From 87724859d07b45c35bb8e56dadc67c69eb9dbd3b Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 8 Dec 2021 11:41:02 +0000 Subject: [PATCH] nixos/user-profiles.nix: Extract module --- nixos/modules/config/user-profiles.nix | 25 +++++++++++++++++++++++++ nixos/modules/config/users-groups.nix | 15 --------------- nixos/modules/module-list.nix | 1 + 3 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 nixos/modules/config/user-profiles.nix diff --git a/nixos/modules/config/user-profiles.nix b/nixos/modules/config/user-profiles.nix new file mode 100644 index 0000000000000..db86debf8cd74 --- /dev/null +++ b/nixos/modules/config/user-profiles.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: +let + inherit (lib) + mapAttrs' + filterAttrs + ; +in +{ + config = { + environment.etc = mapAttrs' (_: { packages, name, ... }: { + name = "profiles/per-user/${name}"; + value.source = pkgs.buildEnv { + name = "user-environment"; + paths = packages; + inherit (config.environment) pathsToLink extraOutputsToInstall; + inherit (config.system.path) ignoreCollisions postBuild; + }; + }) (filterAttrs (_: u: u.packages != []) config.users.users); + + environment.profiles = [ + "$HOME/.nix-profile" + "/etc/profiles/per-user/$USER" + ]; + }; +} diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index 5cc5e30159ae6..34fec82849795 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -594,21 +594,6 @@ in { # Install all the user shells environment.systemPackages = systemShells; - environment.etc = (mapAttrs' (_: { packages, name, ... }: { - name = "profiles/per-user/${name}"; - value.source = pkgs.buildEnv { - name = "user-environment"; - paths = packages; - inherit (config.environment) pathsToLink extraOutputsToInstall; - inherit (config.system.path) ignoreCollisions postBuild; - }; - }) (filterAttrs (_: u: u.packages != []) cfg.users)); - - environment.profiles = [ - "$HOME/.nix-profile" - "/etc/profiles/per-user/$USER" - ]; - assertions = [ { assertion = !cfg.enforceIdUniqueness || (uidsAreUnique && gidsAreUnique); message = "UIDs and GIDs must be unique!"; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index e1877b71575a4..c9f6e685bfc22 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -35,6 +35,7 @@ ./config/system-path.nix ./config/terminfo.nix ./config/unix-odbc-drivers.nix + ./config/user-profiles.nix ./config/users-groups.nix ./config/vte.nix ./config/zram.nix