Skip to content

Instantly share code, notes, and snippets.

@haylinmoore
Created November 11, 2025 08:58
Show Gist options
  • Select an option

  • Save haylinmoore/5d253c91df849c013ffdf2fe19e72583 to your computer and use it in GitHub Desktop.

Select an option

Save haylinmoore/5d253c91df849c013ffdf2fe19e72583 to your computer and use it in GitHub Desktop.
let
pkgs = import <nixpkgs> { };
lib = pkgs.lib;
targetFS =
{ targetFSes }:
pkgs.symlinkJoin {
name = "fs";
paths = targetFSes;
};
passwd =
{ users }:
let
concatMapStrings = lib.strings.concatMapStrings;
combiner = (x: x + ":x:0:0::/home/${x}:/run/current-system-/sw/bin/bash\n");
content = concatMapStrings combiner users;
in
pkgs.stdenv.mkDerivation {
pname = "passwd";
name = "passwd";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/etc/
cat <<EOF > $out/etc/passwd
${content}'';
};
infuse = (import ./lib/infuse.nix { inherit lib; }).v1.infuse;
in
lib.fix (
final:
infuse { } [
{
fs.__assign = pkgs.callPackage targetFS {
targetFSes = [ ];
};
}
{
passwd.__assign = pkgs.callPackage passwd {
users = [
"root"
"toor"
];
};
fs.__input.targetFSes.__append = [ final.passwd ];
}
{
passwd.__input.users.__append = [ "haylin" ];
}
]
)
root:x:0:0::/home/root:/run/current-system-/sw/bin/bash
toor:x:0:0::/home/toor:/run/current-system-/sw/bin/bash
haylin:x:0:0::/home/haylin:/run/current-system-/sw/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment