diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-10-14 08:29:06 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-10-14 08:29:06 +0200 |
| commit | a00d4bf2c04220255f5f48ee313f24360a1b70bb (patch) | |
| tree | 69861b53060ff19daeb33584a82db037a225af66 | |
| parent | d67e818223a6965d76362dd0407a17caf2c3fe4c (diff) | |
nixos: auto-upgrade: enable monitoring
| -rw-r--r-- | modules/nixos/personal/nix.nix | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/modules/nixos/personal/nix.nix b/modules/nixos/personal/nix.nix index d1bd3cb..35d7fc7 100644 --- a/modules/nixos/personal/nix.nix +++ b/modules/nixos/personal/nix.nix @@ -1,6 +1,10 @@ -{ config, lib, pkgs, ... }: - -let cfg = config.personal.nix; +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.personal.nix; in { options.personal.nix = { enable = lib.mkEnableOption "nix configuration"; @@ -13,11 +17,11 @@ in { }; config = lib.mkIf cfg.enable { - nixpkgs.config = { allowUnfree = true; }; + nixpkgs.config = {allowUnfree = true;}; nix = { settings = { auto-optimise-store = true; - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = ["nix-command" "flakes"]; }; gc = lib.mkIf cfg.gc.enable { automatic = true; @@ -28,14 +32,16 @@ in { system.autoUpgrade = lib.mkIf cfg.autoUpgrade { enable = true; flake = cfg.flake; - flags = if (cfg.flake == null) then - [ "--upgrade-all" ] - else - [ "--commit-lock-file" ] ++ pkgs.personal.lib.updateInputFlag "nixpkgs"; + flags = + if (cfg.flake == null) + then ["--upgrade-all"] + else ["--commit-lock-file"] ++ pkgs.personal.lib.updateInputFlag "nixpkgs"; }; systemd.services = { + nixos-upgrade.personal.monitor = true; nix-gc = { - after = lib.optional (cfg.autoUpgrade && cfg.gc.enable) + after = + lib.optional (cfg.autoUpgrade && cfg.gc.enable) "nixos-upgrade.service"; personal.monitor = true; }; @@ -44,18 +50,17 @@ in { description = "Remove dead symlinks in /nix/var/nix/gcroots"; serviceConfig.Type = "oneshot"; script = "find /nix/var/nix/gcroots -xtype l -delete"; - before = lib.mkIf config.nix.gc.automatic [ "nix-gc.service" ]; - wantedBy = lib.mkIf config.nix.gc.automatic [ "nix-gc.service" ]; + before = lib.mkIf config.nix.gc.automatic ["nix-gc.service"]; + wantedBy = lib.mkIf config.nix.gc.automatic ["nix-gc.service"]; personal.monitor = true; }; }; - programs.git = - lib.mkIf (cfg.flake != null && lib.hasPrefix "git+file" cfg.flake) { - enable = true; - config.user = { - name = "Root user of ${config.networking.hostName}"; - email = "root@${config.networking.hostName}"; - }; + programs.git = lib.mkIf (cfg.flake != null && lib.hasPrefix "git+file" cfg.flake) { + enable = true; + config.user = { + name = "Root user of ${config.networking.hostName}"; + email = "root@${config.networking.hostName}"; }; + }; }; } |
