mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00

Due to Nix bug <https://github.com/NixOS/nix/issues/11503>, `builtins.filterSource` and chroot stores interact in a confusing and broken way that breaks `lib.fileset`. This means that uses of the API inside Nixpkgs keep breaking the NixOS installer, blocking the channel. The resulting error messages are inscrutable (they look like “the installer test is trying to download `curl`…?” and eventually bottom out in a derivation that has the wrong `outPath` because of the chroot store causing an incorrect `lib.fileset` result). Whenever this happens, someone (well, in practice K900 or I) has to bisect the change that introduced it and remove the use of `lib.fileset`. This has happened at least three times in the past four months (I believe I might actually be missing one here, but these are the ones I remember and could easily dig up): * <https://github.com/NixOS/nixpkgs/pull/340046> * <https://github.com/NixOS/nixpkgs/pull/352491> * <https://github.com/NixOS/nixpkgs/pull/369459> The options I see here are: 1. Forbid use of `lib.fileset` within Nixpkgs until the Nix bug is fixed. This is the approach taken here. External users of Nixpkgs can continue to use the API as normal, but using it from within something that affects any release jobset `outPath`s will cause an evaluation failure with a hopefully‐helpful error message. 2. Forbid `lib.fileset` and also all of the other library APIs that use `builtins.filterSource`. I’m happy to do this, but so far none of those have broken the installer, so I decided to start small and worry about the others if they end up causing a problem in practice. 3. Forbid `builtins.filterSource` directly. This is hard and would require more invasive `builtins.scopedImport` crimes to do at evaluation time. I think this would realistically have to be done in something like nixpkgs-vet instead and I didn’t have much luck shoehorning a check like this into that codebase when I tried. 4. Fix the Nix bug. This would be great! But also it doesn’t seem to be happening any time soon, it seems difficult to fix in a way that doesn’t subtly break compatibility with the previous semantics, and arguably the fix would need backporting all the way back to 2.3 given our minimum version policy. 5. Do nothing; have people continue to innocuously use `lib.fileset` throughout Nixpkgs, breaking the installer whenever one of them sneaks in to that closure, causing the channel to be blocked and requiring expensive bisections to narrow down the inscrutable test failure to the package using `lib.fileset`, which then needs moving back off it. This sucks for the people who keep having to track it down, holds back important channel bumps, and the criteria for when it’s okay to use `lib.fileset` are not realistically possible to teach to all contributors. I'd be happy to work on (2) as an alternative; (3) would be difficult and seems like overkill, (4) is not really something I trust myself to do and wouldn’t address the immediate problem, and (5) isn’t sustainable. I think that the current approach here is the best trade‐off for now, as `lib.fileset` seems to be the only prominent user of the `builtins.filterSource` API that works with full store paths, exposing it to the Nix bug. It’s unfortunate to lose the nice API, but since we can’t rely on it to produce correct results and the channels keep getting blocked as a result, I don’t think we really have an alternative right now.
124 lines
3.5 KiB
Nix
124 lines
3.5 KiB
Nix
/*
|
|
Nixpkgs unfree+redistributable packages.
|
|
|
|
NOTE: This file is used by the sister nix-community project.
|
|
|
|
The official Hydra instance only builds and provides binary caches for free
|
|
packages (as in OSI-approved).
|
|
|
|
Some unfree packages such as MongoDB, ZeroTier, ... take a while to be
|
|
built. While their license is not free, they allow redistribution of
|
|
build artefacts.
|
|
|
|
The sister project nix-community will build and distribute those packages
|
|
for a subset of the channels to <https://nix-community.cachix.org>.
|
|
|
|
See also:
|
|
|
|
* <https://hydra.nix-community.org/jobset/nixpkgs/unfree-redistributable>
|
|
* <https://github.com/nix-community/infra/pull/1406>
|
|
|
|
Test for example like this:
|
|
|
|
$ hydra-eval-jobs pkgs/top-level/release-unfree-redistributable.nix -I .
|
|
*/
|
|
|
|
{
|
|
# The platforms for which we build Nixpkgs.
|
|
supportedSystems ? [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
],
|
|
# Attributes passed to nixpkgs.
|
|
nixpkgsArgs ? {
|
|
config = {
|
|
allowAliases = false;
|
|
allowUnfree = true;
|
|
cudaSupport = true;
|
|
inHydra = true;
|
|
};
|
|
|
|
__allowFileset = false;
|
|
},
|
|
# We only build the full package set on infrequently releasing channels.
|
|
full ? false,
|
|
}:
|
|
|
|
let
|
|
release-lib = import ./release-lib.nix {
|
|
inherit supportedSystems nixpkgsArgs;
|
|
};
|
|
|
|
inherit (release-lib)
|
|
lib
|
|
mapTestOn
|
|
pkgs
|
|
;
|
|
|
|
# similar to release-lib.packagePlatforms, but also includes some condition for which package to pick
|
|
packagesWith =
|
|
prefix: cond:
|
|
lib.mapAttrs (
|
|
name: value:
|
|
let
|
|
attrPath = if prefix == "" then name else "${prefix}.${name}";
|
|
res = builtins.tryEval (
|
|
if lib.isDerivation value then
|
|
lib.optionals (cond attrPath value) (
|
|
# logic copied from release-lib packagePlatforms
|
|
value.meta.hydraPlatforms
|
|
or (lib.subtractLists (value.meta.badPlatforms or [ ]) (value.meta.platforms or [ "x86_64-linux" ]))
|
|
)
|
|
else if
|
|
value.recurseForDerivations or false
|
|
|| value.recurseForRelease or false
|
|
|| value.__recurseIntoDerivationForReleaseJobs or false
|
|
then
|
|
# Recurse
|
|
packagesWith attrPath cond value
|
|
else
|
|
[ ]
|
|
);
|
|
in
|
|
lib.optionals res.success res.value
|
|
);
|
|
|
|
# Unfree is any license not OSI-approved.
|
|
isUnfree = pkg: lib.lists.any (l: !(l.free or true)) (lib.lists.toList (pkg.meta.license or [ ]));
|
|
|
|
# Whenever the license allows re-distribution of the binaries
|
|
isRedistributable =
|
|
pkg: lib.lists.any (l: l.redistributable or false) (lib.lists.toList (pkg.meta.license or [ ]));
|
|
|
|
isSource =
|
|
pkg: !lib.lists.any (x: !(x.isSource)) (lib.lists.toList (pkg.meta.sourceProvenance or [ ]));
|
|
|
|
isNotLinuxKernel =
|
|
attrPath: !(lib.hasPrefix "linuxKernel" attrPath || lib.hasPrefix "linuxPackages" attrPath);
|
|
|
|
# This is handled by release-cuda.nix
|
|
isNotCudaPackage = attrPath: !(lib.hasPrefix "cuda" attrPath);
|
|
|
|
canSubstituteSrc =
|
|
pkg:
|
|
# requireFile don't allow using substituters and are therefor skipped
|
|
pkg.src.allowSubstitutes or true;
|
|
|
|
cond =
|
|
attrPath: pkg:
|
|
(isUnfree pkg)
|
|
&& (isRedistributable pkg)
|
|
&& (isSource pkg)
|
|
&& (canSubstituteSrc pkg)
|
|
&& (
|
|
full
|
|
||
|
|
# We only build these heavy packages on releases
|
|
((isNotCudaPackage attrPath) && (isNotLinuxKernel attrPath))
|
|
);
|
|
|
|
packages = packagesWith "" cond pkgs;
|
|
|
|
jobs = mapTestOn packages;
|
|
in
|
|
jobs
|