nh
nh copied to clipboard
Recognized environment variable `NIX_CONFIG` wrong and called failure
I have confirmed that this is a bug related to nh
- [x] This is a bug, and not an user error or a support request. I understand that my issue will be closed if it is not a bug in NH.
- [x] I have checked the issues tab and confirmed that my issue has not yet been reported. I understand that my issue will be closed if it is a duplicate.
Description
$ echo $NIX_CONFIG
access-tokens = github.com=ghp_11111aaaaa22222bbbbb
$ nh clean all
Password:
env: ‘access-tokens’: No such file or directory
$ export NIX_CONFIG=""
$ nh clean all
Welcome to nh clean
Keeping 1 generation(s)
Keeping paths newer than 0s
...
Installation Method
Stable Release (nixpkgs, pkgs.nh from nixos-unstable or nixos-yy-mm)
Installation Method (Other)
No response
NH Version
v4.2.0
System Information
- system:
"x86_64-darwin" - host os:
Darwin 21.6.0, macOS 12.7.6 - multi-user?:
yes - sandbox:
no - version:
nix-env (Determinate Nix 3.11.2) 2.31.1 - nixpkgs:
/nix/store/fpkfajcxicbkhcfkvmkkzbs149iqy567-ag94x4as0xi7q4lbjbzlhqzifpc8rf64-source
By the way, I wanna whether there is a better way for nh darwin switch ~/nix-config to use github_token or not.
Ran into a similar problem in my setup.
DEBUG Main {
verbosity: Verbosity {
verbose: 1,
quiet: 0,
phantom: PhantomData<clap_verbosity_flag::InfoLevel>,
},
elevation_program: None,
command: Clean(
CleanProxy {
command: All(
CleanArgs {
keep: 1,
keep_since: Duration(
0ns,
),
dry: false,
ask: true,
no_gc: false,
no_gcroots: false,
optimise: false,
max: None,
},
),
},
),
} (nh/src/main.rs:29)
DEBUG NH_VERSION=4.2.0 NH_REV=Some("v4.2.0") (nh/src/main.rs:30)
DEBUG cmd=Exec { nix --version } (nh/src/commands.rs:577)
DEBUG cmd=Exec { nix --version } (nh/src/commands.rs:577)
DEBUG Version normalized: 'nix (Nix) 2.28.5' -> '2.28.5' (nh/src/util.rs:106)
DEBUG Configured envs: NIX_CONFIG=<preserved>, PATH=<preserved>, USER=tms, NIX_PATH=<preserved>, LOCALE_ARCHIVE=<preserved> (nh/src/commands.rs:295)
DEBUG sudo path found path="/run/wrappers/bin/sudo" (nh/src/commands.rs:131)
DEBUG "/run/wrappers/bin/sudo" "env" "\'NIX_CONFIG=extra-experimental-features" "=" "nix-command" "flakes\'" "\'PATH=/nix/store/fk8kvcgqpnrpf2ii1gr8mkq7v2r6qryp-attr-2.5.2-bin/bin:/nix/store/wqyp4w567brnwh2m835r0hqy3hl3llhm-acl-2.3.2-bin/bin:/nix/store/zl30ila57pgcgcvi29qqjyj5snb0hjpr-libarchive-3.8.2/bin:/nix/store/x92x70hdpnpdblgnvpyar7nbvp8h74nb-nix-2.28.5/bin:/nix/store/cm57177zb5gfym5y7x6p1hf2n1yk4j6h-home-manager-0-unstable-2025-05-13/bin:/nix/store/5a45qqzd1av6amdc1l4qyvx8zwczax3b-nh-4.2.0/bin:/nix/store/639k78iljhfmciklnivi0wja8jcy788g-git-2.50.1/bin:/nix/store/3c3sz42wl903r2jcxqraflsn7wc42ziw-just-1.40.0/bin:/nix/store/aibpz49371mdiq5rp9hwz34b19pi8m1y-pre-commit-4.0.1/bin:/nix/store/jd20rkmqmkfkcvk2wl2lmzz7acq4svlr-python3-3.12.12/bin:/nix/store/vcakrjxlp58r4vgh8k8hcf40faj2yc23-python3.12-identify-2.6.10/bin:/nix/store/b1lgia7cg4hbvgzjg9iiqgcbcr7m97b6-python3.12-pytest-8.3.5/bin:/nix/store/k8my1dzyviysp52d0qm8s9s5rrzp8654-python3.12-nodeenv-1.9.1/bin:/nix/store/k8846p49ynkjnybhbiqw4zp6jhmkqwwj-python3.12-virtualenv-20.30.0/bin:/nix/store/hv0lkawr20i8jb94g4w0rnj0cn60rn61-deadnix-1.2.1/bin:/nix/store/8dx5c9vmh9hg44g2qxln59vnafzzwazz-ssh-to-age-1.1.11/bin:/nix/store/10vfnzszaykykghjv1wahr644crnlf06-yq-go-4.45.4/bin:/nix/store/ngvpcb0rnd2k9pzji7jhqssa9sha0igj-bats-1.11.1/bin:/nix/store/lqw61zkgpw173qbwp3f924aigs9qy98l-age-1.2.1/bin:/nix/store/7fml6yb84ava27r2mvhxagcc5216wmrk-sops-3.11.0/bin:/nix/store/5wf9wpdkxs30811kfgkicn9i3nz9jhsh-patchelf-0.15.0/bin:/nix/store/kks0nbx2riwry5qsx0qr87qr0lswmhzi-gcc-wrapper-14.3.0/bin:/nix/store/y28c83zz73yr4vwz1fsl4nsrn6yz5fj0-gcc-14.3.0/bin:/nix/store/fm1snxs1cg8ml9fjj6kra32sc8413k8z-glibc-2.40-66-bin/bin:/nix/store/zwplch93wbpj82bp7riwaixmdx2xi0ah-coreutils-9.7/bin:/nix/store/iga4lv0say4pbbbgkf1v79403n1ip7hf-binutils-wrapper-2.44/bin:/nix/store/42pzy4ahwk8p41hwfmz2nldgvsdws8q1-binutils-2.44/bin:/nix/store/zwplch93wbpj82bp7riwaixmdx2xi0ah-coreutils-9.7/bin:/nix/store/c9jzm47zb8j7jbpw4a7zdm35qmhdf6ws-findutils-4.10.0/bin:/nix/store/z059fc40f58cp2yflhbpfdg539x66b0g-diffutils-3.12/bin:/nix/store/m0i5hf36sv62vgm2ppjkynv03ihdlxvv-gnused-4.9/bin:/nix/store/90r466lzg0jw11v60cki60s0qfhs93vp-gnugrep-3.11/bin:/nix/store/qvgw9scl3jjy1zsjipm3ngpcq472wj7w-gawk-5.3.2/bin:/nix/store/76df6j9sq1ar58id3y3v4rkijany1wxp-gnutar-1.35/bin:/nix/store/44c243x0jpv587hmxrzl31pripa0f0j8-gzip-1.14/bin:/nix/store/59pgpbm743q1nhav513283zinqrf4rqk-bzip2-1.0.8-bin/bin:/nix/store/xpsgmdsqym0ydx6hkvpxrp6174s4fwbl-gnumake-4.4.1/bin:/nix/store/l9k32vj2aczxw62134j1x0dsh569jz2l-bash-5.2p37/bin:/nix/store/jangxddrzycnc2rl1wc1sqhqp26yrx4k-patch-2.7.6/bin:/nix/store/b7g83isqdl778kmcpv6v68z76x4x5riv-xz-5.8.1-bin/bin:/nix/store/4zpfjm2r6chc8b10c1xa1d6asy100sqv-file-5.45/bin:/run/wrappers/bin:/home/tms/.nix-profile/bin:/nix/profile/bin:/home/tms/.local/state/nix/profile/bin:/etc/profiles/per-user/tms/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin\'" "\'USER=tms\'" "\'NIX_PATH=nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels\'" "\'LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive\'" "/nix/store/5a45qqzd1av6amdc1l4qyvx8zwczax3b-nh-4.2.0/bin/.nh-wrapped" "clean" "all" "--ask" "--verbose" (nh/src/util.rs:286)
env: ‘nix-command’: No such file or directory
If you look at the NIX_CONFIG it includes spaces: "\'NIX_CONFIG=extra-experimental-features" "=" "nix-command" "flakes\'". Feels to me this should be a single VARG, but got broken down into several arguments. If I clean NIX_CONFIG the command works.
Checking my flakes, I can see:
default = pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
I think this is just used when bootstrapping the config. However it this format works with the other command.