feat(justfile): switch away from nh
replaces nh with a super cool and awesome bash script that basically does the exact same thing except i am the one who wrote it so it's cooler true and real
This commit is contained in:
parent
840718e863
commit
ba4b27b664
3 changed files with 27 additions and 10 deletions
|
@ -30,7 +30,6 @@
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
agenix.packages.${system}.default
|
agenix.packages.${system}.default
|
||||||
just
|
just
|
||||||
nh
|
|
||||||
nixfmt-rfc-style
|
nixfmt-rfc-style
|
||||||
statix
|
statix
|
||||||
];
|
];
|
||||||
|
|
13
justfile
13
justfile
|
@ -5,25 +5,20 @@ check:
|
||||||
nix flake check
|
nix flake check
|
||||||
|
|
||||||
switch *args:
|
switch *args:
|
||||||
@sudo -v
|
bash switch.sh {{ justfile_directory() }} {{args}}
|
||||||
nh os switch --no-nom --ask . -- --keep-going {{args}}
|
|
||||||
|
|
||||||
rollback:
|
rollback:
|
||||||
@sudo -v
|
|
||||||
sudo nixos-rebuild switch --rollback
|
sudo nixos-rebuild switch --rollback
|
||||||
|
|
||||||
boot *args:
|
boot *args:
|
||||||
@sudo -v
|
sudo nixos-rebuild boot --flake {{ justfile_directory() }} --keep-going {{args}}
|
||||||
nh os boot --no-nom --ask . -- --keep-going {{args}}
|
|
||||||
|
|
||||||
deploy system user="leo":
|
deploy system user="leo":
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euxo pipefail
|
set -euo pipefail
|
||||||
flake=$(nix eval --impure --raw --expr "(builtins.getFlake \"git+file://$PWD\").outPath")
|
flake=$(nix eval --impure --raw --expr "(builtins.getFlake \"git+file://$PWD\").outPath")
|
||||||
nix copy "$flake" --to "ssh://{{user}}@{{system}}"
|
nix copy "$flake" --to "ssh://{{user}}@{{system}}"
|
||||||
# -R/--bypass-root-check is needed because of a Git CVE regression in Nix 2.20
|
ssh -t "{{user}}@{{system}}" "bash $flake/switch.sh $flake"
|
||||||
# See NixOS/nix#10202, viperML/nh#200
|
|
||||||
ssh -t "{{user}}@{{system}}" "sudo flock -w 60 /dev/shm/deploy-{{system}} nix run n#nh -- os switch --no-nom -R -H {{system}} --ask $flake"
|
|
||||||
|
|
||||||
lint *args:
|
lint *args:
|
||||||
statix check -i flake.nix **/hardware-configuration.nix {{args}}
|
statix check -i flake.nix **/hardware-configuration.nix {{args}}
|
||||||
|
|
23
switch.sh
Normal file
23
switch.sh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
|
flake="$1"
|
||||||
|
|
||||||
|
echo "${bold}Building configuration...$reset"
|
||||||
|
configuration=$(sudo nixos-rebuild dry-activate --flake "$flake" --keep-going "${@:2}")
|
||||||
|
echo "$configuration"
|
||||||
|
|
||||||
|
nix run "$flake#nixosConfigurations.$(hostname).pkgs.nvd" -- diff /run/current-system "$configuration"
|
||||||
|
|
||||||
|
read -n1 -rp "${bold}Activate new configuration? [y/N]$reset " answer
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||||
|
sudo "$configuration/bin/switch-to-configuration" switch
|
||||||
|
else
|
||||||
|
echo "${bold}Not activating :($reset"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue