1/*
2 Nixpkgs unfree+redistributable packages.
3
4 NOTE: This file is used by the sister nix-community project.
5
6 The official Hydra instance only builds and provides binary caches for free
7 packages (as in OSI-approved).
8
9 Some unfree packages such as MongoDB, ZeroTier, ... take a while to be
10 built. While their license is not free, they allow redistribution of
11 build artefacts.
12
13 The sister project nix-community will build and distribute those packages
14 for a subset of the channels to <https://nix-community.cachix.org>.
15
16 See also:
17
18 * <https://hydra.nix-community.org/jobset/nixpkgs/unfree-redistributable>
19 * <https://github.com/nix-community/infra/pull/1406>
20
21 Test for example like this:
22
23 $ hydra-eval-jobs pkgs/top-level/release-unfree-redistributable.nix -I .
24*/
25
26{
27 # The platforms for which we build Nixpkgs.
28 supportedSystems ? [
29 "x86_64-linux"
30 "aarch64-linux"
31 ],
32 # Attributes passed to nixpkgs.
33 nixpkgsArgs ? {
34 config = {
35 allowAliases = false;
36 allowUnfree = true;
37 cudaSupport = true;
38 inHydra = true;
39 };
40
41 __allowFileset = false;
42 },
43 # We only build the full package set on infrequently releasing channels.
44 full ? false,
45}:
46
47let
48 release-lib = import ./release-lib.nix {
49 inherit supportedSystems nixpkgsArgs;
50 };
51
52 inherit (release-lib)
53 lib
54 mapTestOn
55 pkgs
56 ;
57
58 # similar to release-lib.packagePlatforms, but also includes some condition for which package to pick
59 packagesWith =
60 prefix: cond:
61 lib.mapAttrs (
62 name: value:
63 let
64 attrPath = if prefix == "" then name else "${prefix}.${name}";
65 res = builtins.tryEval (
66 if lib.isDerivation value then
67 lib.optionals (cond attrPath value) (
68 # logic copied from release-lib packagePlatforms
69 value.meta.hydraPlatforms
70 or (lib.subtractLists (value.meta.badPlatforms or [ ]) (value.meta.platforms or [ "x86_64-linux" ]))
71 )
72 else if value.recurseForDerivations or false || value.recurseForRelease or false then
73 # Recurse
74 packagesWith attrPath cond value
75 else
76 [ ]
77 );
78 in
79 lib.optionals res.success res.value
80 );
81
82 # Unfree is any license not OSI-approved.
83 isUnfree = pkg: lib.lists.any (l: !(l.free or true)) (lib.lists.toList (pkg.meta.license or [ ]));
84
85 # Whenever the license allows re-distribution of the binaries
86 isRedistributable =
87 pkg: lib.lists.any (l: l.redistributable or false) (lib.lists.toList (pkg.meta.license or [ ]));
88
89 isSource =
90 pkg: !lib.lists.any (x: !(x.isSource)) (lib.lists.toList (pkg.meta.sourceProvenance or [ ]));
91
92 isNotLinuxKernel =
93 attrPath: !(lib.hasPrefix "linuxKernel" attrPath || lib.hasPrefix "linuxPackages" attrPath);
94
95 # This is handled by release-cuda.nix
96 isNotCudaPackage = attrPath: !(lib.hasPrefix "cuda" attrPath);
97
98 canSubstituteSrc =
99 pkg:
100 # requireFile don't allow using substituters and are therefor skipped
101 pkg.src.allowSubstitutes or true;
102
103 cond =
104 attrPath: pkg:
105 (isUnfree pkg)
106 && (isRedistributable pkg)
107 && (isSource pkg)
108 && (canSubstituteSrc pkg)
109 && (
110 full
111 ||
112 # We only build these heavy packages on releases
113 ((isNotCudaPackage attrPath) && (isNotLinuxKernel attrPath))
114 );
115
116 packages = packagesWith "" cond pkgs;
117
118 jobs = mapTestOn packages;
119in
120jobs