generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 29
/
flake.nix
126 lines (107 loc) · 4.23 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
116
117
118
119
120
121
122
123
124
125
126
{
description = "A general code formatter based on tree-sitter.";
nixConfig = {
extra-substituters = [
"https://tweag-topiary.cachix.org"
];
extra-trusted-public-keys = [
"tweag-topiary.cachix.org-1:8TKqya43LAfj4qNHnljLpuBnxAY/YwEBfzo3kzXxNY0="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay.url = "github:oxalica/rust-overlay";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
tree-sitter-nickel-input = {
url = "github:nickel-lang/tree-sitter-nickel";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = inputs:
with inputs;
flake-utils.lib.eachDefaultSystem (
system:
let
wasm-bindgen-cli-overlay = final: prev:
let
cargoLock = builtins.fromTOML (builtins.readFile ./Cargo.lock);
wasmBindgenCargoVersions = builtins.map ({ version, ... }: version) (builtins.filter ({ name, ... }: name == "wasm-bindgen") cargoLock.package);
wasmBindgenVersion = assert builtins.length wasmBindgenCargoVersions == 1; builtins.elemAt wasmBindgenCargoVersions 0;
in
{
wasm-bindgen-cli = prev.wasm-bindgen-cli.override {
version = wasmBindgenVersion;
hash = "sha256-f/RK6s12ItqKJWJlA2WtOXtwX4Y0qa8bq/JHlLTAS3c=";
cargoHash = "sha256-3vxVI0BhNz/9m59b+P2YEIrwGwlp7K3pyPKt4VqQuHE=";
};
};
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default wasm-bindgen-cli-overlay ];
};
craneLib = crane.mkLib pkgs;
tree-sitter-nickel = tree-sitter-nickel-input.packages.${system}.default;
topiaryPkgs = pkgs.callPackage ./default.nix {
inherit advisory-db crane rust-overlay nix-filter craneLib tree-sitter-nickel;
};
binPkgs = pkgs.callPackage ./bin/default.nix { };
in
{
packages = rec {
inherit (topiaryPkgs)
topiary-playground
topiary-queries
client-app;
topiary-cli = topiaryPkgs.topiary-cli { };
topiary-cli-nix = topiaryPkgs.topiary-cli { nixSupport = true; };
inherit (binPkgs)
# FIXME: Broken
# generate-coverage
playground
update-wasm-app
update-wasm-grammars
verify-documented-usage;
default = topiary-cli;
};
checks = {
inherit (topiaryPkgs) clippy clippy-wasm fmt topiary-core topiary-playground audit benchmark;
topiary-cli = topiaryPkgs.topiary-cli { };
## Check that the `lib.pre-commit-hook` output builds/evaluates
## correctly. `deepSeq e1 e2` evaluates `e1` strictly in depth before
## returning `e2`. We use this trick because checks need to be
## derivations, which `lib.pre-commit-hook` is not.
pre-commit-hook = builtins.deepSeq self.lib.${system}.pre-commit-hook pkgs.hello;
};
devShells =
let
checksLight = {
inherit (topiaryPkgs) clippy fmt topiary-core;
topiary-cli = topiaryPkgs.topiary-cli { };
};
in
{
default = pkgs.callPackage ./shell.nix { checks = self.checks.${system}; inherit craneLib; inherit binPkgs; };
light = pkgs.callPackage ./shell.nix { checks = checksLight; inherit craneLib; inherit binPkgs; optionals = false; };
wasm = pkgs.callPackage ./shell.nix { checks = self.checks.${system}; craneLib = topiaryPkgs.passtru.craneLibWasm; inherit binPkgs; };
};
## For easy use in https://github.com/cachix/pre-commit-hooks.nix
lib.pre-commit-hook = {
enable = true;
name = "topiary";
description = "A general code formatter based on tree-sitter.";
entry = "${topiaryPkgs.topiary-cli {}}/bin/topiary fmt";
types = [ "text" ];
};
}
);
}