[nix] Make own module

This commit is contained in:
Tibo De Peuter 2023-11-10 13:07:42 +01:00
parent 401d667acf
commit e55d4b46dd
5 changed files with 55 additions and 18 deletions

View file

@ -13,6 +13,11 @@
networking.openconnect-sso.enable = true;
nix = {
flakes.enable = true;
gc.onFull.enable = true;
};
programs = {
home-manager.enable = true;
sops.enable = true;
@ -61,23 +66,11 @@
time.timeZone = "Europe/Brussels";
nix = {
# Allow Nix Flakes
# Keep derivations so shells don't break (direnv)
# If the disk has less than 100MiB, free up to 2GiB by garbage-collecting.
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (2048 * 1024 * 1024)}
'';
# Scheduled garbage-collect
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
package = pkgs.nixFlakes;
};
i18n.defaultLocale = "en_GB.UTF-8";

View file

@ -13,6 +13,11 @@
networking.openconnect-sso.enable = true;
nix = {
flakes.enable = true;
gc.onFull.enable = true;
};
programs = {
home-manager.enable = true;
sops.enable = true;
@ -94,17 +99,11 @@
};
nix = {
# Allow Nix Flakes
# Keep derivations so shells don't break (direnv)
# If the disk has less than 100MiB, free up to 2GiB by garbage-collecting.
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (2048 * 1024 * 1024)}
'';
package = pkgs.nixFlakes;
};
i18n.defaultLocale = "en_GB.UTF-8";

View file

@ -0,0 +1,6 @@
{
imports = [
./flakes
./gc
];
}

View file

@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sisyphus.nix.flakes;
in {
options.sisyphus.nix.flakes.enable = lib.mkEnableOption "Nix Flakes";
config.nix = lib.mkIf cfg.enable {
extraOptions = ''
experimental-features = nix-command flakes
'';
package = pkgs.nixFlakes;
};
}

View file

@ -0,0 +1,25 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sisyphus.nix.gc;
in {
options.sisyphus.nix.gc = {
weekly.enable = lib.mkEnableOption "Scheduled Nix garbage-collection";
onFull.enable = lib.mkEnableOption "Nix garbage-collection when disk is almost full";
};
config.nix = {
# If the disk has less than 100MiB, free up to 2GiB by garbage-collecting.
extraOptions = lib.mkIf cfg.onFull.enable ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (2048 * 1024 * 1024)}
'';
# Scheduled garbage-collect
gc = lib.mkIf cfg.weekly.enable {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
}