From 3341e1e694ad64c12055c42008c4927c327950de Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 10 Mar 2026 20:39:54 +0100 Subject: Support config file path, add NixOS module with mode option --- default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'default.nix') diff --git a/default.nix b/default.nix index fa9d521..4ae9a74 100644 --- a/default.nix +++ b/default.nix @@ -28,6 +28,23 @@ rustPlatform.buildRustPackage (finalAttrs: { pam ]; + # Support reading config from a file path instead of only inline JSON, + # since NixOS appends comments to PAM rule lines which breaks JSON parsing. + postPatch = '' + substituteInPlace src/lib.rs \ + --replace-fail \ + 'let arg_string = args.iter().map(|s| s.to_str().unwrap()).collect::>().join(" ");' \ + 'let arg_string = { + let joined = args.iter().map(|s| s.to_str().unwrap()).collect::>().join(" "); + if joined.starts_with("/") { + std::fs::read_to_string(joined.split_whitespace().next().unwrap()) + .unwrap_or(joined) + } else { + joined + } + };' + ''; + # cdylib produces no binaries, only libpam_any.so installPhase = '' runHook preInstall -- cgit v1.3.1