2017-12-25 17:38:45 +00:00
|
|
|
|
# Checks derivation meta and attrs for problems (like brokenness,
|
|
|
|
|
# licenses, etc).
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
check-env: don't execute check-meta.nix 15,000 times
Generated from https://github.com/NixOS/nix/pull/2761:
```
ns calls ns/call
- /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 591200 15026 39.3451
+ /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 8744 308 28.3896
```
more, generated by:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > before 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' before | sort > before.list
```
applying this patch, then:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > after 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' after | sort > after.list
```
and then diffing before.list and after.list to get:
```
calls
- :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 7513
+ :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 154
- onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 15026
+ onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 308
```
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|--------:|
| **cpuTime** | 179.915 | 145.543 | 🡖 34.372 | -19.10% |
| **envs-bytes** | 3,900,878,824 | 3,599,483,208 | 🡖 301,395,616 | -7.73% |
| **envs-elements** | 214,426,071 | 185,881,709 | 🡖 28,544,362 | -13.31% |
| **envs-number** | 136,591,891 | 132,026,846 | 🡖 4,565,045 | -3.34% |
| **gc-heapSize** | 11,400,048,640 | 12,314,890,240 | 🡕 914,841,600 | 8.02% |
| **gc-totalBytes** | 25,976,902,560 | 24,510,740,176 | 🡖 1,466,162,384 | -5.64% |
| **list-bytes** | 1,665,290,080 | 1,665,290,080 | 0 | |
| **list-concats** | 7,264,417 | 7,264,417 | 0 | |
| **list-elements** | 208,161,260 | 208,161,260 | 0 | |
| **nrAvoided** | 191,359,386 | 179,693,661 | 🡖 11,665,725 | -6.10% |
| **nrFunctionCalls** | 119,665,062 | 116,348,547 | 🡖 3,316,515 | -2.77% |
| **nrLookups** | 80,996,257 | 76,069,825 | 🡖 4,926,432 | -6.08% |
| **nrOpUpdateValuesCopied** | 213,930,649 | 213,930,649 | 0 | |
| **nrOpUpdates** | 12,025,937 | 12,025,937 | 0 | |
| **nrPrimOpCalls** | 88,105,604 | 86,451,598 | 🡖 1,654,006 | -1.88% |
| **nrThunks** | 196,842,044 | 175,126,701 | 🡖 21,715,343 | -11.03% |
| **sets-bytes** | 7,678,425,776 | 7,285,767,928 | 🡖 392,657,848 | -5.11% |
| **sets-elements** | 310,241,340 | 294,373,227 | 🡖 15,868,113 | -5.11% |
| **sets-number** | 29,079,202 | 27,601,310 | 🡖 1,477,892 | -5.08% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 16,474,666 | 16,474,676 | 🡕 10 | 0.00% |
| **symbols-number** | 376,426 | 376,427 | 🡕 1 | 0.00% |
| **values-bytes** | 6,856,506,288 | 6,316,585,560 | 🡖 539,920,728 | -7.87% |
| **values-number** | 285,687,762 | 263,191,065 | 🡖 22,496,697 | -7.87% |
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-instantiate ./nixos/release-combined.nix -A tested`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|-------:|
| **cpuTime** | 256.071 | 237.531 | 🡖 18.54 | -7.24% |
| **envs-bytes** | 7,111,004,192 | 7,041,478,520 | 🡖 69,525,672 | -0.98% |
| **envs-elements** | 346,236,940 | 339,588,487 | 🡖 6,648,453 | -1.92% |
| **envs-number** | 271,319,292 | 270,298,164 | 🡖 1,021,128 | -0.38% |
| **gc-heapSize** | 8,995,291,136 | 10,110,009,344 | 🡕 1,114,718,208 | 12.39% |
| **gc-totalBytes** | 37,172,737,408 | 36,878,391,888 | 🡖 294,345,520 | -0.79% |
| **list-bytes** | 1,886,162,656 | 1,886,163,472 | 🡕 816 | 0.00% |
| **list-concats** | 6,898,114 | 6,898,114 | 0 | |
| **list-elements** | 235,770,332 | 235,770,434 | 🡕 102 | 0.00% |
| **nrAvoided** | 328,829,821 | 326,618,157 | 🡖 2,211,664 | -0.67% |
| **nrFunctionCalls** | 240,850,845 | 239,998,495 | 🡖 852,350 | -0.35% |
| **nrLookups** | 144,849,632 | 142,126,339 | 🡖 2,723,293 | -1.88% |
| **nrOpUpdateValuesCopied** | 251,032,504 | 251,032,504 | 0 | |
| **nrOpUpdates** | 17,903,110 | 17,903,110 | 0 | |
| **nrPrimOpCalls** | 140,674,913 | 139,485,975 | 🡖 1,188,938 | -0.85% |
| **nrThunks** | 294,643,131 | 288,678,022 | 🡖 5,965,109 | -2.02% |
| **sets-bytes** | 9,464,322,192 | 9,456,172,048 | 🡖 8,150,144 | -0.09% |
| **sets-elements** | 377,474,889 | 377,134,877 | 🡖 340,012 | -0.09% |
| **sets-number** | 50,615,607 | 50,616,875 | 🡕 1,268 | 0.00% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 3,147,102 | 3,147,064 | 🡖 38 | -0.00% |
| **symbols-number** | 82,819 | 82,819 | 0 | |
| **values-bytes** | 11,147,448,768 | 10,996,111,512 | 🡖 151,337,256 | -1.36% |
| **values-number** | 464,477,032 | 458,171,313 | 🡖 6,305,719 | -1.36% |
2019-04-11 17:35:35 +01:00
|
|
|
|
{ lib, config, hostPlatform }:
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
let
|
2023-11-13 21:38:16 +00:00
|
|
|
|
inherit (lib)
|
|
|
|
|
all
|
|
|
|
|
attrNames
|
|
|
|
|
concatMapStrings
|
|
|
|
|
concatMapStringsSep
|
|
|
|
|
concatStrings
|
|
|
|
|
findFirst
|
2023-11-13 21:46:20 +00:00
|
|
|
|
isDerivation
|
2023-11-13 21:38:16 +00:00
|
|
|
|
length
|
2023-12-13 08:52:30 +00:00
|
|
|
|
concatMap
|
2023-11-13 21:38:16 +00:00
|
|
|
|
mutuallyExclusive
|
|
|
|
|
optional
|
|
|
|
|
optionalAttrs
|
|
|
|
|
optionalString
|
|
|
|
|
optionals
|
2023-11-24 22:56:52 +00:00
|
|
|
|
isAttrs
|
|
|
|
|
isString
|
2023-12-13 08:52:30 +00:00
|
|
|
|
mapAttrs
|
2023-11-13 21:38:16 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
inherit (lib.lists)
|
|
|
|
|
any
|
|
|
|
|
toList
|
2023-11-24 22:56:52 +00:00
|
|
|
|
isList
|
|
|
|
|
elem
|
2024-03-30 06:20:59 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
inherit (lib.meta)
|
|
|
|
|
availableOn
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
inherit (lib.generators)
|
|
|
|
|
toPretty
|
2023-11-13 21:38:16 +00:00
|
|
|
|
;
|
|
|
|
|
|
2018-12-18 15:50:53 +00:00
|
|
|
|
# If we're in hydra, we can dispense with the more verbose error
|
|
|
|
|
# messages and make problems easier to spot.
|
2024-08-05 17:44:45 +01:00
|
|
|
|
inHydra = config.inHydra or false;
|
2022-05-03 20:16:04 +01:00
|
|
|
|
# Allow the user to opt-into additional warnings, e.g.
|
|
|
|
|
# import <nixpkgs> { config = { showDerivationWarnings = [ "maintainerless" ]; }; }
|
|
|
|
|
showWarnings = config.showDerivationWarnings;
|
|
|
|
|
|
2024-08-05 17:44:45 +01:00
|
|
|
|
getNameWithVersion = attrs: attrs.name or ("${attrs.pname or "«name-missing»"}-${attrs.version or "«version-missing»"}");
|
2018-12-18 15:50:53 +00:00
|
|
|
|
|
2022-05-02 13:49:04 +01:00
|
|
|
|
allowUnfree = config.allowUnfree
|
2019-11-04 01:38:35 +00:00
|
|
|
|
|| builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-09-28 23:18:33 +01:00
|
|
|
|
allowNonSource = let
|
|
|
|
|
envVar = builtins.getEnv "NIXPKGS_ALLOW_NONSOURCE";
|
|
|
|
|
in if envVar != ""
|
|
|
|
|
then envVar != "0"
|
2024-08-05 17:44:45 +01:00
|
|
|
|
else config.allowNonSource or true;
|
2022-02-20 19:23:12 +00:00
|
|
|
|
|
2021-02-23 15:25:18 +00:00
|
|
|
|
allowlist = config.allowlistedLicenses or config.whitelistedLicenses or [];
|
|
|
|
|
blocklist = config.blocklistedLicenses or config.blacklistedLicenses or [];
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
areLicenseListsValid =
|
2023-11-13 21:38:16 +00:00
|
|
|
|
if mutuallyExclusive allowlist blocklist then
|
2022-02-17 12:09:23 +00:00
|
|
|
|
true
|
2017-07-02 12:52:14 +01:00
|
|
|
|
else
|
2021-02-23 15:25:18 +00:00
|
|
|
|
throw "allowlistedLicenses and blocklistedLicenses are not mutually exclusive.";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
hasLicense = attrs:
|
|
|
|
|
attrs ? meta.license;
|
|
|
|
|
|
2023-11-24 22:56:52 +00:00
|
|
|
|
hasListedLicense = assert areLicenseListsValid; list: attrs:
|
|
|
|
|
length list > 0 && hasLicense attrs && (
|
|
|
|
|
if isList attrs.meta.license then any (l: elem l list) attrs.meta.license
|
|
|
|
|
else elem attrs.meta.license list
|
|
|
|
|
);
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2023-11-24 22:56:52 +00:00
|
|
|
|
hasAllowlistedLicense = attrs: hasListedLicense allowlist attrs;
|
|
|
|
|
|
|
|
|
|
hasBlocklistedLicense = attrs: hasListedLicense blocklist attrs;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-05-02 15:20:44 +01:00
|
|
|
|
allowBroken = config.allowBroken
|
2019-11-04 01:38:35 +00:00
|
|
|
|
|| builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-05-02 18:39:43 +01:00
|
|
|
|
allowUnsupportedSystem = config.allowUnsupportedSystem
|
2019-11-04 01:38:35 +00:00
|
|
|
|
|| builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1";
|
2017-05-20 17:44:20 +01:00
|
|
|
|
|
2023-11-24 22:56:52 +00:00
|
|
|
|
isUnfree = licenses:
|
|
|
|
|
if isAttrs licenses then !licenses.free or true
|
|
|
|
|
# TODO: Returning false in the case of a string is a bug that should be fixed.
|
|
|
|
|
# In a previous implementation of this function the function body
|
|
|
|
|
# was `licenses: lib.lists.any (l: !l.free or true) licenses;`
|
|
|
|
|
# which always evaluates to `!true` for strings.
|
|
|
|
|
else if isString licenses then false
|
2024-03-30 06:20:59 +00:00
|
|
|
|
else any (l: !l.free or true) licenses;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2023-11-24 22:56:52 +00:00
|
|
|
|
hasUnfreeLicense = attrs: hasLicense attrs && isUnfree attrs.meta.license;
|
2020-04-19 11:04:58 +01:00
|
|
|
|
|
2022-05-03 20:17:44 +01:00
|
|
|
|
hasNoMaintainers = attrs:
|
2023-11-13 21:38:16 +00:00
|
|
|
|
attrs ? meta.maintainers && (length attrs.meta.maintainers) == 0;
|
2022-05-03 20:17:44 +01:00
|
|
|
|
|
2020-04-19 11:04:58 +01:00
|
|
|
|
isMarkedBroken = attrs: attrs.meta.broken or false;
|
|
|
|
|
|
2022-10-09 23:26:14 +01:00
|
|
|
|
hasUnsupportedPlatform =
|
2024-03-30 06:20:59 +00:00
|
|
|
|
pkg: !(availableOn hostPlatform pkg);
|
2020-04-19 11:04:58 +01:00
|
|
|
|
|
|
|
|
|
isMarkedInsecure = attrs: (attrs.meta.knownVulnerabilities or []) != [];
|
|
|
|
|
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# Alow granular checks to allow only some unfree packages
|
|
|
|
|
# Example:
|
|
|
|
|
# {pkgs, ...}:
|
|
|
|
|
# {
|
|
|
|
|
# allowUnfree = false;
|
2021-02-07 22:05:25 +00:00
|
|
|
|
# allowUnfreePredicate = (x: pkgs.lib.hasPrefix "vscode" x.name);
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# }
|
2024-08-05 17:44:45 +01:00
|
|
|
|
allowUnfreePredicate = config.allowUnfreePredicate or (x: false);
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
# Check whether unfree packages are allowed and if not, whether the
|
2022-12-18 00:39:44 +00:00
|
|
|
|
# package has an unfree license and is not explicitly allowed by the
|
2018-09-23 17:45:03 +01:00
|
|
|
|
# `allowUnfreePredicate` function.
|
2017-07-02 12:52:14 +01:00
|
|
|
|
hasDeniedUnfreeLicense = attrs:
|
2020-04-19 11:04:58 +01:00
|
|
|
|
hasUnfreeLicense attrs &&
|
2017-07-02 12:52:14 +01:00
|
|
|
|
!allowUnfree &&
|
|
|
|
|
!allowUnfreePredicate attrs;
|
|
|
|
|
|
2024-08-05 17:44:45 +01:00
|
|
|
|
allowInsecureDefaultPredicate = x: builtins.elem (getNameWithVersion x) (config.permittedInsecurePackages or []);
|
2017-12-09 20:36:48 +00:00
|
|
|
|
allowInsecurePredicate = x: (config.allowInsecurePredicate or allowInsecureDefaultPredicate) x;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
hasAllowedInsecure = attrs:
|
2020-04-19 11:04:58 +01:00
|
|
|
|
!(isMarkedInsecure attrs) ||
|
2017-07-02 12:52:14 +01:00
|
|
|
|
allowInsecurePredicate attrs ||
|
2019-11-04 01:38:35 +00:00
|
|
|
|
builtins.getEnv "NIXPKGS_ALLOW_INSECURE" == "1";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-02-20 19:23:12 +00:00
|
|
|
|
|
2023-11-13 21:38:16 +00:00
|
|
|
|
isNonSource = sourceTypes: any (t: !t.isSource) sourceTypes;
|
2022-02-20 19:23:12 +00:00
|
|
|
|
|
|
|
|
|
hasNonSourceProvenance = attrs:
|
2022-05-20 20:17:02 +01:00
|
|
|
|
(attrs ? meta.sourceProvenance) &&
|
2022-05-30 18:11:09 +01:00
|
|
|
|
isNonSource attrs.meta.sourceProvenance;
|
2022-02-20 19:23:12 +00:00
|
|
|
|
|
|
|
|
|
# Allow granular checks to allow only some non-source-built packages
|
|
|
|
|
# Example:
|
2022-06-02 00:38:57 +01:00
|
|
|
|
# { pkgs, ... }:
|
2022-02-20 19:23:12 +00:00
|
|
|
|
# {
|
|
|
|
|
# allowNonSource = false;
|
2022-05-30 18:11:09 +01:00
|
|
|
|
# allowNonSourcePredicate = with pkgs.lib.lists; pkg: !(any (p: !p.isSource && p != lib.sourceTypes.binaryFirmware) pkg.meta.sourceProvenance);
|
2022-02-20 19:23:12 +00:00
|
|
|
|
# }
|
2024-08-05 17:44:45 +01:00
|
|
|
|
allowNonSourcePredicate = config.allowNonSourcePredicate or (x: false);
|
2022-02-20 19:23:12 +00:00
|
|
|
|
|
|
|
|
|
# Check whether non-source packages are allowed and if not, whether the
|
|
|
|
|
# package has non-source provenance and is not explicitly allowed by the
|
|
|
|
|
# `allowNonSourcePredicate` function.
|
|
|
|
|
hasDeniedNonSourceProvenance = attrs:
|
|
|
|
|
hasNonSourceProvenance attrs &&
|
|
|
|
|
!allowNonSource &&
|
|
|
|
|
!allowNonSourcePredicate attrs;
|
|
|
|
|
|
2023-11-13 21:38:16 +00:00
|
|
|
|
showLicenseOrSourceType = value: toString (map (v: v.shortName or "unknown") (toList value));
|
2022-02-20 19:23:12 +00:00
|
|
|
|
showLicense = showLicenseOrSourceType;
|
|
|
|
|
showSourceType = showLicenseOrSourceType;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
check-env: don't execute check-meta.nix 15,000 times
Generated from https://github.com/NixOS/nix/pull/2761:
```
ns calls ns/call
- /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 591200 15026 39.3451
+ /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 8744 308 28.3896
```
more, generated by:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > before 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' before | sort > before.list
```
applying this patch, then:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > after 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' after | sort > after.list
```
and then diffing before.list and after.list to get:
```
calls
- :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 7513
+ :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 154
- onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 15026
+ onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 308
```
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|--------:|
| **cpuTime** | 179.915 | 145.543 | 🡖 34.372 | -19.10% |
| **envs-bytes** | 3,900,878,824 | 3,599,483,208 | 🡖 301,395,616 | -7.73% |
| **envs-elements** | 214,426,071 | 185,881,709 | 🡖 28,544,362 | -13.31% |
| **envs-number** | 136,591,891 | 132,026,846 | 🡖 4,565,045 | -3.34% |
| **gc-heapSize** | 11,400,048,640 | 12,314,890,240 | 🡕 914,841,600 | 8.02% |
| **gc-totalBytes** | 25,976,902,560 | 24,510,740,176 | 🡖 1,466,162,384 | -5.64% |
| **list-bytes** | 1,665,290,080 | 1,665,290,080 | 0 | |
| **list-concats** | 7,264,417 | 7,264,417 | 0 | |
| **list-elements** | 208,161,260 | 208,161,260 | 0 | |
| **nrAvoided** | 191,359,386 | 179,693,661 | 🡖 11,665,725 | -6.10% |
| **nrFunctionCalls** | 119,665,062 | 116,348,547 | 🡖 3,316,515 | -2.77% |
| **nrLookups** | 80,996,257 | 76,069,825 | 🡖 4,926,432 | -6.08% |
| **nrOpUpdateValuesCopied** | 213,930,649 | 213,930,649 | 0 | |
| **nrOpUpdates** | 12,025,937 | 12,025,937 | 0 | |
| **nrPrimOpCalls** | 88,105,604 | 86,451,598 | 🡖 1,654,006 | -1.88% |
| **nrThunks** | 196,842,044 | 175,126,701 | 🡖 21,715,343 | -11.03% |
| **sets-bytes** | 7,678,425,776 | 7,285,767,928 | 🡖 392,657,848 | -5.11% |
| **sets-elements** | 310,241,340 | 294,373,227 | 🡖 15,868,113 | -5.11% |
| **sets-number** | 29,079,202 | 27,601,310 | 🡖 1,477,892 | -5.08% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 16,474,666 | 16,474,676 | 🡕 10 | 0.00% |
| **symbols-number** | 376,426 | 376,427 | 🡕 1 | 0.00% |
| **values-bytes** | 6,856,506,288 | 6,316,585,560 | 🡖 539,920,728 | -7.87% |
| **values-number** | 285,687,762 | 263,191,065 | 🡖 22,496,697 | -7.87% |
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-instantiate ./nixos/release-combined.nix -A tested`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|-------:|
| **cpuTime** | 256.071 | 237.531 | 🡖 18.54 | -7.24% |
| **envs-bytes** | 7,111,004,192 | 7,041,478,520 | 🡖 69,525,672 | -0.98% |
| **envs-elements** | 346,236,940 | 339,588,487 | 🡖 6,648,453 | -1.92% |
| **envs-number** | 271,319,292 | 270,298,164 | 🡖 1,021,128 | -0.38% |
| **gc-heapSize** | 8,995,291,136 | 10,110,009,344 | 🡕 1,114,718,208 | 12.39% |
| **gc-totalBytes** | 37,172,737,408 | 36,878,391,888 | 🡖 294,345,520 | -0.79% |
| **list-bytes** | 1,886,162,656 | 1,886,163,472 | 🡕 816 | 0.00% |
| **list-concats** | 6,898,114 | 6,898,114 | 0 | |
| **list-elements** | 235,770,332 | 235,770,434 | 🡕 102 | 0.00% |
| **nrAvoided** | 328,829,821 | 326,618,157 | 🡖 2,211,664 | -0.67% |
| **nrFunctionCalls** | 240,850,845 | 239,998,495 | 🡖 852,350 | -0.35% |
| **nrLookups** | 144,849,632 | 142,126,339 | 🡖 2,723,293 | -1.88% |
| **nrOpUpdateValuesCopied** | 251,032,504 | 251,032,504 | 0 | |
| **nrOpUpdates** | 17,903,110 | 17,903,110 | 0 | |
| **nrPrimOpCalls** | 140,674,913 | 139,485,975 | 🡖 1,188,938 | -0.85% |
| **nrThunks** | 294,643,131 | 288,678,022 | 🡖 5,965,109 | -2.02% |
| **sets-bytes** | 9,464,322,192 | 9,456,172,048 | 🡖 8,150,144 | -0.09% |
| **sets-elements** | 377,474,889 | 377,134,877 | 🡖 340,012 | -0.09% |
| **sets-number** | 50,615,607 | 50,616,875 | 🡕 1,268 | 0.00% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 3,147,102 | 3,147,064 | 🡖 38 | -0.00% |
| **symbols-number** | 82,819 | 82,819 | 0 | |
| **values-bytes** | 11,147,448,768 | 10,996,111,512 | 🡖 151,337,256 | -1.36% |
| **values-number** | 464,477,032 | 458,171,313 | 🡖 6,305,719 | -1.36% |
2019-04-11 17:35:35 +01:00
|
|
|
|
pos_str = meta: meta.position or "«unknown-file»";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
remediation = {
|
2022-02-20 19:23:12 +00:00
|
|
|
|
unfree = remediate_allowlist "Unfree" (remediate_predicate "allowUnfreePredicate");
|
|
|
|
|
non-source = remediate_allowlist "NonSource" (remediate_predicate "allowNonSourcePredicate");
|
2021-02-23 15:25:18 +00:00
|
|
|
|
broken = remediate_allowlist "Broken" (x: "");
|
|
|
|
|
unsupported = remediate_allowlist "UnsupportedSystem" (x: "");
|
|
|
|
|
blocklisted = x: "";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
insecure = remediate_insecure;
|
2018-09-18 14:30:59 +01:00
|
|
|
|
broken-outputs = remediateOutputsToInstall;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
unknown-meta = x: "";
|
2022-05-03 20:17:44 +01:00
|
|
|
|
maintainerless = x: "";
|
2017-07-02 12:52:14 +01:00
|
|
|
|
};
|
2020-10-27 09:01:32 +00:00
|
|
|
|
remediation_env_var = allow_attr: {
|
|
|
|
|
Unfree = "NIXPKGS_ALLOW_UNFREE";
|
|
|
|
|
Broken = "NIXPKGS_ALLOW_BROKEN";
|
|
|
|
|
UnsupportedSystem = "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM";
|
2022-02-20 19:23:12 +00:00
|
|
|
|
NonSource = "NIXPKGS_ALLOW_NONSOURCE";
|
2020-10-27 09:01:32 +00:00
|
|
|
|
}.${allow_attr};
|
|
|
|
|
remediation_phrase = allow_attr: {
|
|
|
|
|
Unfree = "unfree packages";
|
|
|
|
|
Broken = "broken packages";
|
|
|
|
|
UnsupportedSystem = "packages that are unsupported for this system";
|
2022-02-20 19:23:12 +00:00
|
|
|
|
NonSource = "packages not built from source";
|
2020-10-27 09:01:32 +00:00
|
|
|
|
}.${allow_attr};
|
2022-02-20 19:23:12 +00:00
|
|
|
|
remediate_predicate = predicateConfigAttr: attrs:
|
2020-06-05 20:39:08 +01:00
|
|
|
|
''
|
|
|
|
|
|
2021-02-23 15:25:18 +00:00
|
|
|
|
Alternatively you can configure a predicate to allow specific packages:
|
2022-02-20 19:23:12 +00:00
|
|
|
|
{ nixpkgs.config.${predicateConfigAttr} = pkg: builtins.elem (lib.getName pkg) [
|
2024-04-10 16:15:24 +01:00
|
|
|
|
"${lib.getName attrs}"
|
2020-06-05 20:39:08 +01:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
|
2021-11-13 04:47:23 +00:00
|
|
|
|
# flakeNote will be printed in the remediation messages below.
|
|
|
|
|
flakeNote = "
|
2023-10-31 11:37:14 +00:00
|
|
|
|
Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
|
|
|
|
|
then pass `--impure` in order to allow use of environment variables.
|
2021-11-13 04:47:23 +00:00
|
|
|
|
";
|
|
|
|
|
|
2021-02-23 15:25:18 +00:00
|
|
|
|
remediate_allowlist = allow_attr: rebuild_amendment: attrs:
|
2017-07-02 12:52:14 +01:00
|
|
|
|
''
|
2020-10-27 09:01:32 +00:00
|
|
|
|
a) To temporarily allow ${remediation_phrase allow_attr}, you can use an environment variable
|
|
|
|
|
for a single invocation of the nix tools.
|
|
|
|
|
|
|
|
|
|
$ export ${remediation_env_var allow_attr}=1
|
2021-11-13 04:47:23 +00:00
|
|
|
|
${flakeNote}
|
2020-10-27 09:01:32 +00:00
|
|
|
|
b) For `nixos-rebuild` you can set
|
2017-07-02 12:52:14 +01:00
|
|
|
|
{ nixpkgs.config.allow${allow_attr} = true; }
|
|
|
|
|
in configuration.nix to override this.
|
2020-06-05 20:39:08 +01:00
|
|
|
|
${rebuild_amendment attrs}
|
2020-10-27 09:01:32 +00:00
|
|
|
|
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
|
2017-07-02 12:52:14 +01:00
|
|
|
|
{ allow${allow_attr} = true; }
|
|
|
|
|
to ~/.config/nixpkgs/config.nix.
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
remediate_insecure = attrs:
|
|
|
|
|
''
|
|
|
|
|
|
|
|
|
|
Known issues:
|
2023-11-13 21:38:16 +00:00
|
|
|
|
'' + (concatStrings (map (issue: " - ${issue}\n") attrs.meta.knownVulnerabilities)) + ''
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2021-02-23 15:25:18 +00:00
|
|
|
|
You can install it anyway by allowing this package, using the
|
2017-07-02 12:52:14 +01:00
|
|
|
|
following methods:
|
2020-06-11 03:25:07 +01:00
|
|
|
|
|
|
|
|
|
a) To temporarily allow all insecure packages, you can use an environment
|
|
|
|
|
variable for a single invocation of the nix tools:
|
|
|
|
|
|
|
|
|
|
$ export NIXPKGS_ALLOW_INSECURE=1
|
2021-11-13 04:47:23 +00:00
|
|
|
|
${flakeNote}
|
2024-06-22 10:16:10 +01:00
|
|
|
|
b) for `nixos-rebuild` you can add ‘${getNameWithVersion attrs}’ to
|
2017-07-02 12:52:14 +01:00
|
|
|
|
`nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
|
|
|
|
|
like so:
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
nixpkgs.config.permittedInsecurePackages = [
|
2024-06-22 10:16:10 +01:00
|
|
|
|
"${getNameWithVersion attrs}"
|
2017-07-02 12:52:14 +01:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 09:16:31 +01:00
|
|
|
|
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
|
2024-06-22 10:16:10 +01:00
|
|
|
|
‘${getNameWithVersion attrs}’ to `permittedInsecurePackages` in
|
2020-06-11 03:25:07 +01:00
|
|
|
|
~/.config/nixpkgs/config.nix, like so:
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
permittedInsecurePackages = [
|
2024-06-22 10:16:10 +01:00
|
|
|
|
"${getNameWithVersion attrs}"
|
2017-07-02 12:52:14 +01:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
|
2018-09-18 14:30:59 +01:00
|
|
|
|
remediateOutputsToInstall = attrs: let
|
|
|
|
|
expectedOutputs = attrs.meta.outputsToInstall or [];
|
|
|
|
|
actualOutputs = attrs.outputs or [ "out" ];
|
|
|
|
|
missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs;
|
|
|
|
|
in ''
|
2024-06-22 10:16:10 +01:00
|
|
|
|
The package ${getNameWithVersion attrs} has set meta.outputsToInstall to: ${builtins.concatStringsSep ", " expectedOutputs}
|
2018-09-18 14:30:59 +01:00
|
|
|
|
|
2024-06-22 10:16:10 +01:00
|
|
|
|
however ${getNameWithVersion attrs} only has the outputs: ${builtins.concatStringsSep ", " actualOutputs}
|
2018-09-18 14:30:59 +01:00
|
|
|
|
|
|
|
|
|
and is missing the following ouputs:
|
|
|
|
|
|
2023-11-13 21:38:16 +00:00
|
|
|
|
${concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)}
|
2018-09-18 14:30:59 +01:00
|
|
|
|
'';
|
|
|
|
|
|
check-env: don't execute check-meta.nix 15,000 times
Generated from https://github.com/NixOS/nix/pull/2761:
```
ns calls ns/call
- /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 591200 15026 39.3451
+ /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 8744 308 28.3896
```
more, generated by:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > before 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' before | sort > before.list
```
applying this patch, then:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > after 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' after | sort > after.list
```
and then diffing before.list and after.list to get:
```
calls
- :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 7513
+ :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 154
- onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 15026
+ onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 308
```
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|--------:|
| **cpuTime** | 179.915 | 145.543 | 🡖 34.372 | -19.10% |
| **envs-bytes** | 3,900,878,824 | 3,599,483,208 | 🡖 301,395,616 | -7.73% |
| **envs-elements** | 214,426,071 | 185,881,709 | 🡖 28,544,362 | -13.31% |
| **envs-number** | 136,591,891 | 132,026,846 | 🡖 4,565,045 | -3.34% |
| **gc-heapSize** | 11,400,048,640 | 12,314,890,240 | 🡕 914,841,600 | 8.02% |
| **gc-totalBytes** | 25,976,902,560 | 24,510,740,176 | 🡖 1,466,162,384 | -5.64% |
| **list-bytes** | 1,665,290,080 | 1,665,290,080 | 0 | |
| **list-concats** | 7,264,417 | 7,264,417 | 0 | |
| **list-elements** | 208,161,260 | 208,161,260 | 0 | |
| **nrAvoided** | 191,359,386 | 179,693,661 | 🡖 11,665,725 | -6.10% |
| **nrFunctionCalls** | 119,665,062 | 116,348,547 | 🡖 3,316,515 | -2.77% |
| **nrLookups** | 80,996,257 | 76,069,825 | 🡖 4,926,432 | -6.08% |
| **nrOpUpdateValuesCopied** | 213,930,649 | 213,930,649 | 0 | |
| **nrOpUpdates** | 12,025,937 | 12,025,937 | 0 | |
| **nrPrimOpCalls** | 88,105,604 | 86,451,598 | 🡖 1,654,006 | -1.88% |
| **nrThunks** | 196,842,044 | 175,126,701 | 🡖 21,715,343 | -11.03% |
| **sets-bytes** | 7,678,425,776 | 7,285,767,928 | 🡖 392,657,848 | -5.11% |
| **sets-elements** | 310,241,340 | 294,373,227 | 🡖 15,868,113 | -5.11% |
| **sets-number** | 29,079,202 | 27,601,310 | 🡖 1,477,892 | -5.08% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 16,474,666 | 16,474,676 | 🡕 10 | 0.00% |
| **symbols-number** | 376,426 | 376,427 | 🡕 1 | 0.00% |
| **values-bytes** | 6,856,506,288 | 6,316,585,560 | 🡖 539,920,728 | -7.87% |
| **values-number** | 285,687,762 | 263,191,065 | 🡖 22,496,697 | -7.87% |
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-instantiate ./nixos/release-combined.nix -A tested`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|-------:|
| **cpuTime** | 256.071 | 237.531 | 🡖 18.54 | -7.24% |
| **envs-bytes** | 7,111,004,192 | 7,041,478,520 | 🡖 69,525,672 | -0.98% |
| **envs-elements** | 346,236,940 | 339,588,487 | 🡖 6,648,453 | -1.92% |
| **envs-number** | 271,319,292 | 270,298,164 | 🡖 1,021,128 | -0.38% |
| **gc-heapSize** | 8,995,291,136 | 10,110,009,344 | 🡕 1,114,718,208 | 12.39% |
| **gc-totalBytes** | 37,172,737,408 | 36,878,391,888 | 🡖 294,345,520 | -0.79% |
| **list-bytes** | 1,886,162,656 | 1,886,163,472 | 🡕 816 | 0.00% |
| **list-concats** | 6,898,114 | 6,898,114 | 0 | |
| **list-elements** | 235,770,332 | 235,770,434 | 🡕 102 | 0.00% |
| **nrAvoided** | 328,829,821 | 326,618,157 | 🡖 2,211,664 | -0.67% |
| **nrFunctionCalls** | 240,850,845 | 239,998,495 | 🡖 852,350 | -0.35% |
| **nrLookups** | 144,849,632 | 142,126,339 | 🡖 2,723,293 | -1.88% |
| **nrOpUpdateValuesCopied** | 251,032,504 | 251,032,504 | 0 | |
| **nrOpUpdates** | 17,903,110 | 17,903,110 | 0 | |
| **nrPrimOpCalls** | 140,674,913 | 139,485,975 | 🡖 1,188,938 | -0.85% |
| **nrThunks** | 294,643,131 | 288,678,022 | 🡖 5,965,109 | -2.02% |
| **sets-bytes** | 9,464,322,192 | 9,456,172,048 | 🡖 8,150,144 | -0.09% |
| **sets-elements** | 377,474,889 | 377,134,877 | 🡖 340,012 | -0.09% |
| **sets-number** | 50,615,607 | 50,616,875 | 🡕 1,268 | 0.00% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 3,147,102 | 3,147,064 | 🡖 38 | -0.00% |
| **symbols-number** | 82,819 | 82,819 | 0 | |
| **values-bytes** | 11,147,448,768 | 10,996,111,512 | 🡖 151,337,256 | -1.36% |
| **values-number** | 464,477,032 | 458,171,313 | 🡖 6,305,719 | -1.36% |
2019-04-11 17:35:35 +01:00
|
|
|
|
handleEvalIssue = { meta, attrs }: { reason , errormsg ? "" }:
|
2017-12-12 23:06:55 +00:00
|
|
|
|
let
|
2018-12-18 15:50:53 +00:00
|
|
|
|
msg = if inHydra
|
2024-06-22 10:16:10 +01:00
|
|
|
|
then "Failed to evaluate ${getNameWithVersion attrs}: «${reason}»: ${errormsg}"
|
2018-12-18 15:50:53 +00:00
|
|
|
|
else ''
|
2024-06-22 10:16:10 +01:00
|
|
|
|
Package ‘${getNameWithVersion attrs}’ in ${pos_str meta} ${errormsg}, refusing to evaluate.
|
2017-12-12 23:06:55 +00:00
|
|
|
|
|
2018-12-18 15:50:53 +00:00
|
|
|
|
'' + (builtins.getAttr reason remediation) attrs;
|
2017-12-12 23:06:55 +00:00
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
|
handler = if config ? handleEvalIssue
|
2017-12-12 23:06:55 +00:00
|
|
|
|
then config.handleEvalIssue reason
|
|
|
|
|
else throw;
|
|
|
|
|
in handler msg;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-05-03 20:16:04 +01:00
|
|
|
|
handleEvalWarning = { meta, attrs }: { reason , errormsg ? "" }:
|
|
|
|
|
let
|
|
|
|
|
remediationMsg = (builtins.getAttr reason remediation) attrs;
|
2024-06-22 10:16:10 +01:00
|
|
|
|
msg = if inHydra then "Warning while evaluating ${getNameWithVersion attrs}: «${reason}»: ${errormsg}"
|
|
|
|
|
else "Package ${getNameWithVersion attrs} in ${pos_str meta} ${errormsg}, continuing anyway."
|
2023-11-13 21:38:16 +00:00
|
|
|
|
+ (optionalString (remediationMsg != "") "\n${remediationMsg}");
|
|
|
|
|
isEnabled = findFirst (x: x == reason) null showWarnings;
|
2022-05-03 20:16:04 +01:00
|
|
|
|
in if isEnabled != null then builtins.trace msg true else true;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2023-11-13 21:46:20 +00:00
|
|
|
|
metaTypes = let
|
2023-12-13 08:52:30 +00:00
|
|
|
|
types = import ./meta-types.nix { inherit lib; };
|
|
|
|
|
inherit (types) str union int attrs attrsOf any listOf bool;
|
|
|
|
|
platforms = listOf (union [ str (attrsOf any) ]); # see lib.meta.platformMatch
|
2023-11-13 21:49:27 +00:00
|
|
|
|
in {
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# These keys are documented
|
|
|
|
|
description = str;
|
2021-04-26 05:19:49 +01:00
|
|
|
|
mainProgram = str;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
longDescription = str;
|
|
|
|
|
branch = str;
|
2023-12-13 08:52:30 +00:00
|
|
|
|
homepage = union [
|
|
|
|
|
(listOf str)
|
|
|
|
|
str
|
|
|
|
|
];
|
2017-07-02 12:52:14 +01:00
|
|
|
|
downloadPage = str;
|
2023-12-13 08:52:30 +00:00
|
|
|
|
changelog = union [
|
|
|
|
|
(listOf str)
|
|
|
|
|
str
|
|
|
|
|
];
|
2022-12-18 11:42:43 +00:00
|
|
|
|
license = let
|
2023-12-13 08:52:30 +00:00
|
|
|
|
# TODO disallow `str` licenses, use a module
|
|
|
|
|
licenseType = union [
|
|
|
|
|
(attrsOf any)
|
|
|
|
|
str
|
|
|
|
|
];
|
|
|
|
|
in union [
|
|
|
|
|
(listOf licenseType)
|
|
|
|
|
licenseType
|
|
|
|
|
];
|
|
|
|
|
sourceProvenance = listOf attrs;
|
|
|
|
|
maintainers = listOf (attrsOf any); # TODO use the maintainer type from lib/tests/maintainer-module.nix
|
2017-07-02 12:52:14 +01:00
|
|
|
|
priority = int;
|
2023-02-03 04:49:15 +00:00
|
|
|
|
pkgConfigModules = listOf str;
|
2023-11-13 21:49:27 +00:00
|
|
|
|
inherit platforms;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
hydraPlatforms = listOf str;
|
|
|
|
|
broken = bool;
|
2020-04-19 11:04:58 +01:00
|
|
|
|
unfree = bool;
|
|
|
|
|
unsupported = bool;
|
|
|
|
|
insecure = bool;
|
2023-12-13 08:52:30 +00:00
|
|
|
|
tests = {
|
dovecot, opensmtpd: add link to test in `meta.tests`
Rationale
---------
Currently, tests are hard to discover. For instance, someone updating
`dovecot` might not notice that the interaction of `dovecot` with
`opensmtpd` is handled in the `opensmtpd.nix` test.
And even for someone updating `opensmtpd`, it requires manual work to go
check in `nixos/tests` whether there is actually a test, especially
given not so many packages in `nixpkgs` have tests and this is thus most
of the time useless.
Finally, for the reviewer, it is much easier to check that the “Tested
via one or more NixOS test(s)” has been checked if the file modified
already includes the list of relevant tests.
Implementation
--------------
Currently, this commit only adds the metadata in the package. Each
element of the `meta.tests` attribute is a derivation that, when it
builds successfully, means the test has passed (ie. following the same
convention as NixOS tests).
Future Work
-----------
In the future, the tools could be made aware of this `meta.tests`
attribute, and for instance a `--with-tests` could be added to
`nix-build` so that it also builds all the tests. Or a `--without-tests`
to build without all the tests. @Profpatsch described in his NixCon talk
such systems.
Another thing that would help in the future would be the possibility to
reasonably easily have cross-derivation nix tests without the whole
NixOS VM stack. @7c6f434c already proposed such a system.
This RFC currently handles none of these concerns. Only the addition of
`meta.tests` as metadata to be used by maintainers to remember to run
relevant tests.
2018-08-04 04:18:28 +01:00
|
|
|
|
name = "test";
|
2023-12-13 08:52:30 +00:00
|
|
|
|
verify = x: x == {} || ( # Accept {} for tests that are unsupported
|
2018-11-11 11:30:07 +00:00
|
|
|
|
isDerivation x &&
|
2018-11-11 13:47:49 +00:00
|
|
|
|
x ? meta.timeout
|
2018-11-11 11:30:07 +00:00
|
|
|
|
);
|
2023-12-13 08:52:30 +00:00
|
|
|
|
};
|
dovecot, opensmtpd: add link to test in `meta.tests`
Rationale
---------
Currently, tests are hard to discover. For instance, someone updating
`dovecot` might not notice that the interaction of `dovecot` with
`opensmtpd` is handled in the `opensmtpd.nix` test.
And even for someone updating `opensmtpd`, it requires manual work to go
check in `nixos/tests` whether there is actually a test, especially
given not so many packages in `nixpkgs` have tests and this is thus most
of the time useless.
Finally, for the reviewer, it is much easier to check that the “Tested
via one or more NixOS test(s)” has been checked if the file modified
already includes the list of relevant tests.
Implementation
--------------
Currently, this commit only adds the metadata in the package. Each
element of the `meta.tests` attribute is a derivation that, when it
builds successfully, means the test has passed (ie. following the same
convention as NixOS tests).
Future Work
-----------
In the future, the tools could be made aware of this `meta.tests`
attribute, and for instance a `--with-tests` could be added to
`nix-build` so that it also builds all the tests. Or a `--without-tests`
to build without all the tests. @Profpatsch described in his NixCon talk
such systems.
Another thing that would help in the future would be the possibility to
reasonably easily have cross-derivation nix tests without the whole
NixOS VM stack. @7c6f434c already proposed such a system.
This RFC currently handles none of these concerns. Only the addition of
`meta.tests` as metadata to be used by maintainers to remember to run
relevant tests.
2018-08-04 04:18:28 +01:00
|
|
|
|
timeout = int;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2022-09-28 11:15:24 +01:00
|
|
|
|
# Needed for Hydra to expose channel tarballs:
|
|
|
|
|
# https://github.com/NixOS/hydra/blob/53335323ae79ca1a42643f58e520b376898ce641/doc/manual/src/jobs.md#meta-fields
|
|
|
|
|
isHydraChannel = bool;
|
|
|
|
|
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# Weirder stuff that doesn't appear in the documentation?
|
2021-08-07 00:15:04 +01:00
|
|
|
|
maxSilent = int;
|
2017-12-14 12:36:26 +00:00
|
|
|
|
knownVulnerabilities = listOf str;
|
2018-01-03 15:22:35 +00:00
|
|
|
|
name = str;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
version = str;
|
|
|
|
|
tag = str;
|
|
|
|
|
executables = listOf str;
|
|
|
|
|
outputsToInstall = listOf str;
|
|
|
|
|
position = str;
|
2023-12-13 08:52:30 +00:00
|
|
|
|
available = any;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
isBuildPythonPackage = platforms;
|
2018-01-09 13:25:24 +00:00
|
|
|
|
schedulingPriority = int;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
isFcitxEngine = bool;
|
|
|
|
|
isIbusEngine = bool;
|
2017-12-05 11:57:11 +00:00
|
|
|
|
isGutenprint = bool;
|
2018-03-27 13:12:14 +01:00
|
|
|
|
badPlatforms = platforms;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
};
|
|
|
|
|
|
2023-12-13 08:52:30 +00:00
|
|
|
|
checkMetaAttr = let
|
|
|
|
|
# Map attrs directly to the verify function for performance
|
|
|
|
|
metaTypes' = mapAttrs (_: t: t.verify) metaTypes;
|
|
|
|
|
in k: v:
|
2017-07-02 12:52:14 +01:00
|
|
|
|
if metaTypes?${k} then
|
2023-12-13 08:52:30 +00:00
|
|
|
|
if metaTypes'.${k} v then
|
|
|
|
|
[ ]
|
2022-09-14 11:17:39 +01:00
|
|
|
|
else
|
2023-12-13 08:52:30 +00:00
|
|
|
|
[ "key 'meta.${k}' has invalid value; expected ${metaTypes.${k}.name}, got\n ${
|
2024-03-30 06:20:59 +00:00
|
|
|
|
toPretty { indent = " "; } v
|
2023-12-13 08:52:30 +00:00
|
|
|
|
}" ]
|
2022-09-14 11:17:39 +01:00
|
|
|
|
else
|
2023-12-13 08:52:30 +00:00
|
|
|
|
[ "key 'meta.${k}' is unrecognized; expected one of: \n [${concatMapStringsSep ", " (x: "'${x}'") (attrNames metaTypes)}]" ];
|
|
|
|
|
checkMeta = meta: optionals config.checkMeta (concatMap (attr: checkMetaAttr attr meta.${attr}) (attrNames meta));
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2018-09-18 14:30:59 +01:00
|
|
|
|
checkOutputsToInstall = attrs: let
|
|
|
|
|
expectedOutputs = attrs.meta.outputsToInstall or [];
|
|
|
|
|
actualOutputs = attrs.outputs or [ "out" ];
|
|
|
|
|
missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs;
|
2022-09-14 11:17:39 +01:00
|
|
|
|
in if config.checkMeta
|
2018-09-18 14:30:59 +01:00
|
|
|
|
then builtins.length missingOutputs > 0
|
|
|
|
|
else false;
|
|
|
|
|
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# Check if a derivation is valid, that is whether it passes checks for
|
|
|
|
|
# e.g brokenness or license.
|
|
|
|
|
#
|
2022-12-18 11:42:43 +00:00
|
|
|
|
# Return { valid: "yes", "warn" or "no" } and additionally
|
2017-07-02 12:52:14 +01:00
|
|
|
|
# { reason: String; errormsg: String } if it is not valid, where
|
2021-02-23 15:25:18 +00:00
|
|
|
|
# reason is one of "unfree", "blocklisted", "broken", "insecure", ...
|
2022-12-18 11:42:43 +00:00
|
|
|
|
# !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync
|
2020-04-19 11:04:58 +01:00
|
|
|
|
# Along with a boolean flag for each reason
|
2024-03-20 03:48:12 +00:00
|
|
|
|
checkValidity =
|
|
|
|
|
let
|
|
|
|
|
validYes = {
|
|
|
|
|
valid = "yes";
|
|
|
|
|
handled = true;
|
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
attrs:
|
2022-12-18 11:42:43 +00:00
|
|
|
|
# Check meta attribute types first, to make sure it is always called even when there are other issues
|
|
|
|
|
# Note that this is not a full type check and functions below still need to by careful about their inputs!
|
2024-03-20 03:48:12 +00:00
|
|
|
|
let
|
|
|
|
|
res = checkMeta (attrs.meta or {});
|
|
|
|
|
in
|
|
|
|
|
if res != [] then
|
|
|
|
|
{ valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${concatMapStrings (x: "\n - " + x) res}\n"; }
|
|
|
|
|
|
2022-09-14 11:17:39 +01:00
|
|
|
|
# --- Put checks that cannot be ignored here ---
|
2024-03-20 03:48:12 +00:00
|
|
|
|
else if checkOutputsToInstall attrs then
|
2022-09-14 11:17:39 +01:00
|
|
|
|
{ valid = "no"; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
|
|
|
|
|
|
|
|
|
|
# --- Put checks that can be ignored here ---
|
|
|
|
|
else if hasDeniedUnfreeLicense attrs && !(hasAllowlistedLicense attrs) then
|
2022-05-03 20:12:34 +01:00
|
|
|
|
{ valid = "no"; reason = "unfree"; errormsg = "has an unfree license (‘${showLicense attrs.meta.license}’)"; }
|
2021-02-23 15:25:18 +00:00
|
|
|
|
else if hasBlocklistedLicense attrs then
|
2022-05-03 20:12:34 +01:00
|
|
|
|
{ valid = "no"; reason = "blocklisted"; errormsg = "has a blocklisted license (‘${showLicense attrs.meta.license}’)"; }
|
2022-02-20 19:23:12 +00:00
|
|
|
|
else if hasDeniedNonSourceProvenance attrs then
|
|
|
|
|
{ valid = "no"; reason = "non-source"; errormsg = "contains elements not built from source (‘${showSourceType attrs.meta.sourceProvenance}’)"; }
|
2017-07-02 12:52:14 +01:00
|
|
|
|
else if !allowBroken && attrs.meta.broken or false then
|
2022-05-03 20:12:34 +01:00
|
|
|
|
{ valid = "no"; reason = "broken"; errormsg = "is marked as broken"; }
|
2020-04-19 11:04:58 +01:00
|
|
|
|
else if !allowUnsupportedSystem && hasUnsupportedPlatform attrs then
|
2024-03-30 11:30:20 +00:00
|
|
|
|
let toPretty' = toPretty {
|
2023-03-24 07:15:57 +00:00
|
|
|
|
allowPrettyValues = true;
|
|
|
|
|
indent = " ";
|
|
|
|
|
};
|
|
|
|
|
in { valid = "no"; reason = "unsupported";
|
|
|
|
|
errormsg = ''
|
|
|
|
|
is not available on the requested hostPlatform:
|
|
|
|
|
hostPlatform.config = "${hostPlatform.config}"
|
2024-03-30 11:30:20 +00:00
|
|
|
|
package.meta.platforms = ${toPretty' (attrs.meta.platforms or [])}
|
|
|
|
|
package.meta.badPlatforms = ${toPretty' (attrs.meta.badPlatforms or [])}
|
2023-03-24 07:15:57 +00:00
|
|
|
|
'';
|
|
|
|
|
}
|
2017-07-02 12:52:14 +01:00
|
|
|
|
else if !(hasAllowedInsecure attrs) then
|
2022-05-03 20:12:34 +01:00
|
|
|
|
{ valid = "no"; reason = "insecure"; errormsg = "is marked as insecure"; }
|
2022-09-14 11:17:39 +01:00
|
|
|
|
|
2022-05-03 20:17:44 +01:00
|
|
|
|
# --- warnings ---
|
|
|
|
|
# Please also update the type in /pkgs/top-level/config.nix alongside this.
|
|
|
|
|
else if hasNoMaintainers attrs then
|
|
|
|
|
{ valid = "warn"; reason = "maintainerless"; errormsg = "has no maintainers"; }
|
|
|
|
|
# -----
|
2024-03-20 03:48:12 +00:00
|
|
|
|
else validYes;
|
2017-07-02 12:52:14 +01:00
|
|
|
|
|
2023-04-26 04:43:44 +01:00
|
|
|
|
|
|
|
|
|
# The meta attribute is passed in the resulting attribute set,
|
|
|
|
|
# but it's not part of the actual derivation, i.e., it's not
|
|
|
|
|
# passed to the builder and is not a dependency. But since we
|
|
|
|
|
# include it in the result, it *is* available to nix-env for queries.
|
|
|
|
|
# Example:
|
|
|
|
|
# meta = checkMeta.commonMeta { inherit validity attrs pos references; };
|
|
|
|
|
# validity = checkMeta.assertValidity { inherit meta attrs; };
|
|
|
|
|
commonMeta = { validity, attrs, pos ? null, references ? [ ] }:
|
|
|
|
|
let
|
|
|
|
|
outputs = attrs.outputs or [ "out" ];
|
2024-03-20 00:35:51 +00:00
|
|
|
|
hasOutput = out: builtins.elem out outputs;
|
2023-04-26 04:43:44 +01:00
|
|
|
|
in
|
2024-03-30 14:19:21 +00:00
|
|
|
|
{
|
2023-04-26 04:43:44 +01:00
|
|
|
|
# `name` derivation attribute includes cross-compilation cruft,
|
|
|
|
|
# is under assert, and is sanitized.
|
|
|
|
|
# Let's have a clean always accessible version here.
|
|
|
|
|
name = attrs.name or "${attrs.pname}-${attrs.version}";
|
|
|
|
|
|
|
|
|
|
# If the packager hasn't specified `outputsToInstall`, choose a default,
|
|
|
|
|
# which is the name of `p.bin or p.out or p` along with `p.man` when
|
|
|
|
|
# present.
|
|
|
|
|
#
|
|
|
|
|
# If the packager has specified it, it will be overridden below in
|
|
|
|
|
# `// meta`.
|
|
|
|
|
#
|
|
|
|
|
# Note: This default probably shouldn't be globally configurable.
|
|
|
|
|
# Services and users should specify outputs explicitly,
|
|
|
|
|
# unless they are comfortable with this default.
|
|
|
|
|
outputsToInstall =
|
2024-03-20 00:35:51 +00:00
|
|
|
|
[
|
|
|
|
|
(
|
|
|
|
|
if hasOutput "bin" then "bin"
|
|
|
|
|
else if hasOutput "out" then "out"
|
|
|
|
|
else findFirst hasOutput null outputs
|
|
|
|
|
)
|
|
|
|
|
]
|
2023-11-13 21:38:16 +00:00
|
|
|
|
++ optional (hasOutput "man") "man";
|
2023-04-26 04:43:44 +01:00
|
|
|
|
}
|
|
|
|
|
// attrs.meta or { }
|
|
|
|
|
# Fill `meta.position` to identify the source location of the package.
|
2023-11-13 21:38:16 +00:00
|
|
|
|
// optionalAttrs (pos != null) {
|
2023-04-26 04:43:44 +01:00
|
|
|
|
position = pos.file + ":" + toString pos.line;
|
|
|
|
|
} // {
|
|
|
|
|
# Expose the result of the checks for everyone to see.
|
2024-03-20 03:48:12 +00:00
|
|
|
|
unfree = hasUnfreeLicense attrs;
|
|
|
|
|
broken = isMarkedBroken attrs;
|
|
|
|
|
unsupported = hasUnsupportedPlatform attrs;
|
|
|
|
|
insecure = isMarkedInsecure attrs;
|
2023-04-26 04:43:44 +01:00
|
|
|
|
|
|
|
|
|
available = validity.valid != "no"
|
|
|
|
|
&& (if config.checkMetaRecursively or false
|
2023-11-13 21:38:16 +00:00
|
|
|
|
then all (d: d.meta.available or true) references
|
2023-04-26 04:43:44 +01:00
|
|
|
|
else true);
|
|
|
|
|
};
|
|
|
|
|
|
check-env: don't execute check-meta.nix 15,000 times
Generated from https://github.com/NixOS/nix/pull/2761:
```
ns calls ns/call
- /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 591200 15026 39.3451
+ /home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:22:5 8744 308 28.3896
```
more, generated by:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > before 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' before | sort > before.list
```
applying this patch, then:
```
$ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 nix-instantiate ./pkgs/top-level/release.nix -A unstable > after 2>&1
$ jq -r '.functions | map((.name + ":" + .file + ":" + (.line|tostring) + ":" + (.column|tostring) + " " + (.count|tostring))) | .[]' after | sort > after.list
```
and then diffing before.list and after.list to get:
```
calls
- :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 7513
+ :/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:4:1 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:23 154
- mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 7513
+ mutuallyExclusive:/home/grahamc/projects/github.com/NixOS/nixpkgs/lib/lists.nix:658:26 154
- onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 15026
+ onlyLicenses:/home/grahamc/projects/github.com/NixOS/nixpkgs/pkgs/stdenv/generic/check-meta.nix:21:18 308
```
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|--------:|
| **cpuTime** | 179.915 | 145.543 | 🡖 34.372 | -19.10% |
| **envs-bytes** | 3,900,878,824 | 3,599,483,208 | 🡖 301,395,616 | -7.73% |
| **envs-elements** | 214,426,071 | 185,881,709 | 🡖 28,544,362 | -13.31% |
| **envs-number** | 136,591,891 | 132,026,846 | 🡖 4,565,045 | -3.34% |
| **gc-heapSize** | 11,400,048,640 | 12,314,890,240 | 🡕 914,841,600 | 8.02% |
| **gc-totalBytes** | 25,976,902,560 | 24,510,740,176 | 🡖 1,466,162,384 | -5.64% |
| **list-bytes** | 1,665,290,080 | 1,665,290,080 | 0 | |
| **list-concats** | 7,264,417 | 7,264,417 | 0 | |
| **list-elements** | 208,161,260 | 208,161,260 | 0 | |
| **nrAvoided** | 191,359,386 | 179,693,661 | 🡖 11,665,725 | -6.10% |
| **nrFunctionCalls** | 119,665,062 | 116,348,547 | 🡖 3,316,515 | -2.77% |
| **nrLookups** | 80,996,257 | 76,069,825 | 🡖 4,926,432 | -6.08% |
| **nrOpUpdateValuesCopied** | 213,930,649 | 213,930,649 | 0 | |
| **nrOpUpdates** | 12,025,937 | 12,025,937 | 0 | |
| **nrPrimOpCalls** | 88,105,604 | 86,451,598 | 🡖 1,654,006 | -1.88% |
| **nrThunks** | 196,842,044 | 175,126,701 | 🡖 21,715,343 | -11.03% |
| **sets-bytes** | 7,678,425,776 | 7,285,767,928 | 🡖 392,657,848 | -5.11% |
| **sets-elements** | 310,241,340 | 294,373,227 | 🡖 15,868,113 | -5.11% |
| **sets-number** | 29,079,202 | 27,601,310 | 🡖 1,477,892 | -5.08% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 16,474,666 | 16,474,676 | 🡕 10 | 0.00% |
| **symbols-number** | 376,426 | 376,427 | 🡕 1 | 0.00% |
| **values-bytes** | 6,856,506,288 | 6,316,585,560 | 🡖 539,920,728 | -7.87% |
| **values-number** | 285,687,762 | 263,191,065 | 🡖 22,496,697 | -7.87% |
The following information is from `NIX_SHOW_STATS=1 GC_INITIAL_HEAP_SIZE=4g nix-instantiate ./nixos/release-combined.nix -A tested`:
| stat | before | after | Δ | Δ% |
|:---------------------------|---------------:|---------------:|:----------------|-------:|
| **cpuTime** | 256.071 | 237.531 | 🡖 18.54 | -7.24% |
| **envs-bytes** | 7,111,004,192 | 7,041,478,520 | 🡖 69,525,672 | -0.98% |
| **envs-elements** | 346,236,940 | 339,588,487 | 🡖 6,648,453 | -1.92% |
| **envs-number** | 271,319,292 | 270,298,164 | 🡖 1,021,128 | -0.38% |
| **gc-heapSize** | 8,995,291,136 | 10,110,009,344 | 🡕 1,114,718,208 | 12.39% |
| **gc-totalBytes** | 37,172,737,408 | 36,878,391,888 | 🡖 294,345,520 | -0.79% |
| **list-bytes** | 1,886,162,656 | 1,886,163,472 | 🡕 816 | 0.00% |
| **list-concats** | 6,898,114 | 6,898,114 | 0 | |
| **list-elements** | 235,770,332 | 235,770,434 | 🡕 102 | 0.00% |
| **nrAvoided** | 328,829,821 | 326,618,157 | 🡖 2,211,664 | -0.67% |
| **nrFunctionCalls** | 240,850,845 | 239,998,495 | 🡖 852,350 | -0.35% |
| **nrLookups** | 144,849,632 | 142,126,339 | 🡖 2,723,293 | -1.88% |
| **nrOpUpdateValuesCopied** | 251,032,504 | 251,032,504 | 0 | |
| **nrOpUpdates** | 17,903,110 | 17,903,110 | 0 | |
| **nrPrimOpCalls** | 140,674,913 | 139,485,975 | 🡖 1,188,938 | -0.85% |
| **nrThunks** | 294,643,131 | 288,678,022 | 🡖 5,965,109 | -2.02% |
| **sets-bytes** | 9,464,322,192 | 9,456,172,048 | 🡖 8,150,144 | -0.09% |
| **sets-elements** | 377,474,889 | 377,134,877 | 🡖 340,012 | -0.09% |
| **sets-number** | 50,615,607 | 50,616,875 | 🡕 1,268 | 0.00% |
| **sizes-Attr** | 24 | 24 | 0 | |
| **sizes-Bindings** | 8 | 8 | 0 | |
| **sizes-Env** | 16 | 16 | 0 | |
| **sizes-Value** | 24 | 24 | 0 | |
| **symbols-bytes** | 3,147,102 | 3,147,064 | 🡖 38 | -0.00% |
| **symbols-number** | 82,819 | 82,819 | 0 | |
| **values-bytes** | 11,147,448,768 | 10,996,111,512 | 🡖 151,337,256 | -1.36% |
| **values-number** | 464,477,032 | 458,171,313 | 🡖 6,305,719 | -1.36% |
2019-04-11 17:35:35 +01:00
|
|
|
|
assertValidity = { meta, attrs }: let
|
2018-01-31 03:10:34 +00:00
|
|
|
|
validity = checkValidity attrs;
|
stdenv: Avoid allocating intermediate attrset when checking meta validity
This is a small performance optimization. It should be impercetible to most.
Benchmarks:
- Before
``` json
{
"cpuTime": 0.2777960002422333,
"envs": {
"bytes": 3832648,
"elements": 189513,
"number": 144784
},
"gc": {
"heapSize": 402915328,
"totalBytes": 50229344
},
"list": {
"bytes": 655304,
"concats": 3249,
"elements": 81913
},
"nrAvoided": 218962,
"nrFunctionCalls": 127718,
"nrLookups": 40946,
"nrOpUpdateValuesCopied": 1563978,
"nrOpUpdates": 8542,
"nrPrimOpCalls": 113032,
"nrThunks": 329605,
"sets": {
"bytes": 29774864,
"elements": 1824537,
"number": 36392
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 235909,
"number": 24432
},
"values": {
"bytes": 9691392,
"number": 403808
}
}
```
- After
```
{
"cpuTime": 0.2615779936313629,
"envs": {
"bytes": 3833832,
"elements": 189661,
"number": 144784
},
"gc": {
"heapSize": 402915328,
"totalBytes": 50212960
},
"list": {
"bytes": 655304,
"concats": 3249,
"elements": 81913
},
"nrAvoided": 218814,
"nrFunctionCalls": 127718,
"nrLookups": 40798,
"nrOpUpdateValuesCopied": 1563978,
"nrOpUpdates": 8542,
"nrPrimOpCalls": 113032,
"nrThunks": 329457,
"sets": {
"bytes": 29765392,
"elements": 1824093,
"number": 36244
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 235909,
"number": 24432
},
"values": {
"bytes": 9687840,
"number": 403660
}
}
```
2023-11-24 02:26:39 +00:00
|
|
|
|
inherit (validity) valid;
|
2024-03-20 03:48:12 +00:00
|
|
|
|
in if validity ? handled then validity else validity // {
|
2022-05-03 20:12:34 +01:00
|
|
|
|
# Throw an error if trying to evaluate a non-valid derivation
|
|
|
|
|
# or, alternatively, just output a warning message.
|
|
|
|
|
handled =
|
stdenv: Avoid allocating intermediate attrset when checking meta validity
This is a small performance optimization. It should be impercetible to most.
Benchmarks:
- Before
``` json
{
"cpuTime": 0.2777960002422333,
"envs": {
"bytes": 3832648,
"elements": 189513,
"number": 144784
},
"gc": {
"heapSize": 402915328,
"totalBytes": 50229344
},
"list": {
"bytes": 655304,
"concats": 3249,
"elements": 81913
},
"nrAvoided": 218962,
"nrFunctionCalls": 127718,
"nrLookups": 40946,
"nrOpUpdateValuesCopied": 1563978,
"nrOpUpdates": 8542,
"nrPrimOpCalls": 113032,
"nrThunks": 329605,
"sets": {
"bytes": 29774864,
"elements": 1824537,
"number": 36392
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 235909,
"number": 24432
},
"values": {
"bytes": 9691392,
"number": 403808
}
}
```
- After
```
{
"cpuTime": 0.2615779936313629,
"envs": {
"bytes": 3833832,
"elements": 189661,
"number": 144784
},
"gc": {
"heapSize": 402915328,
"totalBytes": 50212960
},
"list": {
"bytes": 655304,
"concats": 3249,
"elements": 81913
},
"nrAvoided": 218814,
"nrFunctionCalls": 127718,
"nrLookups": 40798,
"nrOpUpdateValuesCopied": 1563978,
"nrOpUpdates": 8542,
"nrPrimOpCalls": 113032,
"nrThunks": 329457,
"sets": {
"bytes": 29765392,
"elements": 1824093,
"number": 36244
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 235909,
"number": 24432
},
"values": {
"bytes": 9687840,
"number": 403660
}
}
```
2023-11-24 02:26:39 +00:00
|
|
|
|
(
|
|
|
|
|
if valid == "yes" then true
|
|
|
|
|
else if valid == "no" then (
|
|
|
|
|
handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; }
|
|
|
|
|
)
|
|
|
|
|
else if valid == "warn" then (
|
|
|
|
|
handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; }
|
|
|
|
|
)
|
|
|
|
|
else throw "Unknown validitiy: '${valid}'"
|
|
|
|
|
);
|
2018-01-31 03:10:34 +00:00
|
|
|
|
};
|
2017-12-25 17:38:45 +00:00
|
|
|
|
|
2023-04-26 04:43:44 +01:00
|
|
|
|
in { inherit assertValidity commonMeta; }
|