-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelix.nix
73 lines (62 loc) · 2.18 KB
/
helix.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
{ fetchFromGitHub, lib, rustPlatform, makeWrapper }:
# a derivation of helix based on my fork
let
src = fetchFromGitHub {
owner = "the-mikedavis";
repo = "helix";
rev = "4da7aa0441be8dd7df775cdf3c39be78f7cc7ccd";
# when building from a new rev, this value clashes first with lib.fakeSha256, then the
# cargoSha256 after that
#
sha256 = "sha256-o021YCSXiGwZH9qZVLICumZhd8tfG5Kry4GWkME7QiU=";
# sha256 = lib.fakeSha256;
};
config = (builtins.fromTOML
(builtins.readFile "${builtins.toPath src}/languages.toml")).language;
gitGrammars = builtins.filter (lang:
builtins.hasAttr "grammar" lang && builtins.hasAttr "source" lang.grammar
&& builtins.hasAttr "git" lang.grammar.source) config;
grammars = builtins.map (lang: {
name = lang.name;
source = fetchGit {
url = lang.grammar.source.git;
rev = lang.grammar.source.rev;
allRefs = true;
};
}) gitGrammars;
grammarLinks = builtins.foldl' (acc: grammar: ''
ln -s ${
builtins.toPath grammar.source
} $out/lib/runtime/grammars/sources/${grammar.name}
${acc}'') "\n" grammars;
in rustPlatform.buildRustPackage rec {
inherit src;
pname = "helix";
version = "0.6.0.3-tmd";
cargoSha256 = "sha256-TzMGITvJ3vWiwtyRu+s1J7v88QskTx1NV1W5yA9Bgww=";
# cargoSha256 = lib.fakeSha256;
nativeBuildInputs = [ makeWrapper ];
postInstall = ''
mkdir -p $out/lib
cp -r runtime $out/lib
mkdir -p $out/lib/runtime/grammars/sources
${grammarLinks}
HELIX_RUNTIME=$out/lib/runtime $out/bin/hx --build-grammars
'';
postFixup = ''
wrapProgram $out/bin/hx --set HELIX_RUNTIME $out/lib/runtime
'';
# HACK:
# Turn off tests - we need at least the rust grammar built to run tests
# successfully after #1659. This could be fixed in theory: nix can build
# the grammars just fine itself, and that might even make the postInstall
# step much cleaner. So just build the grammars in a separate derivation
# and then drop them in in the postUnpack phase.
doCheck = false;
meta = with lib; {
description = "A post-modern modal text editor";
homepage = "https://helix-editor.com";
license = licenses.mpl20;
mainProgram = "hx";
};
}