From 5af86e8cba0793a46460d1bfb6ec379aa3c7ead9 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 11 Aug 2025 10:59:51 +0200 Subject: [PATCH 1/2] nixos/kanidm: add support for kanidm unixd config v2 Co-authored-by: Sammy Etur --- nixos/modules/services/security/kanidm.nix | 14 +++++++++++++- nixos/tests/kanidm.nix | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/security/kanidm.nix b/nixos/modules/services/security/kanidm.nix index f0c6e836194d..c4b23a703737 100644 --- a/nixos/modules/services/security/kanidm.nix +++ b/nixos/modules/services/security/kanidm.nix @@ -368,7 +368,7 @@ in freeformType = settingsFormat.type; options = { - pam_allowed_login_groups = mkOption { + kanidm.pam_allowed_login_groups = mkOption { description = "Kanidm groups that are allowed to login using PAM."; example = "my_pam_group"; type = types.listOf types.str; @@ -673,6 +673,10 @@ in config = mkIf (cfg.enableClient || cfg.enableServer || cfg.enablePam) { warnings = lib.optionals (cfg.package.eolMessage != "") [ cfg.package.eolMessage ]; + services.kanidm = { + unixSettings.version = "2"; + serverSettings.version = "2"; + }; assertions = let @@ -710,6 +714,14 @@ in }; in [ + { + assertion = cfg.enablePam -> !(cfg.unixSettings ? pam_allowed_login_groups); + message = '' + has been renamed + to . + Please change your usage. + ''; + } { assertion = !cfg.enableServer diff --git a/nixos/tests/kanidm.nix b/nixos/tests/kanidm.nix index 78f71fce90c6..c9fd7bb2a083 100644 --- a/nixos/tests/kanidm.nix +++ b/nixos/tests/kanidm.nix @@ -66,7 +66,7 @@ in }; enablePam = true; unixSettings = { - pam_allowed_login_groups = [ "shell" ]; + kanidm.pam_allowed_login_groups = [ "shell" ]; }; }; From e00fd16309633aaaf30a79df3b0a70ef37c11ded Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 3 Dec 2025 19:37:55 +0100 Subject: [PATCH 2/2] nixos/kanidm: fix order of nssDatabase entries --- nixos/modules/services/security/kanidm.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/security/kanidm.nix b/nixos/modules/services/security/kanidm.nix index c4b23a703737..9e46cc776c3b 100644 --- a/nixos/modules/services/security/kanidm.nix +++ b/nixos/modules/services/security/kanidm.nix @@ -29,6 +29,7 @@ let mkIf mkMerge mkOption + mkOrder mkPackageOption optional optionals @@ -1052,8 +1053,9 @@ in system.nssModules = mkIf cfg.enablePam [ cfg.package ]; - system.nssDatabases.group = optional cfg.enablePam "kanidm"; - system.nssDatabases.passwd = optional cfg.enablePam "kanidm"; + # Needs to be before "files" which is `mkBefore` + system.nssDatabases.group = mkOrder 490 (optional cfg.enablePam "kanidm"); + system.nssDatabases.passwd = mkOrder 490 (optional cfg.enablePam "kanidm"); users.groups = mkMerge [ (mkIf cfg.enableServer { kanidm = { }; })