pass flake path as first argument

This commit is contained in:
uku 2025-03-05 10:19:51 +01:00
parent 3ef331d57e
commit 686885f784
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
2 changed files with 5 additions and 6 deletions

View file

@ -5,20 +5,20 @@ check:
nix flake check nix flake check
switch *args: switch *args:
bash switch.sh {{args}} bash switch.sh {{ justfile_directory() }} {{args}}
rollback: rollback:
sudo nixos-rebuild switch --rollback sudo nixos-rebuild switch --rollback
boot *args: boot *args:
sudo nixos-rebuild boot --flake . --keep-going {{args}} sudo nixos-rebuild boot --flake {{ justfile_directory() }} --keep-going {{args}}
deploy system user="leo": deploy system user="leo":
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo 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}}"
ssh -t "{{user}}@{{system}}" "bash $flake/switch.sh" ssh -t "{{user}}@{{system}}" "bash $flake/switch.sh $flake"
lint *args: lint *args:
statix check -i flake.nix **/hardware-configuration.nix {{args}} statix check -i flake.nix **/hardware-configuration.nix {{args}}

View file

@ -4,11 +4,10 @@ set -euo pipefail
bold=$(tput bold) bold=$(tput bold)
reset=$(tput sgr0) reset=$(tput sgr0)
script_path=$(readlink -f "${BASH_SOURCE[0]}") flake="$1"
flake=$(dirname "$script_path")
echo "${bold}Building configuration...$reset" 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 "${@:2}")
echo "$configuration" echo "$configuration"
nix run "$flake#nixosConfigurations.$(hostname).pkgs.nvd" -- diff /run/current-system "$configuration" nix run "$flake#nixosConfigurations.$(hostname).pkgs.nvd" -- diff /run/current-system "$configuration"