summaryrefslogtreecommitdiff
path: root/Biz/Bild/Nixpkgs.nix
blob: 8cb3448ead8fc0ac12560e786c0e22e087fc1cdb (plain)
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
let
  sources = import ./Sources.nix { sourcesFile = ./Sources.json; };

  config = {
    allowBroken = true;
    allowUnfree = true;
    cudaSupport = true;
  };

  system = __currentSystem;

in import sources.nixos-23_05 {
  inherit system config;
  overlays = [
    (_: _: { inherit sources; })

    # add some functions
    (_: old: {
      # Given a generic `builder`, will generate an attrset for all the packages
      # pinned by `deps` with `builder` applied to the package. This attrset can
      # then be merged with the rest of the packages in the set as part of an
      # overlay or overrides.
      overridePinnedDeps = builder:
        old.lib.genAttrs (builtins.attrNames sources) builder;

      # Modifies a derivation with our source and version, keeping old build
      # rules. This will fail if build steps have changed, or if no build
      # rules are available upstream.
      overrideSource = depName:
        if old ? "${depName}" && old.${depName} ? overrideAttrs then
          old.${depName}.overrideAttrs (attrs:
            attrs // rec {
              version = sources.${depName}.version or sources.${depName}.rev;
              src = sources.${depName};
            })
        else
          null;
    })

    # override pinned deps with our sources, this must come before other
    # package overlays, because of the 'null' above
    (_: pkgs: pkgs.overridePinnedDeps pkgs.overrideSource)

    # add other nixpkgs distributions
    (_: _: {
      unstable = import sources.nixpkgs-unstable { inherit system config; };
      nixos-23_11 = import sources.nixos-23_11 { inherit system config; };
    })

    # add our hand-written derivations
    (import ./Deps.nix)
    (_: pkgs: { niv = import pkgs.sources.niv { }; })
  ];
}