summaryrefslogtreecommitdiffstats
path: root/pkgs/default.nix
blob: fffd289a275d64c7d5ad63bf40ce6e7a66868efd (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
self: super:

let
  inherit (super) lib mylib;

  pushBack = x: xs:
    if builtins.elem x xs then
      lib.remove x xs ++ [ x ]
    else
      xs;
in

# Import files and subdirectories like they are overlays.
lib.fix
  (builtins.foldl' (lib.flip lib.extends) (_: super)
    (
      [
        (self: super: {
          callObsolescentPackage = path: args: let
            override = self.callPackage path args;
            upstream = lib.optionalAttrs (override ? "name")
              (super.${(builtins.parseDrvName override.name).name} or {});
          in if upstream ? "name" &&
                override ? "name" &&
                builtins.compareVersions upstream.name override.name != -1
            then builtins.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override
            else override;
        })
      ]
      ++
      map
        (name: import (./. + "/${name}"))
        (pushBack "override"
          (builtins.attrNames
            (lib.filterAttrs mylib.isNixDirEntry (builtins.readDir ./.))))
    )
  )