Hey everyone,
I’ve been using NixOS for a while now, but until now, I haven’t quite figured out how to remove duplication in my NixOS configuration. One specific problem that I have is, that I couldn’t figure out, yet, where it is possible to reuse specific attribute sets at a different point in the configuration, for example for different users.
My minimalized examples is this:
home-manager.users.itsme.programs.firefox.profiles = {
"profile1".settings = {
"browser.aboutwelcome.enabled" = false;
"browser.translations.enable" = false;
"browser.startup.blankWindow" = true;
};
"profile2".settings = {
"browser.aboutwelcome.enabled" = true;
"browser.translations.enable" = false;
"browser.startup.blankWindow" = true;
};
};
So I have to very similar attribute sets in different places in the configuration. My initial approach to reusing code would be something like this:
home-manager.users.itsme.programs.firefox.profiles = let
general_settings = {
"browser.aboutwelcome.enabled" = false;
"browser.translations.enable" = false;
"browser.startup.blankWindow" = true;
};
in {
"profile1".settings = general_settings;
"profile2".settings = general_settings;
"profile2".settings = { "browser.aboutwelcome.enabled" = true; };
};
Of course, this doesn’t work, because “profile2”.settings cannot be defined multiple times. Is there any way in nix to reuse attribute sets partly?
I have tried to search documentation and forum, but couldn’t find anything that worked. Feel free to point me to other forum threads or documentation if I missed anything. I would really appreciate your help