~aasg/nixexprs

ref: b3a95d942396f477ecb3dd9f5923c1de9d66f3db nixexprs/ci.nix -rw-r--r-- 2.0 KiB
b3a95d94 — Aluísio Augusto Silva Gonçalves ci.nix: Fix patched package list generation 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ pkgs ? import <nixpkgs> { }
, flake-utils-lib ? import (fetchTarball {
    url = "https://github.com/numtide/flake-utils/archive/588973065fce51f4763287f0fda87a174d78bf48.tar.gz";
    sha256 = "17h8rcp246y3444l9fp92jz1h5gp4gvgpnnd8rmhq686mdbha02r";
  })
}:
let
  inherit (builtins) deepSeq concatStringsSep listToAttrs mapAttrs;
  inherit (pkgs) recurseIntoAttrs;
  inherit (pkgs.lib.attrsets) filterAttrs getAttrFromPath isDerivation mapAttrsToList nameValuePair;
  inherit (pkgs.lib.strings) splitString;
  inherit (pkgs.lib.trivial) flip pipe;

  newPackages = selectDerivations (import ./pkgs { inherit pkgs; });

  patchedPackages = selectDerivations (import ./patches { pkgs = pkgs.extend (import ./pkgs/overlay.nix); });

  selectDerivations = set:
    let
      derivationTree = value:
        if isDerivation value
        then value
        else if value ? recurseForDerivations && value.recurseForDerivations == true
        then
          pipe value [
            (mapAttrs (name: derivationTree))
            (filterAttrs (name: value: value != null))
            recurseIntoAttrs
          ]
        else null;
    in
    derivationTree (recurseIntoAttrs set);

  flattenAttrsFromPaths = paths: set:
    listToAttrs
      (map
        (path: nameValuePair (concatStringsSep "__" path) (getAttrFromPath path set))
        paths);

  packagePaths = (flip pipe) [
    flake-utils-lib.flattenTree
    (mapAttrsToList (name: _: splitString "/" name))
  ];

in
{
  lib = deepSeq (import ./lib/tests.nix { lib = pkgs.lib; }) { };

  newPackagesDirect = newPackages;

  newPackagesOverlay = pipe [ ./pkgs/overlay.nix ] [
    (map import)
    pkgs.appendOverlays
    (flattenAttrsFromPaths (packagePaths newPackages))
    recurseIntoAttrs
  ];

  patchedPackagesDirect = patchedPackages;

  patchedPackagesOverlay = pipe [ ./pkgs/overlay.nix ./patches/overlay.nix ] [
    (map import)
    pkgs.appendOverlays
    (flattenAttrsFromPaths (packagePaths patchedPackages))
    recurseIntoAttrs
  ];
}