nix-darwin
nix-darwin copied to clipboard
environment.darwinConfig ignored in most shells
I have this line in my configuration file:
environment.darwinConfig = "$HOME/.nix-environment/darwin.nix";
This is not respected in my shell:
➜ echo $NIX_PATH
darwin-config=/Users/jamie/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/jamie/.nix-defexpr/channels
If I create a shell with sudo, it is then respected
➜ sudo -u jamie -i
➜ echo $NIX_PATH
darwin-config=/Users/jamie/.nix-environment/darwin.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/jamie/.nix-defexpr/channels
System info:
➜ nix-shell -p nix-info --run "nix-info -m"
- system: `"aarch64-darwin"`
- host os: `Darwin 21.2.0, macOS 12.1`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.5.1`
- channels(jamie): `"darwin, home-manager"`
- channels(root): `"darwin, home-manager, nixpkgs-22.05pre346058.bc59ba15b64"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
My dotfiles repository, which includes these files, can be found here: https://github.com/Sciencentistguy/dotfiles
@Sciencentistguy, are you still experiencing this issue?
I moved to flakes to avoid this issue, so no.
Huh, well, I'm not sure what was going on here. With let latest version of nix-darwin, when I set environment.darwinConfig to something, then use nix repl or nix eval to query my final config, nix.nixPath and environment.variables.NIX_PATH are both set correctly. (I'm using flakes, but I don't think that should matter, for testing this.)
I just made a fresh install of nix, nix-darwin and home manager. I had this in my config:
{
imports = [ <home-manager/nix-darwin> ];
environment = {
darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
};
}
Also, the fish shell is enabled through the home manager module.
Ran this:
darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
And when I subsequently run darwin-rebuild switch, I'm getting:
building the system configuration...
error:
… while evaluating the attribute 'config.system.build.toplevel'
at /nix/store/07cccv29wds2jfs9xibj5ng4h2694apz-nixpkgs/nixpkgs/lib/modules.nix:326:9:
325| options = checked options;
326| config = checked (removeAttrs config [ "_module" ]);
| ^
327| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/07cccv29wds2jfs9xibj5ng4h2694apz-nixpkgs/nixpkgs/lib/modules.nix:326:18:
325| options = checked options;
326| config = checked (removeAttrs config [ "_module" ]);
| ^
327| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full trace)
error: file 'darwin-config' was not found in the Nix search path (add it using $NIX_PATH or -I)
at «none»:0: (source not available)
$NIX_PATH appears to be empty.