-
Notifications
You must be signed in to change notification settings - Fork 89
/
flake.nix
115 lines (105 loc) · 2.92 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
{
description = "devshell";
# To update all inputs:
# nix flake update
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs }:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"riscv64-linux"
"x86_64-darwin"
"x86_64-linux"
];
eachSystem =
f:
nixpkgs.lib.genAttrs systems (
system:
f rec {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
devshell = import ./. { nixpkgs = pkgs; };
}
);
in
{
packages = eachSystem (
{
pkgs,
system,
devshell,
}:
{
docs = pkgs.writeShellApplication {
name = "docs";
meta.description = ''Run mdBook server at http://localhost:3000'';
runtimeInputs = [ pkgs.mdbook ];
text = ''
cd docs
cp ${devshell.modules-docs.markdown} src/modules_schema.md
mdbook serve
'';
};
bench = pkgs.writeShellApplication {
name = "benchmark";
meta.description = ''Run benchmark'';
runtimeInputs = [ pkgs.hyperfine ];
text = ''
cd benchmark
hyperfine -w 3 \
'nix-instantiate ../shell.nix' \
'nix-instantiate ./devshell-nix.nix' \
'nix-instantiate ./devshell-toml.nix' \
'nix-instantiate ./nixpkgs-mkshell.nix'
'';
};
# expose devshell as an executable package
default = self.devShells.${system}.default;
}
);
devShells = eachSystem (
{ devshell, ... }:
{
default = devshell.fromTOML ./devshell.toml;
}
);
legacyPackages = eachSystem (
{ system, pkgs, ... }:
import self {
inherit system;
inputs = null;
nixpkgs = pkgs;
}
);
checks = eachSystem (
{ pkgs, ... }:
with pkgs.lib;
pipe (import ./tests { inherit pkgs; }) [
(collect isDerivation)
(map (x: {
name = x.name or x.pname;
value = x;
}))
listToAttrs
]
);
formatter = eachSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
# Import this overlay into your instance of nixpkgs
overlays.default = import ./overlay.nix;
templates = rec {
toml = {
path = ./templates/toml;
description = "nix flake new my-project -t github:numtide/devshell";
};
flake-parts = {
path = ./templates/flake-parts;
description = "nix flake new my-project -t github:numtide/devshell#flake-parts";
};
default = toml;
};
lib.importTOML = import ./nix/importTOML.nix;
flakeModule = ./flake-module.nix;
};
}