$NIXPKGS_OVERLAYS -> <nixpkgs-overlays>
The Nix search path is the established mechanism for specifying the location of Nix expressions, so let's use it instead of adding another environment variable.
This commit is contained in:
parent
86fe7a40ac
commit
7dacca324d
|
@ -28,8 +28,8 @@ first one present is considered, and all the rest are ignored:
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
||||||
<para>In the directory pointed by the environment variable
|
<para>In the directory pointed to by the Nix search path entry
|
||||||
<varname>NIXPKGS_OVERLAYS</varname>.</para>
|
<literal><nixpkgs-overlays></literal>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
/* Impure default args for `pkgs/top-level/default.nix`. See that file
|
/* Impure default args for `pkgs/top-level/default.nix`. See that file
|
||||||
for the meaning of each argument. */
|
for the meaning of each argument. */
|
||||||
|
|
||||||
|
with builtins;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
homeDir = builtins.getEnv "HOME";
|
||||||
|
|
||||||
|
# Return ‘x’ if it evaluates, or ‘def’ if it throws an exception.
|
||||||
|
try = x: def: let res = tryEval x; in if res.success then res.value else def;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
{ # Fallback: Assume we are building packages for the current (host, in GNU
|
{ # Fallback: Assume we are building packages for the current (host, in GNU
|
||||||
# Autotools parlance) system.
|
# Autotools parlance) system.
|
||||||
system ? builtins.currentSystem
|
system ? builtins.currentSystem
|
||||||
|
@ -8,10 +19,7 @@
|
||||||
, # Fallback: The contents of the configuration file found at $NIXPKGS_CONFIG or
|
, # Fallback: The contents of the configuration file found at $NIXPKGS_CONFIG or
|
||||||
# $HOME/.nixpkgs/config.nix.
|
# $HOME/.nixpkgs/config.nix.
|
||||||
config ? let
|
config ? let
|
||||||
inherit (builtins) getEnv pathExists;
|
|
||||||
|
|
||||||
configFile = getEnv "NIXPKGS_CONFIG";
|
configFile = getEnv "NIXPKGS_CONFIG";
|
||||||
homeDir = getEnv "HOME";
|
|
||||||
configFile2 = homeDir + "/.nixpkgs/config.nix";
|
configFile2 = homeDir + "/.nixpkgs/config.nix";
|
||||||
in
|
in
|
||||||
if configFile != "" && pathExists configFile then import configFile
|
if configFile != "" && pathExists configFile then import configFile
|
||||||
|
@ -22,20 +30,17 @@
|
||||||
# collections of packages. These collection of packages are part of the
|
# collections of packages. These collection of packages are part of the
|
||||||
# fix-point made by Nixpkgs.
|
# fix-point made by Nixpkgs.
|
||||||
overlays ? let
|
overlays ? let
|
||||||
inherit (builtins) getEnv pathExists readDir attrNames map sort
|
dirPath = try (if pathExists <nixpkgs-overlays> then <nixpkgs-overlays> else "") "";
|
||||||
lessThan;
|
dirHome = homeDir + "/.nixpkgs/overlays";
|
||||||
dirEnv = getEnv "NIXPKGS_OVERLAYS";
|
|
||||||
dirHome = (getEnv "HOME") + "/.nixpkgs/overlays";
|
|
||||||
dirCheck = dir: dir != "" && pathExists (dir + "/.");
|
dirCheck = dir: dir != "" && pathExists (dir + "/.");
|
||||||
overlays = dir:
|
overlays = dir:
|
||||||
let content = readDir dir; in
|
let content = readDir dir; in
|
||||||
map (n: import "${dir}/${n}")
|
map (n: import (dir + ("/" + n)))
|
||||||
(builtins.filter (n: builtins.match ".*\.nix" n != null)
|
(builtins.filter (n: builtins.match ".*\.nix" n != null)
|
||||||
(sort lessThan (attrNames content)));
|
(sort lessThan (attrNames content)));
|
||||||
in
|
in
|
||||||
if dirEnv != "" then
|
if dirPath != "" then
|
||||||
if dirCheck dirEnv then overlays dirEnv
|
overlays dirPath
|
||||||
else throw "The environment variable NIXPKGS_OVERLAYS does not name a valid directory."
|
|
||||||
else if dirCheck dirHome then overlays dirHome
|
else if dirCheck dirHome then overlays dirHome
|
||||||
else []
|
else []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue