Flake for my NixOS devices

Fix imperm

bwc9876.dev ce58e4fe 1da90065

verified
+30 -35
+30 -35
nixosModules/imperm.nix
··· 1 - {...}: { 1 + { ... }: 2 + { 2 3 config, 3 4 lib, 4 5 inputs, 5 6 ... 6 - }: { 7 - imports = [inputs.imperm.nixosModules.default]; 7 + }: 8 + { 9 + imports = [ inputs.imperm.nixosModules.default ]; 8 10 9 11 options.cow.imperm = { 10 12 enable = lib.mkEnableOption "Impermanence, turns off mutable users and expects you to define their password hashes"; ··· 21 23 keep = lib.mkOption { 22 24 type = lib.types.listOf lib.types.str; 23 25 description = "Paths to keep that should be backed up"; 24 - default = []; 26 + default = [ ]; 25 27 }; 26 28 keepCache = lib.mkOption { 27 29 type = lib.types.listOf lib.types.str; 28 30 description = "Paths to keep that shouldn't be backed up"; 29 - default = []; 31 + default = [ ]; 30 32 }; 31 33 }; 32 34 33 - config = let 34 - users = 35 - if config.cow.hm.enable 36 - then config.home-manager.users 37 - else {}; 38 - persistRoot = config.cow.imperm.persistRoot; # Anything important we want backed up 39 - cacheRoot = config.cow.imperm.cacheRoot; # Anything not as important that we can stand losing 40 - in 35 + config = 36 + let 37 + users = if config.cow.hm.enable then config.home-manager.users else { }; 38 + persistRoot = config.cow.imperm.persistRoot; # Anything important we want backed up 39 + cacheRoot = config.cow.imperm.cacheRoot; # Anything not as important that we can stand losing 40 + in 41 41 lib.mkIf config.cow.imperm.enable { 42 42 users.mutableUsers = false; 43 43 ··· 45 45 "${cacheRoot}" = { 46 46 enable = true; 47 47 hideMounts = true; 48 - directories = 49 - [ 50 - "/var/log" 51 - "/var/lib/nixos" 52 - "/var/lib/systemd/coredump" 53 - "/var/lib/systemd/timers" 54 - "/var/lib/systemd/rfkill" 55 - "/var/lib/systemd/backlight" 56 - ] 57 - ++ config.cow.imperm.keep; 58 - users = 59 - builtins.mapAttrs (_: v: { 60 - directories = v.cow.imperm.keepCache or []; 61 - }) 62 - users; 48 + directories = [ 49 + "/var/log" 50 + "/var/lib/nixos" 51 + "/var/lib/systemd/coredump" 52 + "/var/lib/systemd/timers" 53 + "/var/lib/systemd/rfkill" 54 + "/var/lib/systemd/backlight" 55 + ] 56 + ++ config.cow.imperm.keepCache; 57 + users = builtins.mapAttrs (_: v: { 58 + directories = v.cow.imperm.keepCache or [ ]; 59 + }) users; 63 60 }; 64 61 "${persistRoot}" = { 65 62 enable = true; 66 63 hideMounts = true; 67 - directories = config.cow.imperm.keepCache; 68 - users = 69 - builtins.mapAttrs (_: v: { 70 - directories = v.cow.imperm.keep or []; 71 - files = v.cow.imperm.keep or []; 72 - }) 73 - users; 64 + directories = config.cow.imperm.keep; 65 + users = builtins.mapAttrs (_: v: { 66 + directories = v.cow.imperm.keep or [ ]; 67 + files = v.cow.imperm.keep or [ ]; 68 + }) users; 74 69 }; 75 70 }; 76 71 };