passwords: Refactor

This commit is contained in:
Geoffrey Frogeye 2024-06-26 02:16:50 +02:00
parent 81b1307609
commit 7b9c4fb004
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
3 changed files with 127 additions and 103 deletions

View file

@ -14,18 +14,18 @@ fi
tmpdir="$(mktemp -d)"
# sudo so the eval cache is shared with nixos-rebuild
sudo nom build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" -o "$tmpdir/toplevel" "$@"
toplevel="$(readlink "$tmpdir/toplevel")"
toplevel="$(readlink -f "$tmpdir/toplevel")"
rm -rf "$tmpdir"
# Show diff
nvd diff /nix/var/nix/profiles/system "$toplevel"
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
# Figure out specialisation
specialisationArgs=()
currentSystem="$(readlink /run/current-system)"
currentSystem="$(readlink -f /run/current-system)"
while read -r specialisation
do
if [ "$(readlink "/nix/var/nix/profiles/system/specialisation/$specialisation")" = "$currentSystem" ]
if [ "$(readlink -f "/nix/var/nix/profiles/system/specialisation/$specialisation")" = "$currentSystem" ]
then
specialisationArgs=("--specialisation" "$specialisation")
fi
@ -40,14 +40,8 @@ then
fi
if [ "$verb" = "test" ] || [ "$verb" = "switch" ] || [ "$confirm" = "y" ]
then
# Generate passwords first. If there's a missing one that cannot be generated, we'll know before anything is written
"$toplevel/bin/generate-passwords"
# Install the passwords to their respective directories
"$toplevel/bin/install-passwords"
"$toplevel/bin/update-password-store"
sudo nixos-rebuild --flake "$self#$HOSTNAME" test "${specialisationArgs[@]}" "$@"
# Fix passwords permission. After install, so it can use new users
"$toplevel/bin/fix-permissions-passwords"
# TODO Install passwords with correct permissions during activation
fi
# Set as boot