feat(justfile): switch away from nh #1
1 changed files with 7 additions and 3 deletions
10
switch.sh
10
switch.sh
|
@ -1,20 +1,24 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
script_path=$(readlink -f "${BASH_SOURCE[0]}")
|
script_path=$(readlink -f "${BASH_SOURCE[0]}")
|
||||||
flake=$(dirname "$script_path")
|
flake=$(dirname "$script_path")
|
||||||
|
|
||||||
|
echo "${bold}Building configuration...$reset"
|
||||||
configuration=$(sudo nixos-rebuild dry-activate --flake "$flake" --keep-going "$@")
|
configuration=$(sudo nixos-rebuild dry-activate --flake "$flake" --keep-going "$@")
|
||||||
echo "$configuration"
|
echo "$configuration"
|
||||||
|
|
||||||
nix run --inputs-from "$flake" nixpkgs#nvd -- diff /run/current-system "$configuration"
|
nix run "$flake#nixosConfigurations.$(hostname).pkgs.nvd" -- diff /run/current-system "$configuration"
|
||||||
|
|
||||||
read -n1 -rp "Activate new configuration? [y/N] " answer
|
read -n1 -rp "${bold}Activate new configuration? [y/N]$reset " answer
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||||
sudo "$configuration/bin/switch-to-configuration" switch
|
sudo "$configuration/bin/switch-to-configuration" switch
|
||||||
else
|
else
|
||||||
echo "Not activating :("
|
echo "${bold}Not activating :($reset"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue