forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
98 lines (91 loc) · 2.85 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
{
description = "devenv - Developer Environments";
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "flake-compat";
};
};
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.nix = {
url = "github:domenkozar/nix/relaxed-flakes";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, pre-commit-hooks, nix, ... }:
let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
mkPackage = pkgs: import ./src/devenv.nix { inherit pkgs nix; };
mkDocOptions = pkgs:
let
eval = pkgs.lib.evalModules {
modules = [
./src/modules/top-level.nix
{ devenv.warnOnNewVersion = false; }
];
specialArgs = { inherit pre-commit-hooks pkgs; };
};
options = pkgs.nixosOptionsDoc {
options = builtins.removeAttrs eval.options [ "_module" ];
};
in
options.optionsCommonMark;
in
{
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
devenv = mkPackage pkgs;
devenv-docs-options = mkDocOptions pkgs;
});
modules = ./src/modules;
defaultPackage = forAllSystems (system: self.packages.${system}.devenv);
templates =
let
simple = {
path = ./templates/simple;
description = "A direnv supported Nix flake with devenv integration.";
};
in
{
inherit simple;
default = simple;
};
lib = {
mkConfig = { pkgs, inputs, modules }:
let
moduleInputs = { inherit pre-commit-hooks; } // inputs;
project = inputs.nixpkgs.lib.evalModules {
specialArgs = moduleInputs // {
inherit pkgs;
inputs = moduleInputs;
};
modules = [
(self.modules + /top-level.nix)
{
packages = [ self.packages.${pkgs.system}.devenv ];
devenv.warnOnNewVersion = false;
}
] ++ modules;
};
in
project.config;
mkShell = args:
let
config = self.lib.mkConfig args;
in
config.shell // {
ci = config.ciDerivation;
};
};
};
}