extract home-manager assertions into own module

main
Felix Stupp 1 year ago
parent 0dfac33429
commit bd15eb1880
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -0,0 +1,6 @@
{
imports = [
# files
./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-agents scDaemon is enabled but NixOS hardware.gpgSmartcards is disabled
'';
}
];
warnings = [
(lib.mkIf (hwSmartcards && !scDaemon) ''
NixOS hardware.gpgSmartcards is enabled but gpg-agents scDaemon is disabled
'')
];
};
}

@ -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
];

@ -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-agents scDaemon is disabled";
}
{
assertion = scDaemon -> hwSmartcards;
message = "gpg-agents scDaemon is enabled but hardware.gpgSmartcards is disabled on system side";
}
];
home.stateVersion = osConfig.system.stateVersion;
home.file = {

Loading…
Cancel
Save