@@ -94,6 +94,18 @@ in
9494
9595 };
9696
97+ environment.usrbinenv = mkOption {
98+ default = "${pkgs.coreutils}/bin/env";
99+ example = literalExample ''
100+ "''${pkgs.busybox}/bin/env"
101+ '';
102+ type = types.nullOr types.path;
103+ visible = false;
104+ description = ''
105+ The env(1) executable that is linked system-wide to
106+ <literal>/usr/bin/env</literal>.
107+ '';
108+ };
97109 };
98110
99111
@@ -128,11 +140,15 @@ in
128140 mkdir -m 0555 -p /var/empty
129141 '';
130142
131− system.activationScripts.usrbinenv =
132− ''
143+ system.activationScripts.usrbinenv = if config.environment.usrbinenv != null
144+ then ''
133145 mkdir -m 0755 -p /usr/bin
134− ln -sfn ${pkgs.coreutils}/bin/env /usr/bin/.env.tmp
146+ ln -sfn ${config.environment.usrbinenv} /usr/bin/.env.tmp
135147 mv /usr/bin/.env.tmp /usr/bin/env # atomically replace /usr/bin/env
148+ ''
149+ else ''
150+ rm -f /usr/bin/env
151+ rmdir --ignore-fail-on-non-empty /usr/bin /usr
136152 '';
137153
138154 system.activationScripts.tmpfs =