I’m currently in the process of writing a module to host virtualisation options (e.g. Docker) for my NixOS config.
To enable that, I set virtualisation.docker.enable = true;
. Since ideally, I want to be able to only import the module into my config without having to make any extra declarations, I’m searching for a way to extend the users.users.<my-username>.extraGroups
option by the "docker"
group. I define the extraGroups
option in my configuration.nix
, which also imports the module. I wondered how I would extend the extraGroups
option in my module, while keeping the values that are already specified in my configuration.nix
.
See my files here, shortened for readability:
configuration.nix
:
{ inputs, lib, config, pkgs, ... }: {
imports = [
./virtualisation.nix
];
users.users.<my-username> = {
extraGroups = [ "networkmanager" "wheel" ];
};
}
virtualisation.nix
:
{ pkgs, ... }: {
virtualisation.docker.enable = true;
# TODO: add user to docker group
}