pkgs: import relative stockholm lib only once

New overlay code in inspired by <nixpkgs/pkgs/top-level/stage.nix>.
This commit is contained in:
tv 2021-10-12 22:08:07 +02:00
parent 77c3aab5b8
commit be5f4833fe
3 changed files with 21 additions and 16 deletions

View File

@ -1,17 +1,23 @@
with import ../../lib; let
stockholm.lib = import ../../lib;
in
with stockholm.lib;
self: super: self: super:
fix (foldl' (flip extends) (self: super) (
# Import files and subdirectories like they are overlays. [
foldl' mergeAttrs {} (self: super: { inherit stockholm; })
]
++
(map (map
(name: import (./. + "/${name}") self super) (name: import (./. + "/${name}"))
(filter (filter
(name: name != "default.nix" && !hasPrefix "." name) (name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir ./.)))) (attrNames (readDir ./.))))
++
// [
(self: super: {
{ brockman = self.haskellPackages.brockman;
brockman = self.haskellPackages.brockman; reaktor2 = self.haskellPackages.reaktor2;
reaktor2 = self.haskellPackages.reaktor2; })
} ]
))

View File

@ -2,7 +2,7 @@ self: super:
let let
# This callPackage will try to detect obsolete overrides. # This callPackage will try to detect obsolete overrides.
lib = import ../../../lib; lib = super.stockholm.lib;
callPackage = path: args: let callPackage = path: args: let
override = self.callPackage path args; override = self.callPackage path args;
upstream = lib.optionalAttrs (override ? "name") upstream = lib.optionalAttrs (override ? "name")
@ -13,5 +13,4 @@ let
then lib.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override then lib.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override
else override; else override;
in in
{ stockholm.lib = lib; } // lib.mapNixDir (path: callPackage path {}) ./.
lib.mapNixDir (path: callPackage path {}) ./.

View File

@ -6,8 +6,8 @@
nixpkgs = { nixpkgs = {
overlays = [ overlays = [
(import ./5pkgs)
(import ../submodules/nix-writers/pkgs) (import ../submodules/nix-writers/pkgs)
(import ./5pkgs)
]; ];
}; };