Skip to content

Commit be80a85

Browse files
committed
buildGoModule: use finalAttrs
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
1 parent 2905a6e commit be80a85

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ async fn run() -> Result<()> {
535535
}
536536

537537
let mut python_import = None;
538+
let mut close_parenthesis = false; // final ')', for example when using finalAttrs.
538539
let (native_build_inputs, build_inputs) = match choice {
539540
BuildType::BuildGoModule => {
540541
let go_sum = File::open(src_dir.join("go.sum")).ok_warn();
@@ -557,14 +558,18 @@ async fn run() -> Result<()> {
557558
};
558559

559560
let res = write_all_lambda_inputs(&mut out, &inputs, &mut BTreeSet::new())?;
561+
562+
let src_expr_final_attrs =src_expr.replace("${version}", "${finalAttrs.version}");
563+
564+
close_parenthesis = true;
560565
writedoc! {out, r#"
561566
}}:
562567
563-
buildGoModule rec {{
568+
buildGoModule (finalAttrs: {{
564569
pname = {pname:?};
565570
version = {version:?};
566571
567-
src = {src_expr};
572+
src = {src_expr_final_attrs};
568573
569574
vendorHash = {hash};
570575
@@ -1011,7 +1016,11 @@ async fn run() -> Result<()> {
10111016
}
10121017
}
10131018

1014-
writeln!(out, " }};\n}}")?;
1019+
write!(out, " }};\n}}")?;
1020+
if close_parenthesis {
1021+
write!(out, ")")?;
1022+
};
1023+
writeln!(out)?;
10151024

10161025
let mut out_file = File::create(&out_path).context("failed to create output file")?;
10171026
write!(out_file, "{out}")?;

0 commit comments

Comments
 (0)