[nix] Make own module
This commit is contained in:
parent
5f0934bf39
commit
4e0b6e9869
5 changed files with 55 additions and 18 deletions
6
nixos/modules/nix/default.nix
Normal file
6
nixos/modules/nix/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./flakes
|
||||
./gc
|
||||
];
|
||||
}
|
14
nixos/modules/nix/flakes/default.nix
Normal file
14
nixos/modules/nix/flakes/default.nix
Normal 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;
|
||||
};
|
||||
}
|
25
nixos/modules/nix/gc/default.nix
Normal file
25
nixos/modules/nix/gc/default.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue