Revert "Revert "feat: Upgrade into current specialisation""
This reverts commit 1a563dc66f
.
This commit is contained in:
parent
1a563dc66f
commit
a00ef96fa3
|
@ -5,6 +5,37 @@
|
||||||
project-manager = inputs.project-manager.packages.x86_64-linux.default;
|
project-manager = inputs.project-manager.packages.x86_64-linux.default;
|
||||||
taskDir = config.home-manager.users.lukew.home.homeDirectory
|
taskDir = config.home-manager.users.lukew.home.homeDirectory
|
||||||
+ "/Documents/tasks";
|
+ "/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 {
|
in {
|
||||||
console.useXkbConfig = true;
|
console.useXkbConfig = true;
|
||||||
environment = {
|
environment = {
|
||||||
|
@ -250,8 +281,7 @@
|
||||||
nixos-status = "journalctl -xefu nixos-upgrade.service";
|
nixos-status = "journalctl -xefu nixos-upgrade.service";
|
||||||
nixos-upgrade =
|
nixos-upgrade =
|
||||||
"${config.lwad.rootCommand} systemctl start nixos-upgrade.service";
|
"${config.lwad.rootCommand} systemctl start nixos-upgrade.service";
|
||||||
nixos-upgrade-local =
|
nixos-upgrade-local = "${upgradeScript} local";
|
||||||
"${config.lwad.rootCommand} nixos-rebuild switch --no-write-lock-file --recreate-lock-file --flake /home/lukew/nixos#";
|
|
||||||
open = "${pkgs.xdg-utils}/bin/xdg-open";
|
open = "${pkgs.xdg-utils}/bin/xdg-open";
|
||||||
otp = ''
|
otp = ''
|
||||||
${pkgs.cloak}/bin/cloak view lancs | ${pkgs.coreutils}/bin/tr -d "\n" | ${pkgs.xclip}/bin/xclip -i -selection clipboard'';
|
${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;
|
"btrbk-${config.networking.hostName}".restartIfChanged = false;
|
||||||
# Work around incompatabilities between old systemd and new syscalls.
|
# Work around incompatabilities between old systemd and new syscalls.
|
||||||
nix-daemon.serviceConfig.SystemCallErrorNumber = "ENOSYS";
|
nix-daemon.serviceConfig.SystemCallErrorNumber = "ENOSYS";
|
||||||
|
nixos-upgrade.script = lib.mkForce ''
|
||||||
|
${upgradeScript}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
tmpfiles.rules = [ "d ${taskDir} - lukew users" ];
|
tmpfiles.rules = [ "d ${taskDir} - lukew users" ];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue