···37}
38```
3940-To use the local proxy in Go builds, you can set the proxy as environment variable:
4142```nix
43{
···47}
48```
4950-It is currently not possible to use the local proxy for builds done by the Nix daemon. This might be enabled
51-by experimental features, specifically [`configurable-impure-env`](https://nixos.org/manual/nix/unstable/contributing/experimental-features#xp-feature-configurable-impure-env),
52-in upcoming Nix versions.
000000000000000
···37}
38```
3940+To use the local proxy in Go builds (outside of `nix`), you can set the proxy as environment variable:
4142```nix
43{
···47}
48```
4950+To also use the local proxy for Go builds happening in `nix` (with `buildGoModule`), the nix daemon can be configured to pass the GOPROXY environment variable to the `goModules` fixed-output derivation.
51+52+This can either be done via the nix-daemon systemd unit:
53+54+```nix
55+{
56+ systemd.services.nix-daemon.environment.GOPROXY = "http://localhost:3000";
57+}
58+```
59+60+or via the [impure-env experimental feature](https://nix.dev/manual/nix/2.24/command-ref/conf-file#conf-impure-env):
61+62+```nix
63+{
64+ nix.settings.experimental-features = [ "configurable-impure-env" ];
65+ nix.settings.impure-env = "GOPROXY=http://localhost:3000";
66+}
67+```
+9-10
nixos/modules/system/boot/systemd/initrd.nix
···482483 # so NSS can look up usernames
484 "${pkgs.glibc}/lib/libnss_files.so.2"
000485 ] ++ optionals cfg.package.withCryptsetup [
486 # fido2 support
487 "${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
···522523 script = /* bash */ ''
524 set -uo pipefail
525- export PATH="/bin:${cfg.package.util-linux}/bin"
526527 # Figure out what closure to boot
528 closure=
···543544 # Resolve symlinks in the init parameter. We need this for some boot loaders
545 # (e.g. boot.loader.generationsDir).
546- closure="$(chroot /sysroot ${pkgs.coreutils}/bin/realpath "$closure")"
547548 # Assume the directory containing the init script is the closure.
549 closure="$(dirname "$closure")"
···578 ];
579580 services.initrd-nixos-activation = {
581- requires = [
582- config.boot.initrd.systemd.services.initrd-find-nixos-closure.name
583- ];
584- after = [
585- "initrd-fs.target"
586- config.boot.initrd.systemd.services.initrd-find-nixos-closure.name
587- ];
588- requiredBy = [ "initrd.target" ];
589 unitConfig = {
590 AssertPathExists = "/etc/initrd-release";
591 RequiresMountsFor = [
···482483 # so NSS can look up usernames
484 "${pkgs.glibc}/lib/libnss_files.so.2"
485+486+ # Resolving sysroot symlinks without code exec
487+ "${pkgs.chroot-realpath}/bin/chroot-realpath"
488 ] ++ optionals cfg.package.withCryptsetup [
489 # fido2 support
490 "${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
···525526 script = /* bash */ ''
527 set -uo pipefail
528+ export PATH="/bin:${cfg.package.util-linux}/bin:${pkgs.chroot-realpath}/bin"
529530 # Figure out what closure to boot
531 closure=
···546547 # Resolve symlinks in the init parameter. We need this for some boot loaders
548 # (e.g. boot.loader.generationsDir).
549+ closure="$(chroot-realpath /sysroot "$closure")"
550551 # Assume the directory containing the init script is the closure.
552 closure="$(dirname "$closure")"
···581 ];
582583 services.initrd-nixos-activation = {
584+ after = [ "initrd-switch-root.target" ];
585+ requiredBy = [ "initrd-switch-root.service" ];
586+ before = [ "initrd-switch-root.service" ];
587+ unitConfig.DefaultDependencies = false;
0000588 unitConfig = {
589 AssertPathExists = "/etc/initrd-release";
590 RequiresMountsFor = [
···1+# This file is automatically @generated by Cargo.
2+# It is not intended for manual editing.
3+version = 3
4+5+[[package]]
6+name = "chroot-realpath"
7+version = "0.1.0"