Add helper functions for multi-user toggle support
Introduced a new file `lib.nix` containing helper functions to streamline user package management and attributes for multi-user configurations. Updated various modules to utilize these functions, enhancing code maintainability and readability.
This commit is contained in:
@@ -34,27 +34,25 @@ in
|
||||
};
|
||||
config = lib.mkIf config.my.dev.nix.enable {
|
||||
users.users = let
|
||||
users = if lib.isString config.my.toggleUsers.dev then [ config.my.toggleUsers.dev ] else config.my.toggleUsers.dev;
|
||||
in lib.mkMerge (map (user: {
|
||||
${user} = { inherit packages; };
|
||||
}) users);
|
||||
userLib = import ../lib.nix { inherit lib; };
|
||||
in userLib.mkUserAttrs config.my.toggleUsers.dev { inherit packages; };
|
||||
home-manager.users = let
|
||||
users = if lib.isString config.my.toggleUsers.dev then [ config.my.toggleUsers.dev ] else config.my.toggleUsers.dev;
|
||||
in lib.mkMerge (map (user: {
|
||||
${user}.programs.${shellType}.shellAliases =
|
||||
inputs.self.lib.mergeAliases inputs.self.lib.commonAliases
|
||||
{
|
||||
nixformat = ''
|
||||
deadnix -e && \
|
||||
nix run nixpkgs#nixfmt-tree && \
|
||||
statix fix
|
||||
'';
|
||||
nix-push-cache = ''
|
||||
nix build $NH_FLAKE#nixosConfigurations.${config.networking.hostName}.config.system.build.toplevel \
|
||||
--print-out-paths --fallback --max-jobs 100 --cores 0 |
|
||||
nix run nixpkgs#attic-client -- push lan:nixos --stdin
|
||||
'';
|
||||
};
|
||||
}) users);
|
||||
userLib = import ../lib.nix { inherit lib; };
|
||||
in userLib.mkHomeManagerUsers config.my.toggleUsers.dev (user: {
|
||||
programs.${shellType}.shellAliases =
|
||||
inputs.self.lib.mergeAliases inputs.self.lib.commonAliases
|
||||
{
|
||||
nixformat = ''
|
||||
deadnix -e && \
|
||||
nix run nixpkgs#nixfmt-tree && \
|
||||
statix fix
|
||||
'';
|
||||
nix-push-cache = ''
|
||||
nix build $NH_FLAKE#nixosConfigurations.${config.networking.hostName}.config.system.build.toplevel \
|
||||
--print-out-paths --fallback --max-jobs 100 --cores 0 |
|
||||
nix run nixpkgs#attic-client -- push lan:nixos --stdin
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user