-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
130 lines (117 loc) · 3.07 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
127
128
129
130
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
tree-sitter = {
url = "github:viperML/tree-sitter";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
...
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
inherit (nixpkgs) lib;
fs = lib.fileset;
r = ./.;
src = fs.toSource {
root = r;
fileset =
fs.intersection
(fs.fromSource (lib.sources.cleanSource r))
(fs.unions [
./src
./public
./neohome-rs
(fs.fileFilter (file: file.hasExt "ts") r)
(fs.fileFilter (file: file.hasExt "json") r)
]);
};
package-json = builtins.fromJSON (builtins.readFile ./package.json);
grammarPath = pkgs.linkFarmFromDrvs "grammar-bundle" (builtins.attrValues (lib.getAttrs (map (n: "tree-sitter-${n}") [
"nix"
"rust"
"bash"
"ini"
"toml"
"yaml"
"json"
"astro"
"html"
"javascript"
"typescript"
"css"
"haskell"
"glsl"
])
inputs.tree-sitter.legacyPackages.${system}.grammars.all));
in {
packages.${system} = {
default = with pkgs;
buildNpmPackage {
pname = package-json.name;
version = package-json.version;
inherit src;
npmDeps = importNpmLock {
npmRoot = src;
};
npmConfigHook = importNpmLock.npmConfigHook;
# preBuild = ''
# pushd neohome-rs
# npm run build
# popd
# '';
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./neohome-rs/Cargo.lock;
outputHashes = {
"tree-sitter-dynamic-0.1.0" = "sha256-q2ykb8p8OhSVHysnVeMgFakv6xtbS92CpNVaNn2jXU0";
};
};
cargoRoot = "neohome-rs";
nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustc
cargo
];
preInstall = ''
rm -rf $cargoRoot/target
'';
env =
{
ASTRO_TELEMETRY_DISABLED = true;
TS_GRAMMAR_PATH = grammarPath;
}
// (lib.optionalAttrs (builtins.hasAttr "rev" self) {
GIT_COMMIT = self.rev;
});
};
};
devShells.${system}.default = with pkgs;
mkShell {
packages = [
cargo
rustc
rust-analyzer-unwrapped
rustfmt
nodejs
yarn
tailwindcss
# nodePackages.wrangler
nodePackages."@astrojs/language-server"
nodePackages.typescript-language-server
vscode-langservers-extracted
tailwindcss-language-server
ltex-ls
python3.pkgs.libxml2.bin
(python3.withPackages (pp: [
pp.pyyaml
pp.libxml2
]))
];
env.RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
env.TS_GRAMMAR_PATH = grammarPath;
};
};
}