System Gen151 @ 2025-03-15-19:31:07

This commit is contained in:
Jonas Röger 2025-03-15 19:31:07 +01:00
parent f2d89f08c3
commit 216805a80d

View File

@ -38,12 +38,23 @@
echo ".nixos is unclean!"
exit 1
fi
branch_staging="staging-update"
if ${pkgs.git}/bin/git rev-parse --verify "$branch_staging" >/dev/null 2>&1; then
echo "Using staging update branch."
else
echo "No staging update branch found."
exit 1
fi
${pkgs.git}/bin/git checkout "$branch_staging" flake.lock
echo "Updating nix-flake..."
nix flake update --flake .
echo "NixOS Rebuilding..."
${pkgs.nh}/bin/nh os switch ~/.nixos
gen=$(sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | ${pkgs.gnugrep}/bin/grep current | ${pkgs.gawk}/bin/awk '{print "Gen" $1 " @ " $2 "-" $3}')
${pkgs.git}/bin/git commit --no-gpg-sign -am "Upgrade $gen"
${pkgs.git}/bin/git branch -D "$branch_staging"
popd
'';
update =
@ -55,15 +66,28 @@
echo ".nixos is unclean!"
exit 1
fi
echo "Updating nix-flake..."
nix flake update --flake .
echo "NixOS Building..."
${pkgs.nh}/bin/nh os build ~/.nixos
branch_staging="staging-update"
branch_current="$(${pkgs.git}/bin/git branch --show-current)"
if ${pkgs.git}/bin/git rev-parse --verify "$branch_staging" >/dev/null 2>&1; then
echo "There is already a staging update branch."
else
echo "Creating a new staging update branch."
${pkgs.git}/bin/git switch -c "$branch_staging"
nix flake update --verbose --flake .
${pkgs.git}/bin/git add flake.lock
${pkgs.git}/bin/git commit --no-gpg-sign -m "staging update"
${pkgs.git}/bin/git switch "$branch_current"
fi
nix store diff-closures \
'.?ref='"$branch_current"'#nixosConfigurations.'"$(${pkgs.hostname}/bin/hostname)"'.config.system.build.toplevel' \
'.?ref='"$branch_staging"'#nixosConfigurations.'"$(${pkgs.hostname}/bin/hostname)"'.config.system.build.toplevel'
popd
'';
in {
environment.systemPackages = [
pkgs.bash
home-rebuild
rebuild
upgrade