From a49ce0e9edcd717ce6e66041aabd656c02903904 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 17 Jun 2020 23:33:13 +0200 Subject: [PATCH] home-environment: use per-user profile path in /etc Before the profile directory value would point directly to the build output in the Nix store. Unfortunately this would cause an infinite loop if the user's configuration directly or indirectly refers to the profile directory value. Fixes #1188 --- modules/home-environment.nix | 2 +- nix-darwin/default.nix | 2 ++ nixos/default.nix | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index d868ee42..209df4ff 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -402,7 +402,7 @@ in home.profileDirectory = if config.submoduleSupport.enable && config.submoduleSupport.externalPackageInstall - then config.home.path + then "/etc/profiles/per-user/${cfg.username}" else cfg.homeDirectory + "/.nix-profile"; home.sessionVariables = diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 4b226d44..ce6105d4 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -72,6 +72,8 @@ in }) cfg.users ); + environment.pathsToLink = mkIf cfg.useUserPackages [ "/etc/profile.d" ]; + system.activationScripts.postActivation.text = concatStringsSep "\n" (mapAttrsToList (username: usercfg: '' echo Activating home-manager configuration for ${username} diff --git a/nixos/default.nix b/nixos/default.nix index bb0e534a..9aedf618 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -88,6 +88,8 @@ in { (mapAttrs (username: usercfg: { packages = [ usercfg.home.path ]; }) cfg.users); + environment.pathsToLink = mkIf cfg.useUserPackages [ "/etc/profile.d" ]; + systemd.services = mapAttrs' (_: usercfg: let username = usercfg.home.username; in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {