Skip to content

Instantly share code, notes, and snippets.

@isabelroses
Last active January 27, 2025 20:59
Show Gist options
  • Save isabelroses/7c69dc97d07431292898fec34ffa781b to your computer and use it in GitHub Desktop.
Save isabelroses/7c69dc97d07431292898fec34ffa781b to your computer and use it in GitHub Desktop.
# try it yourself with:
# nix eval --file eval.nix config.users.users.alice --show-trace
import <nixpkgs/nixos> {
configuration =
{
lib,
pkgs,
config,
options,
...
}:
{
imports = [
{
options.meow = {
users = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
defaultUserSettings = lib.mkOption {
inherit (options.users.users) type;
default = { };
};
};
}
{
config = {
meow = {
users = [
"alice"
"bob"
];
defaultUserSettings = {
shell = pkgs.fish;
};
};
users.users = lib.genAttrs config.meow.users (
name: config.meow.defaultUserSettings // { inherit name; }
);
};
}
];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment