2 , localSystem ? { system = args.system or builtins.currentSystem; }
3 , system ? localSystem.system
4 , crossSystem ? localSystem
9 # nix-build build.nix --argstr maintainer <yourname>
11 # to build for aarch64-linux using boot.binfmt.emulatedSystems:
12 # nix-build build.nix --argstr maintainer <yourname> --argstr system aarch64-linux
15 # This avoids a common situation for maintainers, where due to Git's behavior of not tracking
16 # directories, they have an empty directory somewhere in `pkgs/by-name`. Because that directory
17 # exists, `pkgs/top-level/by-name-overlay.nix` picks it up and attempts to read `package.nix` out
18 # of it... which doesn't exist, since it's empty.
20 # We don't want to run the code below on every instantiation of `nixpkgs`, as the `pkgs/by-name`
21 # eval machinery is quite performance sensitive. So we use the internals of the `by-name` overlay
22 # to implement our own way to avoid an evaluation failure for this script.
24 # See <https://github.com/NixOS/nixpkgs/issues/338227> for more motivation for this code block.
25 overlay = self: super: {
26 _internalCallByNamePackageFile =
27 file: if builtins.pathExists file then super._internalCallByNamePackageFile file else null;
30 nixpkgsArgs = removeAttrs args [ "maintainer" "overlays" ] // {
31 overlays = args.overlays or [] ++ [ overlay ];
34 pkgs = import ./../../default.nix nixpkgsArgs;
36 maintainer_ = pkgs.lib.maintainers.${maintainer};
37 packagesWith = cond: return: set:
39 (pkgs.lib.mapAttrsToList
42 result = builtins.tryEval
44 if pkgs.lib.isDerivation pkg && cond name pkg then
45 # Skip packages whose closure fails on evaluation.
46 # This happens for pkgs like `python27Packages.djangoql`
47 # that have disabled Python pkgs as dependencies.
48 builtins.seq pkg.outPath
50 else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
51 then packagesWith cond return pkg
55 if result.success then result.value
65 if builtins.hasAttr "meta" pkg && builtins.hasAttr "maintainers" pkg.meta
67 if builtins.isList pkg.meta.maintainers
68 then builtins.elem maintainer_ pkg.meta.maintainers
69 else maintainer_ == pkg.meta.maintainers