Skip to content

Instantly share code, notes, and snippets.

@txtyash
Forked from K900/configuration.nix
Created November 4, 2023 13:15
Show Gist options
  • Save txtyash/f8835c0a45967c8b64ef49812cfd69f9 to your computer and use it in GitHub Desktop.
Save txtyash/f8835c0a45967c8b64ef49812cfd69f9 to your computer and use it in GitHub Desktop.
{
imports = [ ./users.nix ];
x.users.alice.editor = "hx";
x.users.bob.editor = "vi";
x.users.clive.editor = "code";
boot.loader.grub.enable = false;
fileSystems."/" = { device = "/dev/sda1"; };
}
❯ nix-build '<nixpkgs/nixos>' -I nixos-config=example.nix
trace: warning: system.stateVersion is not set, defaulting to 23.11. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
trace: warning: I am alice and my editor is hx
trace: warning: I am bob and my editor is vi
trace: warning: I am clive and my editor is code
{ config, lib, ... }:
let
userOptions = {
options = {
editor = lib.mkOption {
type = lib.types.str;
};
};
};
in
{
options = {
x.users = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [ userOptions ];
});
};
};
config.warnings = lib.mapAttrsToList (name: cfg: "I am ${name} and my editor is ${cfg.editor}") config.x.users;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment