forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
207 lines (191 loc) · 5.69 KB
/
flake.nix
File metadata and controls
207 lines (191 loc) · 5.69 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{
description = "devenv.sh - Fast, Declarative, Reproducible, and Composable Developer Environments";
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM=";
extra-substituters = "https://devenv.cachix.org https://cachix.cachix.org";
};
# this needs to be rolling so we're testing what most devs are using
inputs.nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
inputs.git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
};
};
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs = {
nixpkgs-lib.follows = "nixpkgs";
};
};
inputs.nix = {
url = "github:cachix/nix/devenv-2.30.6";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
flake-parts.follows = "flake-parts";
git-hooks-nix.follows = "git-hooks";
nixpkgs-23-11.follows = "";
nixpkgs-regression.follows = "";
};
};
inputs.cachix = {
url = "github:cachix/cachix/latest";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
git-hooks.follows = "git-hooks";
devenv.follows = "";
};
};
outputs =
{ self
, nixpkgs
, git-hooks
, nix
, ...
}@inputs:
let
systems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
packages = forAllSystems (
system:
let
overlays = [
(final: prev: {
inherit (inputs.cachix.packages.${system}) cachix;
devenv-nix = inputs.nix.packages.${system}.nix-cli;
})
];
pkgs = import nixpkgs { inherit overlays system; };
workspace = pkgs.callPackage ./workspace.nix { };
in
{
inherit (workspace.crates) devenv devenv-tasks devenv-tasks-fast-build;
default = self.packages.${system}.devenv;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
devenv-image = import ./containers/devenv/image.nix {
inherit pkgs;
inherit (self.packages.${system}) devenv;
};
}
);
modules = ./src/modules;
templates =
let
flake-parts = {
path = ./templates/flake-parts;
description = "A flake with flake-parts, direnv and devenv.";
welcomeText = ''
# `.devenv` should be added to `.gitignore`
```sh
echo .devenv >> .gitignore
```
'';
};
flake = {
path = ./templates/flake;
description = "A direnv supported Nix flake with devenv integration.";
welcomeText = ''
# `.devenv` should be added to `.gitignore`
```sh
echo .devenv >> .gitignore
```
'';
};
terraform = {
path = ./templates/terraform;
description = "A Terraform Nix flake with devenv integration.";
welcomeText = ''
# `.devenv` should be added to `.gitignore`
```sh
echo .devenv >> .gitignore
```
'';
};
in
{
inherit flake flake-parts terraform;
simple = flake; # Backwards compatibility
default = self.templates.flake;
};
flakeModule = self.flakeModules.default; # Backwards compatibility
flakeModules = {
default = import ./flake-module.nix self;
readDevenvRoot =
{ inputs, lib, ... }:
{
config =
let
devenvRootFileContent =
if inputs ? devenv-root then builtins.readFile inputs.devenv-root.outPath else "";
in
lib.mkIf (devenvRootFileContent != "") {
devenv.root = devenvRootFileContent;
};
};
};
lib = {
mkConfig = args: (self.lib.mkEval args).config;
mkEval =
args@{ pkgs
, inputs
, modules
, lib ? pkgs.lib
,
}:
let
# TODO: deprecate default git-hooks input
defaultInputs = { inherit git-hooks; };
finalInputs = defaultInputs // inputs;
specialArgs = finalInputs // {
inputs = finalInputs;
};
modules = [
(self.modules + /top-level.nix)
(
{ config, ... }:
{
# Configure overlays
_module.args.pkgs = pkgs.appendOverlays config.overlays;
# Enable the flakes integration
devenv.flakesIntegration = true;
# Disable CLI version checks
devenv.warnOnNewVersion = false;
}
)
]
++ args.modules;
project = lib.evalModules { inherit modules specialArgs; };
in
project;
mkShell =
args:
let
config = self.lib.mkConfig args;
in
config.shell
// {
inherit config;
ci = config.ciDerivation;
};
};
overlays.default = final: prev: {
devenv = self.packages.${prev.system}.default;
};
};
}