k3s: format with nixfmt-rfc-style
[NixPkgs.git] / maintainers / scripts / build.nix
blobca401700b4a6ee099541d750bff349b9552e499b
1 { maintainer
2 , localSystem ? { system = args.system or builtins.currentSystem; }
3 , system ? localSystem.system
4 , crossSystem ? localSystem
5 , ...
6 }@args:
8 # based on update.nix
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
14 let
15   pkgs = import ./../../default.nix (removeAttrs args [ "maintainer" ]);
16   maintainer_ = pkgs.lib.maintainers.${maintainer};
17   packagesWith = cond: return: set:
18     (pkgs.lib.flatten
19       (pkgs.lib.mapAttrsToList
20         (name: pkg:
21           let
22             result = builtins.tryEval
23               (
24                 if pkgs.lib.isDerivation pkg && cond name pkg then
25                   # Skip packages whose closure fails on evaluation.
26                   # This happens for pkgs like `python27Packages.djangoql`
27                   # that have disabled Python pkgs as dependencies.
28                   builtins.seq pkg.outPath
29                     [ (return name pkg) ]
30                 else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
31                 then packagesWith cond return pkg
32                 else [ ]
33               );
34           in
35           if result.success then result.value
36           else [ ]
37         )
38         set
39       )
40     );
42 packagesWith
43   (name: pkg:
44     (
45       if builtins.hasAttr "meta" pkg && builtins.hasAttr "maintainers" pkg.meta
46       then (
47         if builtins.isList pkg.meta.maintainers
48         then builtins.elem maintainer_ pkg.meta.maintainers
49         else maintainer_ == pkg.meta.maintainers
50       )
51       else false
52     )
53   )
54   (name: pkg: pkg)
55   pkgs