You’re right, the proxy env vars are actually set on the nix-daemon directly instead of being forwarded by the client:
Typically with systemd it’s possible to override existing units but not on NixOS:
$ sudo systemctl edit nix-daemon
Failed to create temporary file for "/etc/systemd/system/nix-daemon.service.d/override.conf": Read-only file system
This is because
/etc/systemd/system points into the
/nix/store which is mounted read-only for everyone except the nix-daemon. You also can’t edit the unit itself because of the same reason.
Now I am running a bit out of ideas.
ESCAPE HATCH. DON’T PRESS THE RED BUTTON.
As a last recourse, you can re-mount the /nix/store read-write and edit the unit. This is obviously really bad as the store becomes no longer consistent.
$ sudo mount -o remount,rw /nix/store
# Look for the file and remove the lines:
$ sudo systemstd cat nix-daemon
$ sudo mount -o remount,ro /nix/store
$ sudo systemctl stop nix-daemon.socket nix-daemon
$ sudo systemctl start nix-daemon
Try running the nixos-rebuild. Since the nix-daemon is socket-actived it will only start after nix-build has been invoked. If it doesn’t work you can also check what environment variables the daemon has like that:
sudo cat /proc/$(pgrep nix-daemon)/environ | tr '\0' '\n'