I love how with NixOS I can use flake.nix
and nix develop
to create development environments for different things. I don’t have to use a VM or distrobox or modify the OS that I use. However, I want to test a custom PAM module, such as GitHub - ChocolateLoverRaj/pam-random: A PAM module that has a 1/2 chance of succeeding. Useful for testing PAM related stuff.. However, testing it requires adding a file to in /etc/pam.d
and adding a file to /lib64/security
. How do I add these files to a devShell? This is how I would do it in a VM / other machine accessed through SSH:
IP=192.168.124.164
cargo build
scp ./pam-random root@$IP:/etc/pam.d
scp ./target/debug/libpam_random.so root@$IP:/lib64/security
pamtester pam-random <user> authenticate
this is the flake.nix
that I’m using to build the file ./target/debug/libpam_random.so
:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, nixpkgs
, rust-overlay
, flake-utils
}:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
(import rust-overlay)
];
};
in
with pkgs;
{
devShells.default = mkShell {
buildInputs = [
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
linux-pam
];
};
}
);
}
how can I create something similar which includes the custom file in /etc
and /lib64
?