-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
136 lines (123 loc) · 3.31 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
description = "docs";
inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-23.11";
flake = true;
};
nixpkgs-unstable = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
flake = true;
};
devenv = {
type = "github";
owner = "cachix";
repo = "devenv";
ref = "main";
flake = true;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
devenv,
...
} @ inputs: let
supportedSystems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
_targets = [
"aarch64-apple-darwin"
"aarch64-unknown-linux-gnu"
"x86_64-apple-darwin"
"x86_64-unknown-linux-gnu"
];
forAllSystems = f:
builtins.listToAttrs (map (buildPlatform: {
name = buildPlatform;
value = builtins.listToAttrs (map (hostPlatform: {
name = hostPlatform;
value = f buildPlatform hostPlatform;
})
supportedSystems);
})
supportedSystems);
pkgsImportCrossSystem = buildPlatform: hostPlatform:
import nixpkgs {
system = buildPlatform;
overlays = [];
config = {
allowUnfree = true;
allowUnfreePredicate = _: true;
};
crossSystem =
if buildPlatform == hostPlatform
then null
else {
config = hostPlatform;
};
};
pkgsImportCrossSystemUnstable = buildPlatform: hostPlatform:
import nixpkgs-unstable {
system = buildPlatform;
overlays = [];
config = {
allowUnfree = true;
allowUnfreePredicate = _: true;
};
crossSystem =
if buildPlatform == hostPlatform
then null
else {
config = hostPlatform;
};
};
flattenPackages = systems:
builtins.foldl' (acc: system:
builtins.foldl' (
innerAcc: hostPlatform:
innerAcc // {"${system}.${hostPlatform}" = systems.${system}.${hostPlatform};}
)
acc (builtins.attrNames systems.${system})) {} (builtins.attrNames systems);
in {
###############
## DevShells
###############
devShells = flattenPackages (forAllSystems (buildPlatform: hostPlatform: let
# Build Platform
system = buildPlatform;
pkgs = pkgsImportCrossSystem buildPlatform buildPlatform;
pkgsUnstable = pkgsImportCrossSystemUnstable buildPlatform buildPlatform;
# Host Platform
crossPkgs = pkgsImportCrossSystem buildPlatform hostPlatform;
crossPkgsUnstable = pkgsImportCrossSystemUnstable buildPlatform hostPlatform;
in {
devenv = import ./nix/devshells/devenv {
inherit inputs;
inherit system;
inherit pkgs;
inherit pkgsUnstable;
inherit crossPkgs;
inherit crossPkgsUnstable;
};
default = self.${system}.devShells.devenv;
}));
# Set the default devshell to the one for the current system.
devShell = builtins.listToAttrs (map (system: {
name = system;
value = self.devShells."${system}.${system}".devenv;
})
supportedSystems);
};
}