Skip to content

Commit 9042ecc

Browse files
committed
add nix and nurl to runtime with env vars instead of wrapper
1 parent 506eb05 commit 9042ecc

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

flake.nix

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
installShellFiles
4545
libgit2_1_5
4646
libiconv
47-
makeBinaryWrapper
4847
mkShell
4948
nix
5049
nixpkgs-fmt
@@ -59,11 +58,11 @@
5958
inherit (nixpkgs.lib)
6059
concatMapAttrs
6160
flip
61+
getExe
6262
hasSuffix
6363
importTOML
6464
licenses
6565
maintainers
66-
makeBinPath
6766
nameValuePair
6867
optionalAttrs
6968
optionals
@@ -111,7 +110,6 @@
111110
nativeBuildInputs = [
112111
curl
113112
installShellFiles
114-
makeBinaryWrapper
115113
pkg-config
116114
];
117115

@@ -139,6 +137,8 @@
139137

140138
env = {
141139
GEN_ARTIFACTS = "artifacts";
140+
NIX = getExe nix;
141+
NURL = getExe nurl;
142142
ZSTD_SYS_USE_PKG_CONFIG = true;
143143
};
144144

@@ -194,8 +194,6 @@
194194
packages.default = buildPackage (args // {
195195
doCheck = false;
196196
postInstall = ''
197-
wrapProgram $out/bin/nix-init \
198-
--prefix PATH : ${makeBinPath [ nix nurl ]}
199197
installManPage artifacts/nix-init.1
200198
installShellCompletion artifacts/nix-init.{bash,fish} --zsh artifacts/_nix-init
201199
'';

src/cmd.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub const NIX: &str = match option_env!("NIX") {
2+
Some(nix) => nix,
3+
None => "nix",
4+
};
5+
6+
pub const NURL: &str = match option_env!("NURL") {
7+
Some(nurl) => nurl,
8+
None => "nurl",
9+
};

src/lang/rust/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std::{
2929
};
3030

3131
use crate::{
32+
cmd::NURL,
3233
inputs::AllInputs,
3334
lang::rust::deps::load_rust_dependency,
3435
prompt::{ask_overwrite, Prompter},
@@ -142,7 +143,7 @@ pub async fn write_cargo_lock(
142143
let hashes: BTreeMap<_, _> = revs
143144
.into_par_iter()
144145
.filter_map(|(rev, pkg)| {
145-
let hash = Command::new("nurl")
146+
let hash = Command::new(NURL)
146147
.arg(pkg.source_id().as_url().to_string())
147148
.arg(rev)
148149
.arg("-Hf")

src/main.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod build;
22
mod cfg;
33
mod cli;
4+
mod cmd;
45
mod fetcher;
56
mod inputs;
67
mod lang;
@@ -41,6 +42,7 @@ use crate::{
4142
build::{BuildType, PythonFormat, RustVendor},
4243
cfg::load_config,
4344
cli::Opts,
45+
cmd::{NIX, NURL},
4446
fetcher::{Fetcher, PackageInfo, PypiFormat, Revisions, Version},
4547
inputs::{write_all_lambda_inputs, write_inputs, write_lambda_input, AllInputs},
4648
lang::{
@@ -150,16 +152,11 @@ async fn run() -> Result<()> {
150152
}
151153
};
152154

153-
let mut fetcher = serde_json::from_slice(
154-
&Command::new("nurl")
155-
.arg(&url)
156-
.arg("-p")
157-
.get_stdout()
158-
.await?,
159-
)
160-
.context("failed to parse nurl output")?;
155+
let mut fetcher =
156+
serde_json::from_slice(&Command::new(NURL).arg(&url).arg("-p").get_stdout().await?)
157+
.context("failed to parse nurl output")?;
161158

162-
let mut cmd = Command::new("nurl");
159+
let mut cmd = Command::new(NURL);
163160
let mut licenses = BTreeMap::new();
164161
let mut pypi_format = PypiFormat::TarGz;
165162
let (pname, rev, version, desc, prefix, mut python_deps) =
@@ -348,7 +345,7 @@ async fn run() -> Result<()> {
348345
}
349346
};
350347

351-
let stdout = Command::new("nix")
348+
let stdout = Command::new(NIX)
352349
.arg("build")
353350
.arg("--extra-experimental-features")
354351
.arg("nix-command")

src/utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use tracing::{error, info, warn};
44

55
use std::{fmt::Display, future::Future, io::BufRead, pin::Pin, process::Output};
66

7+
use crate::cmd::NIX;
8+
79
pub const FAKE_HASH: &str = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
810

911
pub trait ResultExt {
@@ -67,7 +69,7 @@ fn into_stdout(output: Output) -> Result<Vec<u8>> {
6769
}
6870

6971
pub async fn fod_hash(expr: String) -> Option<String> {
70-
let mut cmd = Command::new("nix");
72+
let mut cmd = Command::new(NIX);
7173
cmd.arg("build")
7274
.arg("--extra-experimental-features")
7375
.arg("nix-command")

0 commit comments

Comments
 (0)