diff --git a/nix/nixos-modules/assertions/default.nix b/nix/nixos-modules/assertions/default.nix index 8be7bb4..b8d7294 100644 --- a/nix/nixos-modules/assertions/default.nix +++ b/nix/nixos-modules/assertions/default.nix @@ -1,6 +1,7 @@ { imports = [ # files + ./fileSystems.nix ./nixos.nix ]; } diff --git a/nix/nixos-modules/assertions/fileSystems.nix b/nix/nixos-modules/assertions/fileSystems.nix new file mode 100644 index 0000000..16dd341 --- /dev/null +++ b/nix/nixos-modules/assertions/fileSystems.nix @@ -0,0 +1,21 @@ +{ config, ... }: +let + inherit (builtins) any attrValues elem; + allMounts = attrValues config.fileSystems; + testDiskOption = option: disk: elem option disk.options; + testDiskDiscard = testDiskOption "discard"; +in +{ + config = { + + assertions = [ + { + assertion = config.services.fstrim.enable -> !any testDiskDiscard allMounts; + message = '' + enabling "discard" mount option is discouraged because services.fstrim is enabled + ''; + } + ]; + + }; +}