-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
69 lines (66 loc) · 1.96 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: 2022 The Standard Authors
#
# SPDX-License-Identifier: Unlicense
{
description = "Nix flakes with `systems` à la carte.";
outputs = {self}: {
__functor = self: self.lib.noSys;
lib.noSys = inputs @ {
systems ? import ./systems.nix,
config ? {},
...
}: f: let
systems' =
if builtins.isPath systems || systems ? outPath
then import systems
else systems;
in
self.lib.eachSys systems' (system: let
f' = inputs: let
# mapAttrs to deSys up to the same depths as in `self`
inputs' = builtins.mapAttrs (k: v: let
input = self.lib.deSys system v;
in
if
k
== "pkgs"
&& v ? legacyPackages
&& v.inputs == {}
&& builtins.pathExists "${v}/default.nix"
then let
pkgs =
if inputs ? config && inputs.config != {}
then
import v {
inherit system config;
}
else input.legacyPackages;
in
pkgs // input
else input) (builtins.removeAttrs inputs ["self"]);
self' = self.lib.deSys system (builtins.removeAttrs inputs.self ["inputs"]);
in
# must be recombined after `deSys` to avoid infinite recursion
f ((
if inputs ? pkgs && inputs.pkgs ? lib
then {inherit (inputs.pkgs) lib;}
else {}
)
// inputs'
// {self = self';});
in
f' inputs);
lib.deSys = import ./desys.nix;
lib.eachSys = import ./eachSys.nix;
templates = {
default = {
path = ./tmpls/default;
description = "Minimal flake with simplified systems handling.";
};
local = {
path = ./tmpls/local;
description = "Minimal local development environment flake.";
};
};
};
}