From b020faa8d264a5e63b5718b30b0cd9ffd93c4c76 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Sun, 9 Jun 2024 23:58:23 +0200 Subject: [PATCH] Extract auto-gc into it's own module --- hosts/inspiron/default.nix | 4 +--- hosts/north/default.nix | 4 +--- modules/system/auto-gc.nix | 13 +++++++++++++ modules/system/default.nix | 1 + modules/system/nix-helper.nix | 16 ++-------------- 5 files changed, 18 insertions(+), 20 deletions(-) create mode 100644 modules/system/auto-gc.nix diff --git a/hosts/inspiron/default.nix b/hosts/inspiron/default.nix index fd8ede2..3bdd983 100644 --- a/hosts/inspiron/default.nix +++ b/hosts/inspiron/default.nix @@ -27,10 +27,8 @@ sops.enable = true; printing.enable = true; syncthing.enable = true; - nix-helper = { - enable = true; + nix-helper.enable = true; auto-gc.enable = true; - }; night-light.enable = true; }; diff --git a/hosts/north/default.nix b/hosts/north/default.nix index 3d959b5..6a47d97 100644 --- a/hosts/north/default.nix +++ b/hosts/north/default.nix @@ -23,10 +23,8 @@ sops.enable = true; printing.enable = true; syncthing.enable = true; - nix-helper = { - enable = true; + nix-helper.enable = true; auto-gc.enable = true; - }; night-light.enable = true; }; diff --git a/modules/system/auto-gc.nix b/modules/system/auto-gc.nix new file mode 100644 index 0000000..990b863 --- /dev/null +++ b/modules/system/auto-gc.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: +{ + options.myConfig.auto-gc.enable = lib.mkEnableOption ""; + + config = lib.mkIf config.myConfig.auto-gc.enable { + programs.nh.enable = true; + programs.nh.clean = { + enable = true; + dates = "daily"; + extraArgs = "--keep 10 --keep-since 3d"; + }; + }; +} diff --git a/modules/system/default.nix b/modules/system/default.nix index c77b0b9..9a08257 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -14,6 +14,7 @@ ./printing.nix ./syncthing.nix ./nix-helper.nix + ./auto-gc.nix ./night-light.nix ]; } diff --git a/modules/system/nix-helper.nix b/modules/system/nix-helper.nix index 9b5eb5c..5cf5512 100644 --- a/modules/system/nix-helper.nix +++ b/modules/system/nix-helper.nix @@ -1,14 +1,8 @@ { config, lib, ... }: -let - cfg = config.myConfig.nix-helper; -in { - options.myConfig.nix-helper = { - enable = lib.mkEnableOption ""; - auto-gc.enable = lib.mkEnableOption ""; - }; + options.myConfig.nix-helper.enable = lib.mkEnableOption ""; - config = lib.mkIf cfg.enable { + config = lib.mkIf config.myConfig.nix-helper.enable { environment.sessionVariables.FLAKE = "/home/seb/Projects/nixos/my-config"; programs.nh.enable = true; @@ -22,11 +16,5 @@ in nrb = "${rebuild} boot"; nrrb = "nrb && reboot"; }; - - programs.nh.clean = lib.mkIf cfg.auto-gc.enable { - enable = true; - dates = "daily"; - extraArgs = "--keep 10 --keep-since 3d"; - }; }; }