8000 buildGoModule: use finalAttrs by katexochen · Pull Request #639 · nix-community/nix-init · GitHub
[go: up one dir, main page]

Skip to content
8000
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/main.rs
4862
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn run() -> Result<()> {
let version = match revisions.versions.remove(&rev) {
Some(version) => Some(version),
None => fetcher.get_version(&cl, &rev).await,
} ;
};
let version = match version {
Some(Version::Latest | Version::Tag) => get_version_number(&rev).into(),
Some(Version::Pypi {
Expand Down Expand Up @@ -535,6 +535,7 @@ async fn run() -> Result<()> {
}

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

let res = write_all_lambda_inputs(&mut out, &inputs, &mut BTreeSet::new())?;

let src_expr_final_attrs = src_expr.replace("${version}", "${finalAttrs.version}");

close_parenthesis = true;
writedoc! {out, r#"
}}:

buildGoModule rec {{
buildGoModule (finalAttrs: {{
pname = {pname:?};
version = {version:?};

src = {src_expr};
src = {src_expr_final_attrs};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changelog also mentions the version, so that needs to be changed as well


vendorHash = {hash};

Expand Down Expand Up @@ -1011,7 +1016,11 @@ async fn run() -> Result<()> {
}
}

writeln!(out, " }};\n}}")?;
write!(out, " }};\n}}")?;
if close_parenthesis {
write!(out, ")")?;
};
writeln!(out)?;

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