home-manager
home-manager copied to clipboard
bug: `programs.bat` causes activation to fail
Are you following the right branch?
- [X] My Nixpkgs and Home Manager versions are in sync
Is there an existing issue for this?
- [X] I have searched the existing issues
Issue description
With programs.bat.enable = true, nixos-rebuild switch --flake . fails during activation with the following error:
Dec 29 16:43:20 xxxx hm-activate-matt[587149]: Activating batCache
Dec 29 16:43:20 xxxx hm-activate-matt[587870]: error: unexpected argument '--build' found
Dec 29 16:43:20 xxxx hm-activate-matt[587870]: tip: to pass '--build' as a value, use '-- --build'
Dec 29 16:43:20 xxxx hm-activate-matt[587870]: Usage: bat <FILE>...
Dec 29 16:43:20 xxxx hm-activate-matt[587870]: For more information, try '--help'.
Maintainer CC
@lovesegfault
System information
- system: `"x86_64-linux"`
- host os: `Linux 6.1.69, NixOS, 24.05 (Uakari), 24.05.20231224.5f64a12`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.1`
- channels(root): `"nixos"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Can confirm this issue. But running bat cache --build on the cli does work, so I don't understand why it fails.
I can't reproduce it
This happens on latest unstable. Did you try with unstable too?
This issue happens to break the post-activation steps of home-manager generations, following unstable Nixpkgs.
To be clearer, the error does occur with sudo nixos-rebuild switch (because it reloads systemd units), but there is no error with sudo nixos-rebuild build && sudo ./result/activate (because it doesn’t reload the home-manager units).
Strangely enough, on my particular system, I think the error mostly occurs when there’s a system-wide cudaSupport = true attribute set in the nixpkgs.config attribute in my configuration.nix; when I commented out this option, then, after rebooting, I didn’t seem to have this bat cache --build problem. @mcwitt, out of curiosity would you happen to also have this nixpkgs.config.cudaSupport option set to true?
$ cat /etc/systemd/system/home-manager-diti.service
[Unit]
After=nix-daemon.socket
Before=systemd-user-sessions.service
Description=Home Manager environment for diti
RequiresMountsFor=/home/diti
Wants=nix-daemon.socket
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/hsa779ydi29sp4q2w7plgzhxmiv1n8qb-glibc-locales-2.38-27/lib/locale/locale-archive"
Environment="PATH=/nix/store/5idwbbv23b6vnqdicx97s3hsgrwwnj7j-coreutils-9.4/bin:/nix/store/4ajik70nplhkb8ndn3gqh7v0b09hmvg9-findutils-4.9.0/bin:/nix/store/6i00hdmzlj56qy500p5gb5v88wfj6nhg-gnugrep-3.11/bin:/nix/store/9zial3lqry9f7rsw31r7vs5p1mnb7lan-gnused-4.9/bin:/nix/store/3zwz5ywmrrh8m6nqzgw3glq6pilxcphq-systemd-255.2/bin:/nix/store/5idwbbv23b6vnqdicx97s3hsgrwwnj7j-coreutils-9.4/sbin:/nix/store/4ajik70nplhkb8ndn3gqh7v0b09hmvg9-findutils-4.9.0/sbin:/nix/store/6i00hdmzlj56qy500p5gb5v88wfj6nhg-gnugrep-3.11/sbin:/nix/store/9zial3lqry9f7rsw31r7vs5p1mnb7lan-gnused-4.9/sbin:/nix/store/3zwz5ywmrrh8m6nqzgw3glq6pilxcphq-systemd-255.2/sbin"
Environment="TZDIR=/nix/store/g4bk1chlkfw18f6zkljygxp3r4yi8m48-tzdata-2023d/share/zoneinfo"
X-StopIfChanged=false
ExecStart=/nix/store/cv17kn1r2d7im3bjkj4qca1ig0myn3s2-hm-setup-env /nix/store/6irsm5c1rcf24vl4f7diic262zz0vhhz-home-manager-generation
RemainAfterExit=yes
SyslogIdentifier=hm-activate-diti
TimeoutStartSec=5m
Type=oneshot
User=diti
[Install]
WantedBy=multi-user.target
$ /nix/store/cv17kn1r2d7im3bjkj4qca1ig0myn3s2-hm-setup-env /nix/store/6irsm5c1rcf24vl4f7diic262zz0vhhz-home-manager-generation
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating createGpgHomedir
Activating linkGeneration
Cleaning up orphan links from /home/diti
No change so reusing latest profile generation 51
Creating home file links in /home/diti
Activating batCache
error: unexpected argument '--build' found
tip: to pass '--build' as a value, use '-- --build'
Usage: bat <FILE>...
For more information, try '--help'.
@Diti
out of curiosity would you happen to also have this
nixpkgs.config.cudaSupportoption set totrue?
hmm, I do not have nixpkgs.config.cudaSupport set to true in my system configuration. I do routinely use flakes (via nix shell/direnv, not in my hm configuration) that set this option to true when importing nixpkgs, but that's probably not related?
This has just started occuring for me as well even though I've been using unstable for months.
I've just started getting this with standalone home-manager, also tracking unstable.
Could somebody who has this issue check their activation script. It should have a line
run /nix/store/…/bin/bat cache --build
Could you check the version of bat, it should be included in the path or run the command with --version.
Also please run /nix/store/…/bin/bat cache --help. Hopefully some of the above will show what is going on.
I think I've figured out what's going on in my case: I have a directory ~/cache (which in my case was created by Steam).
When ~/cache exists, I can reproduce the failure of the command in the activation script:
$ touch cache
$ /nix/store/wc8yb1n2wbkflv66nqmx536xla2bq5gf-bat-0.24.0/bin/bat cache --build
error: unexpected argument '--build' found
After removing ~/cache, that command and the hm activation script finish successfully. It seems like the root of the issue is that the interpretation of bat cache differs depending on whether the path cache exists in the cwd.
Edit: this is a known issue with bat: https://github.com/sharkdp/bat/issues/1726
Wow, that's pretty wild. Thanks for figuring it out @mcwitt 🙂