fork/helix
git clone https://git.julia.blue/fork/helix
b6ccbddc
master
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 49propagatedBuildInputs = [ runtimeDir ]; 5051 nativeBuildInputs = [ 52installShellFiles 53git 54]; 55 56buildType = "release" ; 57 58name = with builtins ; ( fromTOML ( readFile ./helix-term/Cargo.toml )). package . name ; 59src = fs . toSource { 60root = ./. ; 61fileset = src ; 62}; 63 64# Helix attempts to reach out to the network and get the grammars. Nix doesn't allow this. 65HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1" ; 66 67# So Helix knows what rev it is. 68HELIX_NIX_BUILD_REV = gitRev ; 69 70doCheck = false ; 71strictDeps = true ; 72 73# Sets the Helix runtime dir to the grammars 74env . HELIX_DEFAULT_RUNTIME = " ${ runtimeDir } " ; 75 76# Get all the application stuff in the output directory. 77postInstall = '' 78mkdir -p $ out /lib 79installShellCompletion ${ ./contrib/completion } /hx.{bash,fish,zsh} 80mkdir -p $ out /share/{applications,icons/hicolor/{256x256,scalable}/apps} 81cp ${ ./contrib/Helix.desktop } $ out /share/applications/Helix.desktop 82cp ${ ./logo.svg } $ out /share/icons/hicolor/scalable/apps/helix.svg 83cp ${ ./contrib/helix.png } $ out /share/icons/hicolor/256x256/apps/helix.png 84'' ; 85 86meta . mainProgram = "hx" ; 87})