From 78f7af88a8a921c7d8fa139e6a5d2ba3623b3b49 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 26 Feb 2024 08:12:26 +0000 Subject: [PATCH] Move autoUpgrade back to flake.nix but use flake output instead of URL Set autoUpgrade flake to current flake outpath but keeping nixpkgs update, means things won't automatically be rolled back if there's no internet connection. Keep using remote URL for server though to keep unattended updates. --- flake.nix | 45 ++++++++++++++++++++++++++-------- hosts/Legion/configuration.nix | 3 ++- system/autoupgrade.nix | 15 ------------ 3 files changed, 37 insertions(+), 26 deletions(-) delete mode 100644 system/autoupgrade.nix diff --git a/flake.nix b/flake.nix index 1109de6d..66ffd911 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ }; outputs = { + self, nixpkgs, home-manager, stylix, @@ -42,7 +43,11 @@ ./hosts/${hostName}/configuration.nix ./hosts/${hostName}/hardware-configuration.nix ./system/default.nix - ({pkgs, ...}: { + ({ + lib, + pkgs, + ... + }: { nix = { enable = true; settings = { @@ -66,9 +71,22 @@ ''; }; nixpkgs.config.allowUnfree = true; - system = {inherit stateVersion;}; networking = {inherit hostName;}; programs.${shell}.enable = true; + system = { + inherit stateVersion; + autoUpgrade = { + enable = true; + flake = lib.mkDefault self.outPath; + flags = [ + "--update-input" + "nixpkgs" + "--no-write-lock-file" + "-L" # print build logs + ]; + dates = "02:00"; + }; + }; users = { defaultUserShell = pkgs.${shell}; users = let @@ -139,7 +157,6 @@ systemConfig { inherit hostName user system; systemModules = [ - ./system/autoupgrade.nix ./services/caddy.nix ./services/gitea.nix ./services/grafana.nix @@ -147,7 +164,9 @@ ./services/sshd.nix ./services/syncthing.nix ]; - homeModules = [./home/default.nix]; + homeModules = [ + ./home/default.nix + ]; }; ## Personal @@ -164,7 +183,9 @@ ./system/hyprland.nix ./system/games.nix ]; - homeModules = [./home/hyprland/default.nix]; + homeModules = [ + ./home/hyprland/default.nix + ]; }; Vanguard = let @@ -175,11 +196,12 @@ systemConfig { inherit hostName user system; systemModules = [ - ./system/autoupgrade.nix ./system/hyprland.nix ./system/games.nix ]; - homeModules = [./home/hyprland/default.nix]; + homeModules = [ + ./home/hyprland/default.nix + ]; }; ## Work @@ -195,7 +217,9 @@ ./system/laptop.nix ./system/hyprland.nix ]; - homeModules = [./home/hyprland/default.nix]; + homeModules = [ + ./home/hyprland/default.nix + ]; }; Scorch = let @@ -206,10 +230,11 @@ systemConfig { inherit hostName user system; systemModules = [ - ./system/autoupgrade.nix ./system/hyprland.nix ]; - homeModules = [./home/hyprland/default.nix]; + homeModules = [ + ./home/hyprland/default.nix + ]; }; }; }; diff --git a/hosts/Legion/configuration.nix b/hosts/Legion/configuration.nix index 51c2019f..9777fb40 100644 --- a/hosts/Legion/configuration.nix +++ b/hosts/Legion/configuration.nix @@ -1,6 +1,7 @@ -{...}: { +{config, ...}: { users.mutableUsers = false; system.autoUpgrade = { + flake = "git+${config.nix.registry.nixos.to.url}"; randomizedDelaySec = "15min"; allowReboot = true; rebootWindow = { diff --git a/system/autoupgrade.nix b/system/autoupgrade.nix deleted file mode 100644 index f540553a..00000000 --- a/system/autoupgrade.nix +++ /dev/null @@ -1,15 +0,0 @@ -{config, ...}: let - flakeURL = config.nix.registry.nixos.to.url; -in { - system.autoUpgrade = { - enable = true; - flake = "git+${flakeURL}"; - flags = [ - "--update-input" - "nixpkgs" - "--no-write-lock-file" - "-L" # print build logs - ]; - dates = "02:00"; - }; -}