|
1 |
| -{ config, pkgs, lib, bootstrapPkgs ? null, ... }: |
| 1 | +{ |
| 2 | + config, |
| 3 | + pkgs, |
| 4 | + lib, |
| 5 | + bootstrapPkgs ? null, |
| 6 | + ... |
| 7 | +}: |
2 | 8 | let
|
3 | 9 | types = lib.types;
|
4 | 10 | # Returns a list of all the entries in a folder
|
5 |
| - listEntries = path: |
6 |
| - map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path)); |
| 11 | + listEntries = path: map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path)); |
7 | 12 |
|
8 |
| - drvOrPackageToPaths = drvOrPackage: |
| 13 | + drvOrPackageToPaths = |
| 14 | + drvOrPackage: |
9 | 15 | if drvOrPackage ? outputs then
|
10 | 16 | builtins.map (output: drvOrPackage.${output}) drvOrPackage.outputs
|
11 | 17 | else
|
|
16 | 22 | ignoreCollisions = true;
|
17 | 23 | };
|
18 | 24 |
|
19 |
| - failedAssertions = builtins.map (x: x.message) (builtins.filter (x: !x.assertion) config.assertions); |
| 25 | + failedAssertions = builtins.map (x: x.message) ( |
| 26 | + builtins.filter (x: !x.assertion) config.assertions |
| 27 | + ); |
20 | 28 |
|
21 | 29 | performAssertions =
|
22 | 30 | let
|
23 |
| - formatAssertionMessage = message: |
| 31 | + formatAssertionMessage = |
| 32 | + message: |
24 | 33 | let
|
25 | 34 | lines = lib.splitString "\n" message;
|
26 | 35 | in
|
27 | 36 | "- ${lib.concatStringsSep "\n " lines}";
|
28 | 37 | in
|
29 |
| - if failedAssertions != [ ] |
30 |
| - then |
| 38 | + if failedAssertions != [ ] then |
31 | 39 | throw ''
|
32 | 40 | Failed assertions:
|
33 | 41 | ${lib.concatStringsSep "\n" (builtins.map formatAssertionMessage failedAssertions)}
|
34 | 42 | ''
|
35 |
| - else lib.trivial.showWarnings config.warnings; |
| 43 | + else |
| 44 | + lib.trivial.showWarnings config.warnings; |
| 45 | + templateType = types.submodule ( |
| 46 | + { name, config, ... }: |
| 47 | + { |
| 48 | + options = { |
| 49 | + path = lib.mkOption { |
| 50 | + type = lib.types.path; |
| 51 | + }; |
| 52 | + description = lib.mkOption { |
| 53 | + type = types.str; |
| 54 | + description = "description"; |
| 55 | + }; |
| 56 | + welcomeText = lib.mkOption { |
| 57 | + type = types.str; |
| 58 | + description = "description"; |
| 59 | + }; |
| 60 | + }; |
| 61 | + } |
| 62 | + ); |
36 | 63 | in
|
37 | 64 | {
|
38 | 65 | options = {
|
|
89 | 116 |
|
90 | 117 | # Remove the default apple-sdk on macOS.
|
91 | 118 | # Allow users to specify an optional SDK in `apple.sdk`.
|
92 |
| - apply = stdenv: |
93 |
| - if stdenv.isDarwin |
94 |
| - then |
95 |
| - stdenv.override |
96 |
| - (prev: { |
97 |
| - extraBuildInputs = |
98 |
| - builtins.filter (x: !lib.hasPrefix "apple-sdk" x.pname) prev.extraBuildInputs; |
99 |
| - }) |
100 |
| - else stdenv; |
| 119 | + apply = |
| 120 | + stdenv: |
| 121 | + if stdenv.isDarwin then |
| 122 | + stdenv.override (prev: { |
| 123 | + extraBuildInputs = builtins.filter (x: !lib.hasPrefix "apple-sdk" x.pname) prev.extraBuildInputs; |
| 124 | + }) |
| 125 | + else |
| 126 | + stdenv; |
101 | 127 |
|
102 | 128 | };
|
103 | 129 |
|
|
170 | 196 | type = types.listOf types.unspecified;
|
171 | 197 | internal = true;
|
172 | 198 | default = [ ];
|
173 |
| - example = [{ assertion = false; message = "you can't enable this for that reason"; }]; |
| 199 | + example = [ |
| 200 | + { |
| 201 | + assertion = false; |
| 202 | + message = "you can't enable this for that reason"; |
| 203 | + } |
| 204 | + ]; |
174 | 205 | description = ''
|
175 | 206 | This option allows modules to express conditions that must
|
176 | 207 | hold for the evaluation of the configuration to succeed,
|
|
201 | 232 | '';
|
202 | 233 | };
|
203 | 234 |
|
| 235 | + templates = lib.mkOption { |
| 236 | + type = lib.types.attrsOf templateType; |
| 237 | + description = "A set of templates."; |
| 238 | + }; |
| 239 | + |
204 | 240 | devenv = {
|
205 | 241 | root = lib.mkOption {
|
206 | 242 | type = types.str;
|
|
243 | 279 | xdg = builtins.getEnv "XDG_RUNTIME_DIR";
|
244 | 280 | tmp = builtins.getEnv "TMPDIR";
|
245 | 281 | in
|
246 |
| - if xdg != "" then xdg else if tmp != "" then tmp else "/tmp"; |
| 282 | + if xdg != "" then |
| 283 | + xdg |
| 284 | + else if tmp != "" then |
| 285 | + tmp |
| 286 | + else |
| 287 | + "/tmp"; |
247 | 288 | };
|
248 | 289 |
|
249 | 290 | profile = lib.mkOption {
|
|
253 | 294 | };
|
254 | 295 | };
|
255 | 296 |
|
256 |
| - imports = [ |
257 |
| - ./info.nix |
258 |
| - ./outputs.nix |
259 |
| - ./files.nix |
260 |
| - ./processes.nix |
261 |
| - ./outputs.nix |
262 |
| - ./scripts.nix |
263 |
| - ./update-check.nix |
264 |
| - ./containers.nix |
265 |
| - ./debug.nix |
266 |
| - ./lib.nix |
267 |
| - ./tests.nix |
268 |
| - ./cachix.nix |
269 |
| - ./tasks.nix |
270 |
| - ] |
271 |
| - ++ (listEntries ./languages) |
272 |
| - ++ (listEntries ./services) |
273 |
| - ++ (listEntries ./integrations) |
274 |
| - ++ (listEntries ./process-managers) |
275 |
| - ; |
| 297 | + imports = |
| 298 | + [ |
| 299 | + ./info.nix |
| 300 | + ./outputs.nix |
| 301 | + ./files.nix |
| 302 | + ./processes.nix |
| 303 | + ./outputs.nix |
| 304 | + ./scripts.nix |
| 305 | + ./update-check.nix |
| 306 | + ./containers.nix |
| 307 | + ./debug.nix |
| 308 | + ./lib.nix |
| 309 | + ./tests.nix |
| 310 | + ./cachix.nix |
| 311 | + ./tasks.nix |
| 312 | + ] |
| 313 | + ++ (listEntries ./languages) |
| 314 | + ++ (listEntries ./services) |
| 315 | + ++ (listEntries ./integrations) |
| 316 | + ++ (listEntries ./process-managers); |
276 | 317 |
|
277 | 318 | config = {
|
278 | 319 | assertions = [
|
|
285 | 326 | '';
|
286 | 327 | }
|
287 | 328 | {
|
288 |
| - assertion = config.devenv.flakesIntegration || config.overlays == [ ] || lib.versionAtLeast config.devenv.cliVersion "1.4.2"; |
| 329 | + assertion = |
| 330 | + config.devenv.flakesIntegration |
| 331 | + || config.overlays == [ ] |
| 332 | + || lib.versionAtLeast config.devenv.cliVersion "1.4.2"; |
289 | 333 | message = ''
|
290 | 334 | Using overlays requires devenv 1.4.2 or higher, while your current version is ${config.devenv.cliVersion}.
|
291 | 335 | '';
|
|
305 | 349 | packages = [
|
306 | 350 | # needed to make sure we can load libs
|
307 | 351 | pkgs.pkg-config
|
308 |
| - ] |
309 |
| - ++ lib.optional (config.apple.sdk != null) config.apple.sdk; |
| 352 | + ] ++ lib.optional (config.apple.sdk != null) config.apple.sdk; |
310 | 353 |
|
311 | 354 | enterShell = lib.mkBefore ''
|
312 | 355 | export PS1="\[\e[0;34m\](devenv)\[\e[0m\] ''${PS1-}"
|
|
357 | 400 | nativeBuildInputs = partitionedPkgs.wrong;
|
358 | 401 | in
|
359 | 402 | performAssertions (
|
360 |
| - (pkgs.mkShell.override { stdenv = config.stdenv; }) ({ |
361 |
| - name = "devenv-shell"; |
362 |
| - hardeningDisable = config.hardeningDisable; |
363 |
| - inherit buildInputs nativeBuildInputs; |
364 |
| - shellHook = '' |
365 |
| - ${lib.optionalString config.devenv.debug "set -x"} |
366 |
| - ${config.enterShell} |
367 |
| - ''; |
368 |
| - } // config.env) |
| 403 | + (pkgs.mkShell.override { stdenv = config.stdenv; }) ( |
| 404 | + { |
| 405 | + name = "devenv-shell"; |
| 406 | + hardeningDisable = config.hardeningDisable; |
| 407 | + inherit buildInputs nativeBuildInputs; |
| 408 | + shellHook = '' |
| 409 | + ${lib.optionalString config.devenv.debug "set -x"} |
| 410 | + ${config.enterShell} |
| 411 | + ''; |
| 412 | + } |
| 413 | + // config.env |
| 414 | + ) |
369 | 415 | );
|
370 | 416 |
|
371 | 417 | infoSections."env" = lib.mapAttrsToList (name: value: "${name}: ${toString value}") config.env;
|
372 |
| - infoSections."packages" = builtins.map (package: package.name) (builtins.filter (package: !(builtins.elem package.name (builtins.attrNames config.scripts))) config.packages); |
| 418 | + infoSections."packages" = builtins.map (package: package.name) ( |
| 419 | + builtins.filter ( |
| 420 | + package: !(builtins.elem package.name (builtins.attrNames config.scripts)) |
| 421 | + ) config.packages |
| 422 | + ); |
373 | 423 |
|
374 | 424 | _module.args.pkgs = bootstrapPkgs.appendOverlays config.overlays;
|
375 | 425 |
|
|
0 commit comments