pkgs/top-level: allow overrides through by-name
and check for file existence before using path
This commit is contained in:
parent
89b9624031
commit
e95279f45c
3 changed files with 52 additions and 2 deletions
|
@ -45,7 +45,7 @@ self = {
|
||||||
{
|
{
|
||||||
config.nixpkgs.overlays = [
|
config.nixpkgs.overlays = [
|
||||||
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${self}/pkgs/top-level/impure.nix"; } )
|
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${self}/pkgs/top-level/impure.nix"; } )
|
||||||
( import "${inputs.nixpkgs}/pkgs/top-level/by-name-overlay.nix" "${self}/pkgs/by-name" )
|
( import ./pkgs/top-level/by-name-overlay.nix "${self}/pkgs/by-name" )
|
||||||
self.overlays.versionInfoFixup
|
self.overlays.versionInfoFixup
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
50
pkgs/top-level/by-name-overlay.nix
Normal file
50
pkgs/top-level/by-name-overlay.nix
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# Modified copy of github:NixOS/nixpkgs pkgs/top-level/by-name-overlay.nix
|
||||||
|
# as of commit c0d0be00d4ecc4b51d2d6948e37466194c1e6c51
|
||||||
|
|
||||||
|
# This file turns the pkgs/by-name directory into an overlay that adds all the defined packages.
|
||||||
|
# No validity checks are done here.
|
||||||
|
|
||||||
|
# Type: Path -> Overlay
|
||||||
|
baseDirectory:
|
||||||
|
let
|
||||||
|
lib = (import ../../outputs.nix {}).lib;
|
||||||
|
|
||||||
|
inherit (builtins)
|
||||||
|
readDir
|
||||||
|
;
|
||||||
|
|
||||||
|
inherit (lib.attrsets)
|
||||||
|
mapAttrs
|
||||||
|
mapAttrsToList
|
||||||
|
mergeAttrsList
|
||||||
|
;
|
||||||
|
|
||||||
|
# Package files for a single shard
|
||||||
|
# Type: String -> String -> String -> AttrsOf Path
|
||||||
|
namesForShard = nixFilename: shard: type:
|
||||||
|
if type != "directory" then
|
||||||
|
# Ignore all non-directories.
|
||||||
|
{ }
|
||||||
|
else
|
||||||
|
mapAttrs
|
||||||
|
(name: _: baseDirectory + "/${shard}/${name}/${nixFilename}")
|
||||||
|
(readDir (baseDirectory + "/${shard}"));
|
||||||
|
|
||||||
|
# The attribute set mapping names to the package files defining them
|
||||||
|
# Type: String -> AttrsOf Path
|
||||||
|
packageFiles = nixFilename: lib.pipe baseDirectory [
|
||||||
|
readDir
|
||||||
|
(mapAttrsToList (namesForShard nixFilename))
|
||||||
|
mergeAttrsList
|
||||||
|
# Filter out paths that don't have a ${nixFilename} file
|
||||||
|
(lib.filterAttrs (_: lib.pathExists))
|
||||||
|
];
|
||||||
|
in
|
||||||
|
self: super:
|
||||||
|
mapAttrs (name: file:
|
||||||
|
self.callPackage file { inherit self super; package = super.${name}; }
|
||||||
|
) (packageFiles "override.nix")
|
||||||
|
// mapAttrs (name: file:
|
||||||
|
self.callPackage file { }
|
||||||
|
) (packageFiles "package.nix")
|
||||||
|
|
|
@ -16,7 +16,7 @@ let
|
||||||
( import ../overlays/selfExpr.nix { nixpkgsPath = "${builtins.toString ../..}/pkgs/top-level/impure.nix"; } )
|
( import ../overlays/selfExpr.nix { nixpkgsPath = "${builtins.toString ../..}/pkgs/top-level/impure.nix"; } )
|
||||||
( import ../overlays/unstable.nix )
|
( import ../overlays/unstable.nix )
|
||||||
( import ../overlays/version-info-fixup.nix { inherit inputs; } )
|
( import ../overlays/version-info-fixup.nix { inherit inputs; } )
|
||||||
( import "${inputs.nixpkgs}/pkgs/top-level/by-name-overlay.nix" ../by-name )
|
( import ./by-name-overlay.nix ../by-name )
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in a new issue