mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
{environment,nix}: remove references to $HOME
These can’t be relied upon in a post‐user‐activation world. Technically a breaking change, if anyone has their home directory outside of `/Users` or is using `root` for this, but, well, I did my best and these are legacy defaults anyway.
This commit is contained in:
parent
dee253cf56
commit
424ac85232
3 changed files with 29 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ options, config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -75,7 +75,7 @@ in
|
|||
else if config.system.stateVersion >= 6 then
|
||||
"/etc/nix-darwin/configuration.nix"
|
||||
else
|
||||
"$HOME/.nixpkgs/darwin-configuration.nix";
|
||||
"${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix";
|
||||
defaultText = literalExpression ''
|
||||
if config.nixpkgs.flake.setNixPath then
|
||||
# Don’t set this for flake‐based systems.
|
||||
|
@ -83,7 +83,7 @@ in
|
|||
else if config.system.stateVersion >= 6 then
|
||||
"/etc/nix-darwin/configuration.nix"
|
||||
else
|
||||
"$HOME/.nixpkgs/darwin-configuration.nix"
|
||||
"''${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix"
|
||||
'';
|
||||
description = ''
|
||||
The path of the darwin configuration.nix used to configure the system,
|
||||
|
@ -175,6 +175,16 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
# This is horrible, sorry.
|
||||
system.requiresPrimaryUser = mkIf (
|
||||
config.nix.enable
|
||||
&& !config.nixpkgs.flake.setNixPath
|
||||
&& config.system.stateVersion < 6
|
||||
&& options.environment.darwinConfig.highestPrio == (mkOptionDefault {}).priority
|
||||
) [
|
||||
"environment.darwinConfig"
|
||||
];
|
||||
|
||||
environment.systemPath = mkMerge [
|
||||
[ (makeBinPath cfg.profiles) ]
|
||||
(mkOrder 1200 [ "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ])
|
||||
|
|
|
@ -825,11 +825,18 @@ in
|
|||
|
||||
# Not in NixOS module
|
||||
nix.nixPath = mkIf (config.system.stateVersion < 2) (mkDefault [
|
||||
"darwin=$HOME/.nix-defexpr/darwin"
|
||||
"darwin-config=$HOME/.nixpkgs/darwin-configuration.nix"
|
||||
"darwin=${config.system.primaryUserHome}/.nix-defexpr/darwin"
|
||||
"darwin-config=${config.system.primaryUserHome}/.nixpkgs/darwin-configuration.nix"
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
]);
|
||||
|
||||
system.requiresPrimaryUser = mkIf (
|
||||
config.system.stateVersion < 2
|
||||
&& options.nix.nixPath.highestPrio == (mkDefault {}).priotity
|
||||
) [
|
||||
"nix.nixPath"
|
||||
];
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
|
||||
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
'';
|
||||
};
|
||||
|
||||
system.primaryUserHome = lib.mkOption {
|
||||
internal = true;
|
||||
type = lib.types.str;
|
||||
default =
|
||||
config.users.users.${config.system.primaryUser}.home or "/Users/${config.system.primaryUser}";
|
||||
};
|
||||
|
||||
system.requiresPrimaryUser = lib.mkOption {
|
||||
internal = true;
|
||||
type = lib.types.listOf lib.types.str;
|
||||
|
|
Loading…
Add table
Reference in a new issue