Skip to content

Commit 7b880ee

Browse files
figsodakatexochen
andcommitted
use finalAttrs instead of rec
Co-authored-by: Paul Meyer <[email protected]>
1 parent 2d7176e commit 7b880ee

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/fetcher/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub async fn get_package_info(
152152
pname: repo.into(),
153153
description,
154154
file_url_prefix: Some(format!(
155-
"https://{github_base}/{owner}/{repo}/blob/${{src.rev}}/",
155+
"https://{github_base}/{owner}/{repo}/blob/${{finalAttrs.src.rev}}/",
156156
)),
157157
license: Vec::new(),
158158
python_dependencies: Default::default(),

src/fetcher/gitlab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub async fn get_package_info(
141141
pname: repo.into(),
142142
description,
143143
file_url_prefix: Some(format!(
144-
"https://{domain}/{owner}/{repo}/-/blob/${{src.rev}}/",
144+
"https://{domain}/{owner}/{repo}/-/blob/${{finalAttrs.src.rev}}/",
145145
)),
146146
license: Vec::new(),
147147
python_dependencies: Default::default(),

src/lang/go/goreleaser.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ fn regex() -> Option<Regex> {
9292
fn parse_ldflags<'a>(re: &Regex, ldflags: &'a str) -> Cow<'a, str> {
9393
re.replace_all(ldflags, |caps: &Captures| match &caps[1] {
9494
// https://goreleaser.com/customization/templates
95-
".ProjectName" => "${pname}".into(),
96-
".Version" | ".RawVersion" => "${version}".into(),
95+
".ProjectName" => "${finalAttrs.pname}".into(),
96+
".Version" | ".RawVersion" => "${finalAttrs.version}".into(),
9797
".Branch" | ".PrefixedTag" | ".Tag" | ".ShortCommit" | ".FullCommit" | ".Commit" => {
98-
"${src.rev}".into()
98+
"${finalAttrs.src.rev}".into()
9999
}
100100
".IsGitDirty" => "false".into(),
101-
".Major" => "${lib.versions.major version}".into(),
102-
".Minor" => "${lib.versions.minor version}".into(),
103-
".Patch" => "${lib.versions.patch version}".into(),
101+
".Major" => "${lib.versions.major finalAttrs.version}".into(),
102+
".Minor" => "${lib.versions.minor finalAttrs.version}".into(),
103+
".Patch" => "${lib.versions.patch finalAttrs.version}".into(),
104104
".Date" | ".CommitDate" => "1970-01-01T00:00:00Z".into(),
105105
".Timestamp" | ".CommitTimestamp" => "0".into(),
106-
".Summary" | ".PrefixedSummary" => "${src.rev}".into(),
106+
".Summary" | ".PrefixedSummary" => "${finalAttrs.src.rev}".into(),
107107
x => format!("${{{}}}", x.to_lower_camel_case()),
108108
})
109109
}
@@ -118,14 +118,14 @@ mod tests {
118118
assert_eq!(parse_ldflags(&re, "-s -w"), "-s -w");
119119
assert_eq!(
120120
parse_ldflags(&re, "-X=main.Version={{ .Version }}"),
121-
"-X=main.Version=${version}",
121+
"-X=main.Version=${finalAttrs.version}",
122122
);
123123
assert_eq!(
124124
parse_ldflags(
125125
&re,
126126
"-s -w -X main.Version={{ .Version }} -X main.Tag={{ .Tag }}",
127127
),
128-
"-s -w -X main.Version=${version} -X main.Tag=${src.rev}",
128+
"-s -w -X main.Version=${finalAttrs.version} -X main.Tag=${finalAttrs.src.rev}",
129129
);
130130

131131
assert_eq!(

src/main.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ async fn run() -> Result<()> {
230230
if &pname == name {
231231
formatdoc! {r#"
232232
fetchCrate {{
233-
inherit pname version;
233+
inherit (finalAttrs) pname version;
234234
hash = "{hash}";
235235
}}"#,
236236
}
237237
} else {
238238
formatdoc! {r#"
239239
fetchCrate {{
240240
pname = {name:?};
241-
inherit version;
241+
inherit (finalAttrs) version;
242242
hash = "{hash}";
243243
}}"#,
244244
}
@@ -263,7 +263,7 @@ async fn run() -> Result<()> {
263263
.context("failed to parse nurl output")?;
264264
formatdoc! {r#"
265265
fetchPypi {{
266-
inherit pname version;
266+
inherit (finalAttrs) pname version;
267267
hash = "{hash}";{ext}
268268
}}"#,
269269
}
@@ -278,7 +278,7 @@ async fn run() -> Result<()> {
278278
formatdoc! {r#"
279279
fetchPypi {{
280280
pname = {name:?};
281-
inherit version;
281+
inherit (finalAttrs) version;
282282
hash = "{hash}";{ext}
283283
}}"#,
284284
}
@@ -291,7 +291,7 @@ async fn run() -> Result<()> {
291291
} else if rev.contains(&version) {
292292
cmd.arg("-O")
293293
.arg("rev")
294-
.arg(rev.replacen(&version, "${version}", 1));
294+
.arg(rev.replacen(&version, "${finalAttrs.version}", 1));
295295
}
296296

297297
String::from_utf8(
@@ -315,7 +315,7 @@ async fn run() -> Result<()> {
315315
.arg("--json")
316316
.arg("--expr")
317317
.arg(format!(
318-
"let pname={pname:?};version={version:?};in(import({nixpkgs}){{}}).{src_expr}",
318+
"let finalAttrs={{pname={pname:?};version={version:?};}};in(import({nixpkgs}){{}}).{src_expr}",
319319
))
320320
.get_stdout()
321321
.await?;
@@ -560,7 +560,7 @@ async fn run() -> Result<()> {
560560
writedoc! {out, r#"
561561
}}:
562562
563-
buildGoModule rec {{
563+
buildGoModule (finalAttrs: {{
564564
pname = {pname:?};
565565
version = {version:?};
566566
@@ -647,7 +647,7 @@ async fn run() -> Result<()> {
647647
writedoc! {out, r#"
648648
}}:
649649
650-
{} rec {{
650+
{} (finalAttrs: {{
651651
pname = {pname:?};
652652
version = {version:?};
653653
pyproject = true;
@@ -667,7 +667,7 @@ async fn run() -> Result<()> {
667667
write!(out, " ")?;
668668
writedoc! {out, r#"
669669
cargoDeps = rustPlatform.fetchCargoVendor {{
670-
inherit pname version src;
670+
inherit (finalAttrs) pname version src;
671671
hash = "{hash}";
672672
}};
673673
@@ -701,7 +701,7 @@ async fn run() -> Result<()> {
701701
writedoc! {out, r#"
702702
}}:
703703
704-
rustPlatform.buildRustPackage rec {{
704+
rustPlatform.buildRustPackage (finalAttrs: {{
705705
pname = {pname:?};
706706
version = {version:?};
707707
@@ -734,7 +734,7 @@ async fn run() -> Result<()> {
734734
writedoc! {out, r#"
735735
}}:
736736
737-
rustPlatform.buildRustPackage rec {{
737+
rustPlatform.buildRustPackage (finalAttrs: {{
738738
pname = "{pname}";
739739
version = "{version}";
740740
@@ -751,7 +751,7 @@ async fn run() -> Result<()> {
751751
writedoc! { out, r#"
752752
}}:
753753
754-
stdenv.mkDerivation rec {{
754+
stdenv.mkDerivation (finalAttrs: {{
755755
pname = {pname:?};
756756
version = {version:?};
757757
@@ -778,14 +778,14 @@ async fn run() -> Result<()> {
778778
writedoc! {out, r#"
779779
}}:
780780
781-
stdenv.mkDerivation rec {{
781+
stdenv.mkDerivation (finalAttrs: {{
782782
pname = {pname:?};
783783
version = {version:?};
784784
785785
src = {src_expr};
786786
787787
cargoDeps = rustPlatform.fetchCargoVendor {{
788-
inherit pname version src;
788+
inherit (finalAttrs) pname version src;
789789
hash = "{hash}";
790790
}};
791791
@@ -813,7 +813,7 @@ async fn run() -> Result<()> {
813813
writedoc! {out, r#"
814814
}}:
815815
816-
stdenv.mkDerivation rec {{
816+
stdenv.mkDerivation (finalAttrs: {{
817817
pname = "{pname}";
818818
version = "{version}";
819819
@@ -1027,7 +1027,7 @@ async fn run() -> Result<()> {
10271027
}
10281028
}
10291029

1030-
writeln!(out, " }};\n}}")?;
1030+
writeln!(out, " }};\n}})")?;
10311031

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

0 commit comments

Comments
 (0)