-
Notifications
You must be signed in to change notification settings - Fork 0
/
.devenv.flake.nix
55 lines (54 loc) · 2.19 KB
/
.devenv.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
{
inputs = {
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devenv.url = "github:cachix/devenv?dir=src/modules";
} // (if builtins.pathExists ./.devenv/devenv.json
then (builtins.fromJSON (builtins.readFile ./.devenv/devenv.json)).inputs
else {});
outputs = { nixpkgs, ... }@inputs:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = pkgs.lib;
devenv = if builtins.pathExists ./.devenv/devenv.json
then builtins.fromJSON (builtins.readFile ./.devenv/devenv.json)
else {};
toModule = path:
if lib.hasPrefix "./" path
then ./. + (builtins.substring 1 255 path) + "/devenv.nix"
else if lib.hasPrefix "../" path
then throw "devenv: ../ is not supported for imports"
else let
paths = lib.splitString "/" path;
name = builtins.head paths;
input = inputs.${name} or (throw "Unknown input ${name}");
subpath = "/${lib.concatStringsSep "/" (builtins.tail paths)}";
devenvpath = "${input}/" + subpath + "/devenv.nix";
in if (!devenv.inputs.${name}.flake or true) && builtins.pathExists devenvpath
then devenvpath
else throw (devenvpath + " file does not exist for input ${name}.");
project = pkgs.lib.evalModules {
specialArgs = inputs // { inherit inputs pkgs; };
modules = [
(inputs.devenv.modules + /top-level.nix)
{ devenv.cliVersion = "0.5"; }
] ++ (map toModule (devenv.imports or [])) ++ [
./devenv.nix
(devenv.devenv or {})
(if builtins.pathExists ./devenv.local.nix then ./devenv.local.nix else {})
];
};
config = project.config;
options = pkgs.nixosOptionsDoc {
options = builtins.removeAttrs project.options [ "_module" ];
};
in {
packages."x86_64-linux" = {
optionsJSON = options.optionsJSON;
inherit (config) info procfileScript procfileEnv procfile;
ci = config.ciDerivation;
};
devShell."x86_64-linux" = config.shell;
};
}