Each of your “.nix” file is a nix module. Based on my understanding of your question, what you can do as a first step is:
- Add options to
child1.nixcontrolling whether it is enabled and whether it is added towheeletc - Still import
child1.nixin yourconfiguration.nix. - In
configuration.nix, you can specify/override themynamespace.user.child1.enableandmynamespace.user.child1.isWheel.
To achieve that, child1.nix should look like
{ config, lib, pkgs, ... }:
let cfg = config.mynamespace.user.child1;
in {
options.mynamespace.user.child1 = with lib; {
enable = lib.mkEnableOption "Enable the userchild1";
isWheel = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
whether add to the group wheel
'';
};
};
config = lib.mkIf cfg.enable {
users = {
extraUsers = {
"child1" = {
uid = xxxx;
extraGroups = [
... # other groups
] ++ lib.lists.optionals cfg.isWheel [ "wheel" ];;
};
};
};
};
}
Please note the usage of lib.mkIf and lib.lists.optionals.