New rebuild mechanism

Put most of it as a flake app, so we can mess with it without relying on
`rb` being rebuilt. Also nom nom!
This commit is contained in:
Geoffrey Frogeye 2024-06-10 02:11:04 +02:00
parent 7b9d9053bf
commit 17f0ba3370
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
8 changed files with 115 additions and 85 deletions

View file

@ -1,8 +1,4 @@
{ pkgs, config, ... }:
let
ulf = pkgs.writers.writePython3 "update-local-flakes" {
} (builtins.readFile ./update-local-flakes.py);
in
{
home.packages = [
(pkgs.writeShellApplication {
@ -14,32 +10,26 @@ in
verb="$1"
shift
fi
nixos_flake="/etc/nixos/flake.nix"
if [ -f "$nixos_flake" ]
nixos_flake="$(readlink -f /etc/nixos)"
if [ -f "$nixos_flake/flake.nix" ]
then
sudo ${ulf} "$nixos_flake"
# ${pkgs.nix-output-monitor}/bin/nom build "$(dirname "$nixos_flake")#nixosConfigurations.$HOSTNAME.config.system.build.toplevel"
if [ "$verb" = "switch" ] || [ "$verb" = "test" ]
then
sudo nixos-rebuild "$verb" --specialisation ${config.frogeye.polarity} "$@"
else
sudo nixos-rebuild "$verb" "$@"
fi
fi
hm_flake="${config.xdg.configHome}/home-manager/flake.nix"
if [ -f "$hm_flake" ]
then
${ulf} "$hm_flake"
home-manager "$verb" "$@"
fi
nod_flake="${config.xdg.configHome}/nix-on-droid/flake.nix"
if [ -f "$nod_flake" ]
then
${ulf} "$nod_flake"
nix-on-droid "$verb" --flake "$(dirname "$nod_flake")" "$@"
nix run "$nixos_flake#updateLocalFlakes" -- "$nixos_flake"
nix run "$nixos_flake#nixosRebuild" -- "$verb" "$@"
fi
# TODO Fix nix-on-droid and home-manager
# hm_flake="${config.xdg.configHome}/home-manager/flake.nix"
# if [ -f "$hm_flake" ]
# then
# {ulf} "$hm_flake"
# home-manager "$verb" "$@"
# fi
# nod_flake="${config.xdg.configHome}/nix-on-droid/flake.nix"
# if [ -f "$nod_flake" ]
# then
# {ulf} "$nod_flake"
# nix-on-droid "$verb" --flake "$(dirname "$nod_flake")" "$@"
# fi
'';
})
];
}
# TODO make it a flake application, optional nom (is slow), test then boot, flags to confirm each, nvd diff here