utils/shell-wrapper: hardcode paths to the right sh/env executables (#459)

This commit is contained in:
K900
2024-04-26 14:31:44 +02:00
committed by GitHub
parent 4c8248d6aa
commit 4fb773cffe
2 changed files with 11 additions and 3 deletions
+6 -1
View File
@@ -1,8 +1,13 @@
{ rustPlatform }:
{ rustPlatform, bash, coreutils }:
rustPlatform.buildRustPackage {
pname = "nixos-wsl-utils";
version = "1.0.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
env = {
NIXOS_WSL_SH = "${bash}/bin/sh";
NIXOS_WSL_ENV = "${coreutils}/bin/env";
};
}
+5 -2
View File
@@ -19,8 +19,11 @@ fn real_main() -> anyhow::Result<()> {
// Skip if environment was already set
if env::var_os("__NIXOS_SET_ENVIRONMENT_DONE") != Some("1".into()) {
// Load the environment from /etc/set-environment
let output = Command::new("/bin/sh")
.args(&["-c", ". /etc/set-environment && /usr/bin/env -0"])
let output = Command::new(env!("NIXOS_WSL_SH"))
.args(&[
"-c",
&format!(". /etc/set-environment && {} -0", env!("NIXOS_WSL_ENV")),
])
.output()
.context("when reading /etc/set-environment")?;