feat: Upgrade into current specialisation
This commit is contained in:
parent
1a9d3084da
commit
6f91f68d53
|
@ -5,6 +5,37 @@
|
|||
project-manager = inputs.project-manager.packages.x86_64-linux.default;
|
||||
taskDir = config.home-manager.users.lukew.home.homeDirectory
|
||||
+ "/Documents/tasks";
|
||||
upgradeScript = let
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
nix = "${pkgs.nix}/bin/nix";
|
||||
sed = "${pkgs.gnused}/bin/sed";
|
||||
test = "${pkgs.coreutils}/bin/test";
|
||||
in pkgs.writeScript "nixos-upgrade.sh" ''
|
||||
upgrade() {
|
||||
if ${test} "$1" == "local"; then
|
||||
source="/home/lukew/nixos"
|
||||
args=""
|
||||
else
|
||||
source="git+ssh://disroot/lwad/nixos.git"
|
||||
args="--refresh"
|
||||
fi
|
||||
|
||||
out="$(${nix} build $source#nixosConfigurations.akame.config.system.build.toplevel --no-write-lock-file --recreate-lock-file --no-link --print-out-paths $args)"
|
||||
specialisation="$(${jq} -re '.["org.nixos.bootspec.v1"].label' /run/current-system/boot.json | ${sed} -e 's/NixOS [^ ]* //' -Ee 's/[-]{0,1}([0-9]{2}\.){2}[0-9]{8}\.[0-9a-f]{7} \(.*//')"
|
||||
|
||||
if ${test} -n "$specialisation"; then
|
||||
if eval "$(${jq} -re ".[\"org.nixos.specialisation.v1\"] | has(\"$specialisation\")" "$out/boot.json")"; then
|
||||
${config.lwad.rootCommand} "$out/bin/switch-to-configuration" boot
|
||||
${config.lwad.rootCommand} "$out/specialisation/$specialisation/bin/switch-to-configuration" test
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
${config.lwad.rootCommand} "$out/bin/switch-to-configuration" switch
|
||||
}
|
||||
|
||||
upgrade "$1"
|
||||
'';
|
||||
in {
|
||||
console.useXkbConfig = true;
|
||||
environment = {
|
||||
|
@ -250,8 +281,7 @@
|
|||
nixos-status = "journalctl -xefu nixos-upgrade.service";
|
||||
nixos-upgrade =
|
||||
"${config.lwad.rootCommand} systemctl start nixos-upgrade.service";
|
||||
nixos-upgrade-local =
|
||||
"${config.lwad.rootCommand} nixos-rebuild switch --no-write-lock-file --recreate-lock-file --flake /home/lukew/nixos#";
|
||||
nixos-upgrade-local = "${upgradeScript} local";
|
||||
open = "${pkgs.xdg-utils}/bin/xdg-open";
|
||||
otp = ''
|
||||
${pkgs.cloak}/bin/cloak view lancs | ${pkgs.coreutils}/bin/tr -d "\n" | ${pkgs.xclip}/bin/xclip -i -selection clipboard'';
|
||||
|
@ -401,6 +431,9 @@
|
|||
"btrbk-${config.networking.hostName}".restartIfChanged = false;
|
||||
# Work around incompatabilities between old systemd and new syscalls.
|
||||
nix-daemon.serviceConfig.SystemCallErrorNumber = "ENOSYS";
|
||||
nixos-upgrade.script = lib.mkForce ''
|
||||
${upgradeScript}
|
||||
'';
|
||||
};
|
||||
tmpfiles.rules = [ "d ${taskDir} - lukew users" ];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue