Skip to content

Commit 17f577e

Browse files
committed
packages: make byName the single top-level scope
This is required for overrides to work correctly. Previously, overriding a package in one scope (e.g. 'kata') wouldn't propagate properly into another scope (e.g. 'contrast') that depends on that package from the first scope.
1 parent 6f563ca commit 17f577e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

packages/default.nix

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@
44
{ pkgs }:
55

66
let
7-
inherit (pkgs.lib) makeScope;
7+
inherit (pkgs.lib) makeScope packagesFromDirectoryRecursive;
8+
9+
# IMPORTANT!
10+
# byName must be the top-level scope, otherwise overrides won't propagate correctly.
11+
# Do not merge (//) anything into byName. Always use overrideScope for modifications.
12+
byName = packagesFromDirectoryRecursive {
13+
inherit (pkgs) newScope;
14+
callPackage = pkgs.newScope { };
15+
directory = ./by-name;
16+
};
817
in
918

10-
makeScope pkgs.newScope (
11-
self:
12-
let
13-
fromDir = pkgs.lib.packagesFromDirectoryRecursive {
14-
inherit (self) callPackage newScope;
15-
directory = ./by-name;
16-
};
17-
in
18-
fromDir
19-
// {
19+
byName.overrideScope (
20+
_final: prev: {
2021
contrastPkgsStatic = makeScope pkgs.pkgsStatic.newScope (
2122
self:
22-
pkgs.lib.packagesFromDirectoryRecursive {
23+
packagesFromDirectoryRecursive {
2324
inherit (self) callPackage newScope;
2425
directory = ./by-name;
2526
}
2627
);
27-
scripts = (fromDir.scripts or { }) // pkgs.callPackages ./scripts.nix { };
28-
containers = (fromDir.containers or { }) // pkgs.callPackages ./containers.nix { };
28+
scripts = (prev.scripts or { }) // pkgs.callPackages ./scripts.nix { };
29+
containers = (prev.containers or { }) // pkgs.callPackages ./containers.nix { };
2930
contrast-releases = pkgs.callPackages ./contrast-releases.nix { };
3031
}
3132
)

0 commit comments

Comments
 (0)