diff --git a/hosts/lambdaos/configuration.nix b/hosts/lambdaos/configuration.nix index 8d3cdfc..2de8fff 100644 --- a/hosts/lambdaos/configuration.nix +++ b/hosts/lambdaos/configuration.nix @@ -129,36 +129,43 @@ }; services = { - "update-flake" = { - path = with pkgs; [ - git - openssh - nix - nixos-rebuild - ]; - script = '' - [[ ! -d '/root/nixconf' ]] && git clone git@github.com:itepastra/nixconf /root/nixconf - cd /root/nixconf - git fetch - git reset --hard origin/main - git pull - nix flake update --commit-lock-file - nixos-rebuild boot -L --flake . - git push - ''; - serviceConfig = { - Type = "oneshot"; - User = "root"; - RemainAfterExit = true; + "update-flake" = + let + script = pkgs.writeShellApplication { + name = "update-flake-script"; + runtimeInputs = with pkgs; [ + git + openssh + config.nix.package + config.system.build.nixos-rebuild + ]; + text = '' + [[ ! -d '/root/nixconf' ]] && git clone git@github.com:itepastra/nixconf /root/nixconf + cd /root/nixconf + git fetch + git reset --hard origin/main + git pull + nix flake update --commit-lock-file + nixos-rebuild boot -L --flake . + git push + ''; + }; + in + { + serviceConfig = { + Type = "oneshot"; + User = "root"; + ExecStart = "${script}/bin/update-flake-script"; + RemainAfterExit = true; + }; + wants = [ + "network-online.target" + ]; + after = [ + "network-online.target" + ]; + restartIfChanged = false; }; - wants = [ - "network-online.target" - ]; - after = [ - "network-online.target" - ]; - restartIfChanged = false; - }; }; user.services.polkit-gnome-authentication-agent-1 = { description = "polkit-gnome-authentication-agent-1"; diff --git a/hosts/muos/configuration.nix b/hosts/muos/configuration.nix index dd62d87..204bf7f 100644 --- a/hosts/muos/configuration.nix +++ b/hosts/muos/configuration.nix @@ -3,6 +3,7 @@ # and in the NixOS manual (accessible by running ‘nixos-help’). { + config, pkgs, ... }: @@ -75,7 +76,7 @@ serviceConfig = { Type = "exec"; User = "root"; - ExecStart = "${pkgs.nixos-rebuild-ng}/bin/nixos-rebuild switch --flake github:itepastra/nixconf"; + ExecStart = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch --flake github:itepastra/nixconf"; }; wants = [ "network-online.target" diff --git a/hosts/nuos/configuration.nix b/hosts/nuos/configuration.nix index 817423b..1c78276 100644 --- a/hosts/nuos/configuration.nix +++ b/hosts/nuos/configuration.nix @@ -122,7 +122,7 @@ in serviceConfig = { Type = "exec"; User = "root"; - ExecStart = "${pkgs.nixos-rebuild-ng}/bin/nixos-rebuild boot --flake github:itepastra/nixconf"; + ExecStart = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch --flake github:itepastra/nixconf"; ExecStopPost = ''shutdown -r +5 "Preparing update finished, rebooting..."''; }; wants = [