Nixos rebuild - root vs sudo - program 'git' failed with exit code 1

nix-shell -p nix-info --run “nix-info -m”

  • system: "x86_64-linux"
  • host os: Linux 5.7.10, NixOS, 20.03.2652.076c67fdea6 (Markhor)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20200622_334e26b
  • channels(ae): "home-manager-20.03, nixos-20.03.3001.985047d3c9f, unstableNix-21.03pre243353.6d4b93323e7, unstableOS-21.03pre243690.441a7da8080"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

sudo nixos-rebuild switch --show-trace

[sudo] password for user: 
building Nix...
building the system configuration...
updating GRUB 2 menu...
lsblk: /dev/mapper/no*[0-9]: not a block device
lsblk: /dev/mapper/block*[0-9]: not a block device
lsblk: /dev/mapper/devices*[0-9]: not a block device
lsblk: /dev/mapper/found*[0-9]: not a block device
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu 20.04.1 LTS (20.04) on /dev/mapper/vgCrypt-rootubuntu
activating the configuration...
setting up /etc...
reloading user units for sddm...
reloading user units for ae...
setting up tmpfiles

but with su / root
nixos-rebuild switch --show-trace

error: executing 'git': No such file or directory
error: executing 'git': No such file or directory
error: while evaluating the attribute 'config' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:64:5:
while evaluating the attribute 'config' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:96:25:
while evaluating 'yieldConfig' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:83:29, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:82:16:
while evaluating 'mergeModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:233:26, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:73:17:
while evaluating 'mergeModules'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:237:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:234:5:
while evaluating 'flip' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:138:16, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:280:6:
while evaluating 'byName' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:260:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:268:21:
while evaluating 'reverseList' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:393:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:73:38:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:167:37, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:68:19:
while evaluating 'filterModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:157:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:168:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:161:31, called from undefined position:
while evaluating the attribute 'disabled' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:139:13:
while evaluating 'loadModule' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:106:53, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:144:22:
while evaluating 'isFunction' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:333:16, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:107:12:
program 'git' failed with exit code 1

what does sudo nix-shell -p nix-info --run “nix-info -m” say? root might be following an old channel

sorry,

builtins.fetchGit doesn’t install git if it is not yet installed
(I “hoped” it would do so or warn/error out that I would have to install it or change to tarball)

1 Like