| 1 |
{ |
| 2 |
lib, |
| 3 |
rustPlatform, |
| 4 |
callPackage, |
| 5 |
runCommand, |
| 6 |
installShellFiles, |
| 7 |
git, |
| 8 |
gitRev ? null, |
| 9 |
grammarOverlays ? [], |
| 10 |
includeGrammarIf ? _: true, |
| 11 |
}: let |
| 12 |
fs = lib.fileset; |
| 13 |
|
| 14 |
src = fs.difference (fs.gitTracked ./.) (fs.unions [ |
| 15 |
./.envrc |
| 16 |
./rustfmt.toml |
| 17 |
./screenshot.png |
| 18 |
./book |
| 19 |
./docs |
| 20 |
./runtime |
| 21 |
./flake.lock |
| 22 |
(fs.fileFilter (file: lib.strings.hasInfix ".git" file.name) ./.) |
| 23 |
(fs.fileFilter (file: file.hasExt "svg") ./.) |
| 24 |
(fs.fileFilter (file: file.hasExt "md") ./.) |
| 25 |
(fs.fileFilter (file: file.hasExt "nix") ./.) |
| 26 |
]); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
grammars = callPackage ./grammars.nix {inherit grammarOverlays includeGrammarIf;}; |
| 33 |
runtimeDir = runCommand "helix-runtime" {} '' |
| 34 |
mkdir -p $out |
| 35 |
ln -s ${./runtime}/* $out |
| 36 |
rm -r $out/grammars |
| 37 |
ln -s ${grammars} $out/grammars |
| 38 |
''; |
| 39 |
in |
| 40 |
rustPlatform.buildRustPackage (self: { |
| 41 |
cargoLock = { |
| 42 |
lockFile = ./Cargo.lock; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
allowBuiltinFetchGit = true; |
| 47 |
}; |
| 48 |
|
| 49 |
propagatedBuildInputs = [ runtimeDir ]; |
| 50 |
|
| 51 |
nativeBuildInputs = [ |
| 52 |
installShellFiles |
| 53 |
git |
| 54 |
]; |
| 55 |
|
| 56 |
buildType = "release"; |
| 57 |
|
| 58 |
name = with builtins; (fromTOML (readFile ./helix-term/Cargo.toml)).package.name; |
| 59 |
src = fs.toSource { |
| 60 |
root = ./.; |
| 61 |
fileset = src; |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; |
| 66 |
|
| 67 |
|
| 68 |
HELIX_NIX_BUILD_REV = gitRev; |
| 69 |
|
| 70 |
doCheck = false; |
| 71 |
strictDeps = true; |
| 72 |
|
| 73 |
|
| 74 |
env.HELIX_DEFAULT_RUNTIME = "${runtimeDir}"; |
| 75 |
|
| 76 |
|
| 77 |
postInstall = '' |
| 78 |
mkdir -p $out/lib |
| 79 |
installShellCompletion ${./contrib/completion}/hx.{bash,fish,zsh} |
| 80 |
mkdir -p $out/share/{applications,icons/hicolor/{256x256,scalable}/apps} |
| 81 |
cp ${./contrib/Helix.desktop} $out/share/applications/Helix.desktop |
| 82 |
cp ${./logo.svg} $out/share/icons/hicolor/scalable/apps/helix.svg |
| 83 |
cp ${./contrib/helix.png} $out/share/icons/hicolor/256x256/apps/helix.png |
| 84 |
''; |
| 85 |
|
| 86 |
meta.mainProgram = "hx"; |
| 87 |
}) |