···1+/**
2+ This file has as its value the list of overlays, as determined from the environment.
3+ If Nix evaluation is [pure](https://nix.dev/manual/nix/latest/command-ref/conf-file.html?highlight=pure-eval#conf-pure-eval), then the list is empty.
4+*/
5+let
6+ # Return ‘x’ if it evaluates, or ‘def’ if it throws an exception.
7+ try =
8+ x: def:
9+ let
10+ res = builtins.tryEval x;
11+ in
12+ if res.success then res.value else def;
13+ homeDir = builtins.getEnv "HOME";
14+15+ isDir = path: builtins.pathExists (path + "/.");
16+ pathOverlays = try (toString <nixpkgs-overlays>) "";
17+ homeOverlaysFile = homeDir + "/.config/nixpkgs/overlays.nix";
18+ homeOverlaysDir = homeDir + "/.config/nixpkgs/overlays";
19+ overlays =
20+ path:
21+ # check if the path is a directory or a file
22+ if isDir path then
23+ # it's a directory, so the set of overlays from the directory, ordered lexicographically
24+ let
25+ content = builtins.readDir path;
26+ in
27+ map (n: import (path + ("/" + n))) (
28+ builtins.filter (
29+ n:
30+ (
31+ builtins.match ".*\\.nix" n != null
32+ &&
33+ # ignore Emacs lock files (.#foo.nix)
34+ builtins.match "\\.#.*" n == null
35+ )
36+ || builtins.pathExists (path + ("/" + n + "/default.nix"))
37+ ) (builtins.attrNames content)
38+ )
39+ else
40+ # it's a file, so the result is the contents of the file itself
41+ import path;
42+in
43+if pathOverlays != "" && builtins.pathExists pathOverlays then
44+ overlays pathOverlays
45+else if builtins.pathExists homeOverlaysFile && builtins.pathExists homeOverlaysDir then
46+ throw ''
47+ Nixpkgs overlays can be specified with ${homeOverlaysFile} or ${homeOverlaysDir}, but not both.
48+ Please remove one of them and try again.
49+ ''
50+else if builtins.pathExists homeOverlaysFile then
51+ if isDir homeOverlaysFile then
52+ throw (homeOverlaysFile + " should be a file")
53+ else
54+ overlays homeOverlaysFile
55+else if builtins.pathExists homeOverlaysDir then
56+ if !(isDir homeOverlaysDir) then
57+ throw (homeOverlaysDir + " should be a directory")
58+ else
59+ overlays homeOverlaysDir
60+else
61+ [ ]
+1-57
pkgs/top-level/impure.nix
···78 homeDir = builtins.getEnv "HOME";
910- # Return ‘x’ if it evaluates, or ‘def’ if it throws an exception.
11- try =
12- x: def:
13- let
14- res = builtins.tryEval x;
15- in
16- if res.success then res.value else def;
17-18in
1920{
···50 # Overlays are used to extend Nixpkgs collection with additional
51 # collections of packages. These collection of packages are part of the
52 # fix-point made by Nixpkgs.
53- overlays ?
54- let
55- isDir = path: builtins.pathExists (path + "/.");
56- pathOverlays = try (toString <nixpkgs-overlays>) "";
57- homeOverlaysFile = homeDir + "/.config/nixpkgs/overlays.nix";
58- homeOverlaysDir = homeDir + "/.config/nixpkgs/overlays";
59- overlays =
60- path:
61- # check if the path is a directory or a file
62- if isDir path then
63- # it's a directory, so the set of overlays from the directory, ordered lexicographically
64- let
65- content = builtins.readDir path;
66- in
67- map (n: import (path + ("/" + n))) (
68- builtins.filter (
69- n:
70- (
71- builtins.match ".*\\.nix" n != null
72- &&
73- # ignore Emacs lock files (.#foo.nix)
74- builtins.match "\\.#.*" n == null
75- )
76- || builtins.pathExists (path + ("/" + n + "/default.nix"))
77- ) (builtins.attrNames content)
78- )
79- else
80- # it's a file, so the result is the contents of the file itself
81- import path;
82- in
83- if pathOverlays != "" && builtins.pathExists pathOverlays then
84- overlays pathOverlays
85- else if builtins.pathExists homeOverlaysFile && builtins.pathExists homeOverlaysDir then
86- throw ''
87- Nixpkgs overlays can be specified with ${homeOverlaysFile} or ${homeOverlaysDir}, but not both.
88- Please remove one of them and try again.
89- ''
90- else if builtins.pathExists homeOverlaysFile then
91- if isDir homeOverlaysFile then
92- throw (homeOverlaysFile + " should be a file")
93- else
94- overlays homeOverlaysFile
95- else if builtins.pathExists homeOverlaysDir then
96- if !(isDir homeOverlaysDir) then
97- throw (homeOverlaysDir + " should be a directory")
98- else
99- overlays homeOverlaysDir
100- else
101- [ ],
102103 crossOverlays ? [ ],
104
···78 homeDir = builtins.getEnv "HOME";
90000000010in
1112{
···42 # Overlays are used to extend Nixpkgs collection with additional
43 # collections of packages. These collection of packages are part of the
44 # fix-point made by Nixpkgs.
45+ overlays ? import ./impure-overlays.nix,
0000000000000000000000000000000000000000000000004647 crossOverlays ? [ ],
48