Now Passing
This commit is contained in:
151
default.nix
151
default.nix
@@ -1,149 +1,2 @@
|
||||
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
|
||||
|
||||
# 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;
|
||||
|
||||
# isDir path - Is path a directory (requires access).
|
||||
isDir = path: pathExists (path + "/.");
|
||||
|
||||
# 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 matches what is done in nixpkgs (see pkgs/top-level/stage.nix).
|
||||
#
|
||||
knot = path: self: super:
|
||||
let res = import path res super self; in res;
|
||||
in
|
||||
map knot [
|
||||
./temporary/all-packages.nix
|
||||
./pkgs/all-packages.nix
|
||||
];
|
||||
|
||||
# nixpkgs - The underlying nixpkg to use.
|
||||
#
|
||||
# Get a usable nixpkgs, that is, one with a version that matches ours, or die.
|
||||
#
|
||||
nixpkgs =
|
||||
let
|
||||
|
||||
# first check list - Return first element of list that passes check list otherwise aborts.
|
||||
#
|
||||
first = check: list:
|
||||
if list == []
|
||||
then builtins.throw ''
|
||||
Unable to locate a suitable nixpkgs directory.
|
||||
Most likely you want to git clone one into the top of the repo as 'upstream'.
|
||||
''
|
||||
else if check ( builtins.head list )
|
||||
then builtins.head list
|
||||
else first check ( builtins.tail list );
|
||||
|
||||
# okay path - Check if path exist and match our version number and otherwise print a warning.
|
||||
#
|
||||
# Version numbers are taken from ./version files.
|
||||
#
|
||||
okay =
|
||||
let
|
||||
version = builtins.readFile ./.version;
|
||||
in
|
||||
path:
|
||||
( builtins.pathExists (path + /.version)
|
||||
&& ( builtins.readFile (path + /.version) == version
|
||||
|| builtins.trace ''
|
||||
Skipping ${toString path} as not version ${version}.
|
||||
'' false ) );
|
||||
|
||||
# paths - Paths to search for nixpkgs.
|
||||
#
|
||||
paths = [
|
||||
./upstream # 1. build channel or git cloned one directly associated with us takes priority
|
||||
<nixpkgs/upstream> # 2. if the channel is a version of ourselves the real one will be in a subdirectory
|
||||
<nixpkgs> # 3. otherwise maybe the channel is a nixpkgs proper
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
first okay paths;
|
||||
|
||||
in
|
||||
|
||||
{ overlays ? overlaysDefault
|
||||
, upstream ? nixpkgs
|
||||
, ... } @ args:
|
||||
|
||||
import upstream ( builtins.removeAttrs args [ "upstream" ]
|
||||
// { overlays = overlaysAlways ++ overlays; } )
|
||||
self: super:
|
||||
import ./pkgs/all-packages.nix self super
|
||||
|
||||
Reference in New Issue
Block a user