These are intended for temporary fixes to upstream that are expected to be dropped when incorporated in upstream.
100 lines
3.9 KiB
Nix
100 lines
3.9 KiB
Nix
with builtins;
|
|
|
|
# This duplicates the overlay code in nixpkgs/pkgs/top-level/impure.nix (may require periodic resyncing).
|
|
#
|
|
# It has to be done this way because passing overlays to nixpkgs (required to insert our packages) disables all the
|
|
# default overlay mechanisms (required to pickup any user or system overlays).
|
|
|
|
let
|
|
|
|
# overlaysDefault - List of overlay functions nixpkgs would normally use if not provided.
|
|
#
|
|
# This is the order overlays are searched for in accordance to what is done in nixpkgs. If an overlay is found
|
|
# at a given level (the leading number) the search is stopped and they are used. If multiple overlays are found
|
|
# at a given level then an error is generated.
|
|
#
|
|
# 1: <nixpkgs-overlays> (i.e., nixpkgs-overlays.nix or nixpkgs-overlays/default.nix in NIX_PATH)
|
|
# 2: ~/.config/nixpkgs/overlays.nix
|
|
# 2: ~/.config/nixpkgs/overlays
|
|
#
|
|
# This code is lifted directly from nixpkgs/pkgs/top-level/impure.nix to ensure consistency.
|
|
#
|
|
overlaysDefault =
|
|
let
|
|
|
|
# isDir path - Is path a directory (requires access).
|
|
isDir = path: pathExists (path + "/.");
|
|
|
|
# try expression default - Replace expression with default on exception.
|
|
try = x: def: let res = tryEval x; in if res.success then res.value else def;
|
|
|
|
# overlaysRetrieve path - Retrieve a list of the overlay functions from path.
|
|
# path is file - import the file itself (should give a list of overlay functions)
|
|
# path is directory - list of imports of all the *.nix files in the directory (each should give an overlay function)
|
|
#
|
|
overlaysRetrieve = path:
|
|
if isDir path then
|
|
let content = readDir path; in
|
|
map (n: import (path + ("/" + n)))
|
|
(builtins.filter (n: builtins.match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix")))
|
|
(attrNames content))
|
|
else
|
|
import path;
|
|
|
|
# pathOverlays - NIX_PATH nixpkgs-overlays file or "" if not found
|
|
pathOverlays = try <nixpkgs-overlays> "";
|
|
|
|
# homeDir - ~/
|
|
# homeOverlaysFile - ~/.config/nixpkgs/overlays.nix
|
|
# homeOverlaysDir - ~/.config/nixpkgs/overlays
|
|
#
|
|
homeDir = builtins.getEnv "HOME";
|
|
homeOverlaysFile = homeDir + "/.config/nixpkgs/overlays.nix";
|
|
homeOverlaysDir = homeDir + "/.config/nixpkgs/overlays";
|
|
|
|
in
|
|
if pathOverlays != "" && pathExists pathOverlays then overlaysRetrieve pathOverlays
|
|
else if pathExists homeOverlaysFile && pathExists homeOverlaysDir then
|
|
throw ''
|
|
Nixpkgs overlays can be specified with ${homeOverlaysFile} or ${homeOverlaysDir}, but not both.
|
|
Please remove one of them and try again.
|
|
''
|
|
else if pathExists homeOverlaysFile then
|
|
if isDir homeOverlaysFile then
|
|
throw (homeOverlaysFile + " should be a file")
|
|
else overlaysRetrieve homeOverlaysFile
|
|
else if pathExists homeOverlaysDir then
|
|
if !(isDir homeOverlaysDir) then
|
|
throw (homeOverlaysDir + " should be a directory")
|
|
else overlaysRetrieve homeOverlaysDir
|
|
else [];
|
|
|
|
|
|
# overlaysAlways - List of overlay functions provide by this package.
|
|
#
|
|
# The naming in this function is misleading but consistent with nixpkgs.
|
|
#
|
|
# self - final package set (stack fully closed) (-> pkgs in all-packages.nix)
|
|
# super - prior package set (stack closed up to us)
|
|
# res - next package set (stack closed up to and over us) (-> self in all-packages.nix)
|
|
#
|
|
overlaysAlways =
|
|
let
|
|
# knot - Feed final and up to and over us overlay results into overlay
|
|
#
|
|
# This matche what is done in nixpkgs (see pkgs/top-level/stage.nix).
|
|
#
|
|
knot = path: self: super:
|
|
let res = import path res self; in res;
|
|
in
|
|
map knot [
|
|
./temporary/all-temporary.nix
|
|
./pkgs/all-packages.nix
|
|
];
|
|
|
|
in
|
|
|
|
{ overlays ? overlaysDefault
|
|
, ... } @ args:
|
|
import ./nixpkgs (args // { overlays = overlaysAlways ++ overlays; })
|