-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
top-level/packages-info: pre-evaluate output paths #487944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| pkgs ? import nixpkgs.outPath { }, | ||
| nix ? pkgs.nix, | ||
| lib-tests ? import ../../lib/tests/release.nix { inherit pkgs; }, | ||
| supportedSystems ? builtins.fromJSON (builtins.readFile ../../ci/supportedSystems.json), | ||
| }: | ||
|
|
||
| pkgs.releaseTools.sourceTarball { | ||
|
|
@@ -44,7 +45,12 @@ pkgs.releaseTools.sourceTarball { | |
| checkPhase = '' | ||
| echo "generating packages.json" | ||
|
|
||
| NIX_STATE_DIR=$TMPDIR NIX_PATH= nix-instantiate --eval --raw --expr "import $src/pkgs/top-level/packages-info.nix {}" | sed "s|$src/||g" | jq -c > packages.json | ||
| echo ' '''${builtins.toJSON supportedSystems}''' ' | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsafe escaping/quoting is a bit of a pet peve of mine. Especially when going through multiple "layers" of syntax/evaluation. Here we could use something like E.g. using Ideally we'd also avoid interpolating shell variables into the expression, using |
||
| NIX_STATE_DIR=$TMPDIR NIX_PATH= nix-instantiate \ | ||
| --eval --raw --arg-from-stdin supportedSystems \ | ||
| --expr "{ supportedSystems }: import $src/pkgs/top-level/packages-info.nix { supportedSystems = builtins.fromJSON supportedSystems; }" | | ||
| sed "s|$src/||g" | | ||
| jq -c > packages.json | ||
|
|
||
| # Arbitrary number. The index has ~115k packages as of April 2024. | ||
| if [ $(jq -r '.packages | length' < packages.json) -lt 100000 ]; then | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,29 @@ | ||||||||||||||||||
| { | ||||||||||||||||||
| trace ? false, | ||||||||||||||||||
| supportedSystems, | ||||||||||||||||||
| }: | ||||||||||||||||||
|
|
||||||||||||||||||
| let | ||||||||||||||||||
| pkgs = import ../.. { config = import ./packages-config.nix; }; | ||||||||||||||||||
| pkgsSystems = | ||||||||||||||||||
| if builtins.all (v: v != builtins.currentSystem) supportedSystems then | ||||||||||||||||||
| supportedSystems ++ [ builtins.currentSystem ] | ||||||||||||||||||
| else | ||||||||||||||||||
| supportedSystems; | ||||||||||||||||||
|
Comment on lines
+8
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this flow more readably if the if was flipped?
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| pkgsByArch = builtins.listToAttrs ( | ||||||||||||||||||
| map (system: { | ||||||||||||||||||
| name = system; | ||||||||||||||||||
| value = import ../.. { | ||||||||||||||||||
| inherit system; | ||||||||||||||||||
| config = import ./packages-config.nix; | ||||||||||||||||||
| }; | ||||||||||||||||||
| }) pkgsSystems | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| pkgs = pkgsByArch.${builtins.currentSystem}; | ||||||||||||||||||
|
|
||||||||||||||||||
| inherit (pkgs) lib; | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off-topic: a lot of this code could be simplified if we had access to a systemless instance of E.g. the above code is re-implementing |
||||||||||||||||||
|
|
||||||||||||||||||
| generateInfo = | ||||||||||||||||||
| path: value: | ||||||||||||||||||
| let | ||||||||||||||||||
|
|
@@ -23,10 +42,42 @@ let | |||||||||||||||||
| system | ||||||||||||||||||
| ; | ||||||||||||||||||
| ${if value ? "outputs" then "outputs" else null} = lib.listToAttrs ( | ||||||||||||||||||
| lib.map (x: { | ||||||||||||||||||
| name = x; | ||||||||||||||||||
| value = null; | ||||||||||||||||||
| }) value.outputs | ||||||||||||||||||
| lib.map ( | ||||||||||||||||||
| x: | ||||||||||||||||||
|
Comment on lines
+45
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, although pre-existing |
||||||||||||||||||
| let | ||||||||||||||||||
| platforms = lib.intersectLists (value.meta.hydraPlatforms | ||||||||||||||||||
| or (lib.subtractLists (value.meta.badPlatforms or [ ]) (value.meta.platforms or supportedSystems)) | ||||||||||||||||||
| ) supportedSystems; | ||||||||||||||||||
|
|
||||||||||||||||||
| outPaths = lib.listToAttrs ( | ||||||||||||||||||
| lib.map ( | ||||||||||||||||||
|
Comment on lines
+52
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be |
||||||||||||||||||
| platform: | ||||||||||||||||||
| let | ||||||||||||||||||
| drvForPlatform = | ||||||||||||||||||
| if lib.hasAttrByPath path pkgsByArch.${platform} then | ||||||||||||||||||
| lib.getAttrFromPath path pkgsByArch.${platform} | ||||||||||||||||||
| else | ||||||||||||||||||
| null; | ||||||||||||||||||
| outPath = | ||||||||||||||||||
| if builtins.isAttrs drvForPlatform && drvForPlatform ? ${x}.outPath then | ||||||||||||||||||
| builtins.unsafeDiscardStringContext drvForPlatform.${x}.outPath | ||||||||||||||||||
| else | ||||||||||||||||||
| null; | ||||||||||||||||||
| eval = builtins.tryEval outPath; | ||||||||||||||||||
| in | ||||||||||||||||||
| { | ||||||||||||||||||
| name = platform; | ||||||||||||||||||
| value = if eval.success then eval.value else null; | ||||||||||||||||||
| } | ||||||||||||||||||
| ) platforms | ||||||||||||||||||
| ); | ||||||||||||||||||
| in | ||||||||||||||||||
| { | ||||||||||||||||||
| name = x; | ||||||||||||||||||
| value = (builtins.tryEval outPaths).value or null; | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The If you want to return null for unsuccessful evals, you need to check
Suggested change
(You'd probably merge that let binding into your existing let block, of course.) |
||||||||||||||||||
| # value = null; | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the comment? |
||||||||||||||||||
| } | ||||||||||||||||||
| ) value.outputs | ||||||||||||||||||
| ); | ||||||||||||||||||
| # TODO: Remove the following two fallbacks when all packages have been fixed. | ||||||||||||||||||
| # Note: pname and version are *required* by repology, so do not change to | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,7 @@ let | |
| pkgs | ||
| nixpkgs | ||
| officialRelease | ||
| supportedSystems | ||
| ; | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of #492103 this has moved to
pkgs/top-level/release-supported-systems.json