who needs temporary files and tee and whatever when you can have BASH SCRIPTS :3
This commit is contained in:
parent
87c2e38720
commit
361dd6dc67
4 changed files with 22 additions and 31 deletions
|
@ -196,11 +196,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
system.activationScripts."upgrade-diff" = {
|
||||
supportsDryActivation = true;
|
||||
text = "${lib.getExe pkgs.nvd} --nix-bin-dir=${config.nix.package}/bin diff /run/current-system $systemConfig 1>&2";
|
||||
};
|
||||
|
||||
systemd = {
|
||||
services.NetworkManager-wait-online.enable = lib.mkForce false;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
agenix.packages.${system}.default
|
||||
just
|
||||
nixfmt-rfc-style
|
||||
nvd
|
||||
statix
|
||||
];
|
||||
};
|
||||
|
|
27
justfile
27
justfile
|
@ -5,17 +5,7 @@ check:
|
|||
nix flake check
|
||||
|
||||
switch *args:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
configuration=$(sudo nixos-rebuild dry-activate --flake . --keep-going {{args}})
|
||||
echo $configuration
|
||||
read -n1 -p "Activate new configuration? [y/N] " answer
|
||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||
sudo "$configuration/bin/switch-to-configuration" switch
|
||||
else
|
||||
echo "Not activating :("
|
||||
exit 1
|
||||
fi
|
||||
bash switch.sh {{args}}
|
||||
|
||||
rollback:
|
||||
sudo nixos-rebuild switch --rollback
|
||||
|
@ -27,21 +17,8 @@ deploy system user="leo":
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
flake=$(nix eval --impure --raw --expr "(builtins.getFlake \"git+file://$PWD\").outPath")
|
||||
sshout=$(mktemp)
|
||||
|
||||
nix copy "$flake" --to "ssh://{{user}}@{{system}}"
|
||||
ssh -t "{{user}}@{{system}}" "sudo nixos-rebuild dry-activate --flake $flake --keep-going" | tee "$sshout"
|
||||
configuration=$(tail -n1 "$sshout" | grep -Po "/nix/store/[\w\d\.\-]+")
|
||||
echo "$configuration"
|
||||
rm "$sshout"
|
||||
|
||||
read -n1 -p "Activate new configuration? [y/N] " answer
|
||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||
ssh -t "{{user}}@{{system}}" "sudo \"$configuration/bin/switch-to-configuration\" switch"
|
||||
else
|
||||
echo "Not activating :("
|
||||
exit 1
|
||||
fi
|
||||
ssh -t "{{user}}@{{system}}" "bash $flake/switch.sh"
|
||||
|
||||
lint *args:
|
||||
statix check -i flake.nix **/hardware-configuration.nix {{args}}
|
||||
|
|
20
switch.sh
Normal file
20
switch.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_path=$(readlink -f "${BASH_SOURCE[0]}")
|
||||
flake=$(dirname "$script_path")
|
||||
|
||||
configuration=$(sudo nixos-rebuild dry-activate --flake "$flake" --keep-going "$@")
|
||||
echo "$configuration"
|
||||
|
||||
nix run --inputs-from "$flake" nixpkgs#nvd -- diff /run/current-system "$configuration"
|
||||
|
||||
read -n1 -rp "Activate new configuration? [y/N] " answer
|
||||
echo
|
||||
|
||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||
sudo "$configuration/bin/switch-to-configuration" switch
|
||||
else
|
||||
echo "Not activating :("
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue