gvolpe
April 8, 2024, 12:16pm
1
Hi all,
A bit puzzled about my NixOS system with all the nix-*
commands going AWOL , not even sure where to start looking.
$ nix-build
The program 'nix-build' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
....
$ nix --version
nix (Nix) 2.20.5
I’ve been messing around with flake-schemas
recently, which require a specific nix
version, and it seems I screwed things up. I don’t use nix-build
directly, but it’s required by Home Manager, so for now I can workaround this issue by using nix shell, but it would be great to fix this properly.
I tried setting nix.package = pkgs.nixVersions.stable; # nix 2.18.1
but no luck either. This value was set to nixVersions.unstable
before (nix 2.20.5), and previously to the custom nix version with schema support, and I think that’s when the problem started.
I’ve restarted my system to boot into the nix stable config as well, but commands are still gone.
Any ideas on where to start looking for a fix?
How does your $PATH look like?
Meanwhile you can access nix-build directly from the store, e.g. with `/nix/store/m28r6mf37cc8bwwq52kqdzdkc9yrq3ag-nix-2.18.1/bin/nix-build --help
gvolpe
April 8, 2024, 1:13pm
3
It looks as follows:
$ echo $PATH
/run/wrappers/bin /home/gvolpe/.nix-profile/bin /nix/profile/bin /home/gvolpe/.local/state/nix/profile/bin /etc/profiles/per-user/gvolpe/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin
Yes, I can do the following, for instance:
$ nix shell nixpkgs#nix
$ which nix-build
/nix/store/6r0bm8shswm9v08kzvq24ib48mx3kxmn-nix-2.18.1/bin/nix-build
But nix-build
is needed by Home Manager, I don’t use it directly.
gvolpe
April 8, 2024, 1:17pm
4
Here’s something interesting from further inspecting one of the paths declared in PATH:
$ ls -la /run/current-system/sw/bin/ | rg 'nix-'
lrwxrwxrwx - root 1 Jan 1970 nix -> /nix/store/6r0bm8shswm9v08kzvq24ib48mx3kxmn-nix-2.18.1/bin/nix
lrwxrwxrwx - root 1 Jan 1970 nix-build -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-build
lrwxrwxrwx - root 1 Jan 1970 nix-channel -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-channel
lrwxrwxrwx - root 1 Jan 1970 nix-collect-garbage -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-collect-garbage
lrwxrwxrwx - root 1 Jan 1970 nix-copy-closure -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-copy-closure
lrwxrwxrwx - root 1 Jan 1970 nix-daemon -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-daemon
lrwxrwxrwx - root 1 Jan 1970 nix-env -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-env
lrwxrwxrwx - root 1 Jan 1970 nix-hash -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-hash
lrwxrwxrwx - root 1 Jan 1970 nix-info -> /nix/store/imd120fan53pgy6qi6kra0q15v5kn6dn-nix-info/bin/nix-info
lrwxrwxrwx - root 1 Jan 1970 nix-instantiate -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-instantiate
lrwxrwxrwx - root 1 Jan 1970 nix-prefetch-url -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-prefetch-url
lrwxrwxrwx - root 1 Jan 1970 nix-schema -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-schema
lrwxrwxrwx - root 1 Jan 1970 nix-shell -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-shell
lrwxrwxrwx - root 1 Jan 1970 nix-store -> /nix/store/cz4my09fw8ricxpan1vsr27jkva4m9z7-nix-2.21.0pre20240311_d76e5fb/bin/nix-store
All the nix-*
commands are symlinked to the custom nix
command with schema support. Any ideas how to fix these symlinks?
gvolpe
April 8, 2024, 1:22pm
5
Alright, I figured it out. I was adding nix-schema
to my environment.systemPackages
without noticing it’s overriding all the nix-*
commands
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
# Set your time zone.
time.timeZone = "Europe/Warsaw";
# List packages installed in system profile
environment.systemPackages = with pkgs; [
globalprotect-openconnect
firejail
nix-schema
vim
wget
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;