diff --git a/nix/hmModules/assertions/default.nix b/nix/hmModules/assertions/default.nix new file mode 100644 index 0000000..865a24e --- /dev/null +++ b/nix/hmModules/assertions/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + # files + ./gpg-agent.nix + ]; +} diff --git a/nix/hmModules/assertions/gpg-agent.nix b/nix/hmModules/assertions/gpg-agent.nix new file mode 100644 index 0000000..a0ba480 --- /dev/null +++ b/nix/hmModules/assertions/gpg-agent.nix @@ -0,0 +1,31 @@ +{ + config, + lib, + osConfig ? null, + ... +}: +let + cfg = config.services.gpg-agent; + hwSmartcards = osConfig.hardware.gpgSmartcards.enable; + scDaemon = cfg.enable && cfg.enableScDaemon; +in +{ + config = lib.mkIf (!builtins.isNull osConfig) { + + assertions = [ + { + assertion = scDaemon -> hwSmartcards; + message = '' + gpg-agent’s scDaemon is enabled but NixOS hardware.gpgSmartcards is disabled + ''; + } + ]; + + warnings = [ + (lib.mkIf (hwSmartcards && !scDaemon) '' + NixOS hardware.gpgSmartcards is enabled but gpg-agent’s scDaemon is disabled + '') + ]; + + }; +} diff --git a/nix/hmModules/default.nix b/nix/hmModules/default.nix index a3a4d4b..26302f6 100644 --- a/nix/hmModules/default.nix +++ b/nix/hmModules/default.nix @@ -1,9 +1,13 @@ -{ ... }@flakeArg: +{ lib, self, ... }@flakeArg: { + assertions.imports = lib.singleton ./assertions; + # combination of all my custom modules # these should not change anything until you enable their custom options default.imports = [ + # flake + self.assertions # directories ./extends ]; diff --git a/nix/nixos-modules/frontend/home.nix b/nix/nixos-modules/frontend/home.nix index 411c360..df8900b 100644 --- a/nix/nixos-modules/frontend/home.nix +++ b/nix/nixos-modules/frontend/home.nix @@ -18,23 +18,6 @@ let in { - # TODO exclude in own home-manager module - assertions = - let - hwSmartcards = osConfig.hardware.gpgSmartcards.enable; - scDaemon = with config.services.gpg-agent; enable && enableScDaemon; - in - [ - { - assertion = hwSmartcards -> scDaemon; - message = "hardware.gpgSmartcards is enabled on system side but gpg-agent’s scDaemon is disabled"; - } - { - assertion = scDaemon -> hwSmartcards; - message = "gpg-agent’s scDaemon is enabled but hardware.gpgSmartcards is disabled on system side"; - } - ]; - home.stateVersion = osConfig.system.stateVersion; home.file = {