fork/helix
git clone https://git.julia.blue/fork/helix
12523cd1
25.07
1{ 2lib , 3rustPlatform , 4callPackage , 5runCommand , 6installShellFiles , 7git , 8gitRev ? null , 9grammarOverlays ? [], 10includeGrammarIf ? _ :true , 11} : let 12fs = lib . fileset ; 13 14src = 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# Next we actually need to build the grammars and the runtime directory 29# that they reside in. It is built by calling the derivation in the 30# grammars.nix file, then taking the runtime directory in the git repo 31# and hooking symlinks up to it. 32grammars = callPackage ./grammars.nix { inherit grammarOverlays includeGrammarIf ;}; 33runtimeDir = runCommand "helix-runtime" {} '' 34mkdir -p $ out 35ln -s ${ ./runtime } /* $ out 36rm -r $ out /grammars 37ln -s ${ grammars } $ out /grammars 38'' ; 39in 40rustPlatform . buildRustPackage ( self: { 41cargoLock = { 42lockFile = ./Cargo.lock ; 43# This is not allowed in nixpkgs but is very convenient here: it allows us to 44# avoid specifying `outputHashes` here for any git dependencies we might take 45# on temporarily. 46allowBuiltinFetchGit = true ; 47}; 48 49nativeBuildInputs = [ 50installShellFiles 51git 52]; 53 54buildType = "release" ; 55 56name = with builtins ; ( fromTOML ( readFile ./helix-term/Cargo.toml )). package . name ; 57src = fs . toSource { 58root = ./. ; 59fileset = src ; 60}; 61 62# Helix attempts to reach out to the network and get the grammars. Nix doesn't allow this. 63HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1" ; 64 65# So Helix knows what rev it is. 66HELIX_NIX_BUILD_REV = gitRev ; 67 68doCheck = false ; 69strictDeps = true ; 70 71# Sets the Helix runtime dir to the grammars 72env . HELIX_DEFAULT_RUNTIME = " ${ runtimeDir } " ; 73 74# Get all the application stuff in the output directory. 75postInstall = '' 76mkdir -p $ out /lib 77installShellCompletion ${ ./contrib/completion } /hx.{bash,fish,zsh} 78mkdir -p $ out /share/{applications,icons/hicolor/{256x256,scalable}/apps} 79cp ${ ./contrib/Helix.desktop } $ out /share/applications/Helix.desktop 80cp ${ ./logo.svg } $ out /share/icons/hicolor/scalable/apps/helix.svg 81cp ${ ./contrib/helix.png } $ out /share/icons/hicolor/256x256/apps/helix.png 82'' ; 83 84meta . mainProgram = "hx" ; 85})