blob: 4ae9a74c6e952cf479ca50030172654917edf78b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
{
lib,
rustPlatform,
fetchFromGitHub,
pam,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "pam-any";
version = "0-unstable-2024-11-20";
src = fetchFromGitHub {
owner = "ChocolateLoverRaj";
repo = "pam-any";
rev = "e77687709d092a6bb77e57a444403798855075c0";
hash = "sha256-em/vifkse1Qp3iX/oE1vHQK6UAoJvbhBOowhFhgQ+qw=";
};
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
rustPlatform.bindgenHook
];
buildInputs = [
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::<Vec<_>>().join(" ");' \
'let arg_string = {
let joined = args.iter().map(|s| s.to_str().unwrap()).collect::<Vec<_>>().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
mkdir -p $out/lib/security
cp target/*/release/libpam_any.so $out/lib/security/pam_any.so
runHook postInstall
'';
meta = {
description = "A PAM module that runs multiple other PAM modules in parallel, succeeding as long as one of them succeeds";
homepage = "https://github.com/ChocolateLoverRaj/pam-any";
license = lib.licenses.asl20;
platforms = lib.platforms.linux;
};
})
|