summaryrefslogtreecommitdiff
path: root/Omni/Bild/Functions.nix
blob: 8b87f86969e2cced0dbc08dd1e09321ad8f00bba (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
_: super: {
  # 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:
    super.lib.genAttrs (builtins.attrNames super.sources) builder;

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

  # Simply override the 'src' attr on a drv. This is meant to be a simpler
  # alternative to 'overrideSource' above. In an overlay, use it like:
  #    mypkg = super.overrideSrc super.mypkg super.sources.mypkg;
  overrideSrc = dep: src:
    dep.overrideAttrs (attrs:
      attrs // {
        version = src.version or src.rev;
        src = src;
      });
}