Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn fetch_block(fetcher: &Fetcher) -> (&'static str, &'static str) {
"fetchFromGitHub",
" @doc:fetcher@src = fetchFromGitHub {
owner = \"@owner@\";
repo = finalAttrs.pname;
repo = \"@pname@\";
rev = @rev@;
sha256 = \"@src_sha@\";
};",
Expand All @@ -49,7 +49,7 @@ fn fetch_block(fetcher: &Fetcher) -> (&'static str, &'static str) {
"fetchFromGitLab",
" @doc:fetcher@src = fetchFromGitLab {
owner = \"@owner@\";
repo = finalAttrs.pname;
repo = \"@pname@\";
rev = @rev@;
sha256 = \"@src_sha@\";
};",
Expand All @@ -59,7 +59,7 @@ fn fetch_block(fetcher: &Fetcher) -> (&'static str, &'static str) {
" @doc:fetcher@src = fetchFromGitea {
domain = \"@domain@\";
owner = \"@owner@\";
repo = finalAttrs.pname;
repo = \"@pname@\";
rev = @rev@;
sha256 = \"@src_sha@\";
};",
Expand All @@ -80,8 +80,9 @@ fn fetch_block(fetcher: &Fetcher) -> (&'static str, &'static str) {
),
Fetcher::pypi => (
"fetchPypi",
" @doc:fetcher@src = fetchPypi {
inherit (finalAttrs) pname version;
" @doc:fetcherPypi@src = fetchPypi {
pname = \"@pname@\";
inherit (finalAttrs) version;
sha256 = \"@src_sha@\";
};",
),
Expand Down Expand Up @@ -160,7 +161,8 @@ fn build_inputs(info: &ExpressionInfo) -> String {
];

pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pname = \"@pname@\";
inherit (finalAttrs) version src;
fetcherVersion = 3;
hash = \"@pnpm_deps_hash@\";
};".to_owned()
Expand Down
4 changes: 4 additions & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ lazy_static! {
"fetcher",
"https://nixos.org/nixpkgs/manual/#chap-pkgs-fetchers\n ",
);
m.insert(
"fetcherPypi",
"https://nixos.org/nixpkgs/manual/#chap-pkgs-fetchers\n # NOTE: fetchPypi is discouraged in nixpkgs; prefer fetching from the original source (GitHub, GitLab, etc.)\n ",
);
m.insert("meta", "https://nixos.org/nixpkgs/manual/#chap-meta\n ");
// Template-specific documentation
m.insert(
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ fn test_dotnet_template_basic() {
assert!(stdout.contains("buildDotnetModule (finalAttrs: {"));
assert!(stdout.contains("projectFile = \"CHANGE\";"));
assert!(stdout.contains("nugetDeps = ./deps.json;"));
assert!(stdout.contains("finalAttrs.pname"));
// pname should be a string literal, only version uses finalAttrs
assert!(stdout.contains("repo = \"example\";"));
assert!(stdout.contains("finalAttrs.version"));

// Verify proper spacing (blank lines between sections)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildDotnetModule (finalAttrs: {

src = fetchFromGitHub {
owner = "CHANGE";
repo = finalAttrs.pname;
repo = "example";
rev = finalAttrs.version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshots/integration_tests__npm_basic_template.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: tests/integration_tests.rs
assertion_line: 554
expression: stdout
---
{ lib
Expand All @@ -14,7 +13,7 @@ buildNpmPackage (finalAttrs: {

src = fetchFromGitHub {
owner = "CHANGE";
repo = finalAttrs.pname;
repo = "example";
rev = finalAttrs.version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};
Expand Down
6 changes: 3 additions & 3 deletions tests/snapshots/integration_tests__pnpm_basic_template.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: tests/integration_tests.rs
assertion_line: 584
expression: stdout
---
{ lib
Expand All @@ -18,7 +17,7 @@ stdenv.mkDerivation (finalAttrs: {

src = fetchFromGitHub {
owner = "CHANGE";
repo = finalAttrs.pname;
repo = "example";
rev = finalAttrs.version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};
Expand All @@ -30,7 +29,8 @@ stdenv.mkDerivation (finalAttrs: {
];

pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pname = "example";
inherit (finalAttrs) version src;
fetcherVersion = 3;
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/integration_tests__python_basic_template.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: tests/integration_tests.rs
assertion_line: 32
expression: stdout
---
{ lib
Expand All @@ -14,7 +13,8 @@ buildPythonPackage (finalAttrs: {
format = "setuptools";

src = fetchPypi {
inherit (finalAttrs) pname version;
pname = "requests";
inherit (finalAttrs) version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: tests/integration_tests.rs
assertion_line: 199
expression: package_nix
expression: stdout
---
{ lib
, buildPythonPackage
Expand All @@ -15,7 +14,7 @@ buildPythonPackage (finalAttrs: {

src = fetchFromGitHub {
owner = "CHANGE";
repo = finalAttrs.pname;
repo = "requests";
rev = finalAttrs.version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: tests/integration_tests.rs
assertion_line: 139
expression: package_nix
expression: stdout
---
{ lib
, buildPythonPackage
Expand All @@ -14,7 +13,8 @@ buildPythonPackage (finalAttrs: {
format = "setuptools";

src = fetchPypi {
inherit (finalAttrs) pname version;
pname = "requests";
inherit (finalAttrs) version;
sha256 = "0000000000000000000000000000000000000000000000000000";
};

Expand Down
Loading