-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
87 lines (84 loc) · 2.67 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
{
description = "";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachSystem [ flake-utils.lib.system.x86_64-linux ] (system:
let
pkgs = import nixpkgs {
inherit system;
};
l = builtins // pkgs.lib;
inverseInclude = list: (l.filter (fileName: l.any (e: e != fileName) list) (l.attrNames (l.readDir ./.)));
in
{
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];
packages = with pkgs; [
nodejs-16_x
mdbook
statix
nodePackages.cspell
nodePackages.markdownlint-cli
];
shellHook = ''
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
cspell = {
enable = true;
entry = "${pkgs.nodePackages.cspell}/bin/cspell --words-only";
types = [ "markdown" ];
};
markdownlint.enable = true;
};
};
};
packages = {
docs = pkgs.runCommand
"static-docs"
{ nativeBuildInputs = [ pkgs.mdbook ]; }
''
mdbook build -d $out ${./.}/docs
echo typednix.dev > $out/CNAME
'';
nix-types = pkgs.rustPlatform.buildRustPackage {
pname = "nix-types";
version = "0.1.0";
src = ./parser;
cargoLock = {
lockFile = ./parser/Cargo.lock;
outputHashes = {
# "arenatree-0.1.1" = "";
# "rnix-0.4.1" = "";
};
};
nativeBuildInputs = [ pkgs.pkg-config ];
};
# currently use nixpkgs/lib as test source
parsed = pkgs.stdenv.mkDerivation {
name = "test-data";
src = nixpkgs;
nativeBuildInputs = [ self.packages.${system}.nix-types ];
buildPhase = ''
echo "running nix metadata collect in nixpkgs/lib"
${self.packages.${system}.nix-types}/bin/nix-types --dir ./lib
'';
installPhase = ''
cat data.json > $out
'';
};
default = self.packages.${system}.parsed;
};
});
}