[nix] Make own module

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

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";
};
};
}