-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
76 lines (69 loc) · 2.04 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
{
inputs = {
# Update lockfile with `nix flake lock --update-input <input>`
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
devenv,
...
} @ inputs: let
system = builtins.currentSystem;
pkgs = nixpkgs.legacyPackages.${system};
node = pkgs.nodejs_23;
in {
devShell.${system} = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = [
node
pkgs.nodePackages.yarn
];
scripts = {
publish.exec = ''
nix build .#dist --impure -L
(cd result; npm publish --access public)
'';
snippets = {
exec = ''
const fs = require('fs');
const [,, filename] = process.argv;
const contents = fs.readFileSync(filename).toString();
process.stdout.write(contents.replace(/\$embed: (.+)\$/g, (_, snippet) => {
return fs.readFileSync(snippet).toString().trim();
}));
'';
package = node;
binary = "node";
};
};
pre-commit.hooks = {
alejandra.enable = true;
statix = {
enable = true;
pass_filenames = true;
# https://github.com/oppiliappan/statix/issues/69
entry = "bash -c 'echo \"$@\" | xargs -n1 ${pkgs.statix}/bin/statix check'";
};
biome = {
package = pkgs.biome;
enable = true;
entry = "${pkgs.biome}/bin/biome check --write --no-errors-on-unmatched --diagnostic-level=error --verbose";
};
typos = {
enable = true;
entry = "${pkgs.typos}/bin/typos --force-exclude --exclude .git/*";
};
};
}
];
};
dist = import ./nix/dist.nix pkgs;
};
}