Skip to content

Commit 8797747

Browse files
authored
stdenv: pURL review suggestions - move all logic to mkDerivation
1 parent 83b6d2e commit 8797747

5 files changed

Lines changed: 27 additions & 19 deletions

File tree

doc/release-notes/rl-2511.section.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176

177177
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
178178

179-
- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and derivations for Perl, Python, Ruby and Golang derivations have been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers of derivations using the adopted fetchers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. Maintainers using fetchurl for `drv.src` are urged to adopt their `drv.meta.identifiers.purlParts` for proper identification.
179+
- Metadata identifier purl (Package URL, https://github.com/package-url/purl-spec) has been added for fetchgit, fetchpypi and fetchFromGithub fetchers and mkDerivation has been adjusted to reuse these informations. Package URL's enables a reliable identification and locatization of software packages. Maintainers of derivations using the adopted fetchers should rely on the `drv.src.meta.identifiers.v1.purl` default identifier and can enhance their `drv.meta.identifiers.v1.purls` list once they would like to have additional identifiers. Maintainers using fetchurl for `drv.src` are urged to adopt their `drv.meta.identifiers.purlParts` for proper identification.
180180

181181
- Added `rewriteURL` attribute to the nixpkgs `config`, to allow for rewriting the URLs downloaded by `fetchurl`.
182182

pkgs/build-support/go/module.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,6 @@ lib.extendMkDerivation {
424424
meta = {
425425
# Add default meta information.
426426
platforms = go.meta.platforms or lib.platforms.all;
427-
identifiers = {
428-
${if (finalAttrs.src.meta.identifiers.purl or null) != null then "purl" else null} =
429-
finalAttrs.src.meta.identifiers.purl;
430-
${if (finalAttrs.src.meta.identifiers.purls or null) != null then "purls" else null} =
431-
finalAttrs.src.meta.identifiers.purls;
432-
};
433427
}
434428
// meta;
435429
};

pkgs/development/interpreters/python/mk-python-derivation.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,6 @@ let
416416
# default to python's platforms
417417
platforms = python.meta.platforms;
418418
isBuildPythonPackage = python.meta.platforms;
419-
identifiers = {
420-
${if (finalAttrs.src.meta.identifiers.purl or null) != null then "purl" else null} =
421-
finalAttrs.src.meta.identifiers.purl;
422-
${if (finalAttrs.src.meta.identifiers.purls or null) != null then "purls" else null} =
423-
finalAttrs.src.meta.identifiers.purls;
424-
};
425419
}
426420
// meta;
427421
}

pkgs/development/ruby-modules/gem/default.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ lib.makeOverridable (
307307
platforms = ruby.meta.platforms;
308308
mainProgram = gemName;
309309
}
310-
// (lib.optionalAttrs ((attrs.src.meta or { }) ? identifiers) {
311-
inherit (attrs.src.meta) identifiers;
312-
})
313310
// meta;
314311
}
315312
)

pkgs/stdenv/generic/check-meta.nix

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let
3434
toList
3535
isList
3636
elem
37+
flatten
3738
;
3839

3940
inherit (lib.meta)
@@ -711,12 +712,34 @@ let
711712
}
712713
) possibleCPEPartsFuns;
713714

715+
# search for a pURL in the following order:
716+
# - locally set
717+
# - src.meta.pURL
718+
# - srcs[].meta.pURL (for pURLs only)
714719
purlParts = attrs.meta.identifiers.purlParts or { };
715720
purl =
716-
attrs.meta.identifiers.purl or (
717-
if purlParts ? type && purlParts ? spec then "pkg:${purlParts.type}/${purlParts.spec}" else null
721+
if purlParts ? type && purlParts ? spec then
722+
"pkg:${purlParts.type}/${purlParts.spec}"
723+
else
724+
(attrs.src.meta.identifiers.purl or null);
725+
purls =
726+
attrs.meta.identifiers.purls or (
727+
if purl != null then
728+
[ purl ]
729+
else
730+
(attrs.src.meta.identifiers.purls or (
731+
# some of the srcs may not have a pURL
732+
builtins.filter (purl: purl != null) (
733+
map
734+
# get the pURLs from a single derivation
735+
(derivation: derivation.meta.identifiers.purls or null)
736+
737+
# sometimes srcs is a single derivation
738+
(flatten (attrs.srcs or [ ]))
739+
)
740+
)
741+
)
718742
);
719-
purls = attrs.meta.identifiers.purls or (optional (purl != null) purl);
720743

721744
v1 = {
722745
inherit

0 commit comments

Comments
 (0)