on fa2eecc help sign in
helix/flake.nix
66 lines 2.6 kB history raw
1{
2 description = "A post-modern text editor.";
4 inputs = {
5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6 rust-overlay = {
7 url = "github:oxalica/rust-overlay";
8 inputs.nixpkgs.follows = "nixpkgs";
9 };
10 nixCargoIntegration = {
11 url = "github:yusdacra/nix-cargo-integration";
12 inputs.nixpkgs.follows = "nixpkgs";
13 inputs.rustOverlay.follows = "rust-overlay";
14 };
15 };
17 outputs = inputs@{ nixCargoIntegration, ... }:
18 nixCargoIntegration.lib.makeOutputs {
19 root = ./.;
20 renameOutputs = { "helix-term" = "helix"; };
21 # Set default app to hx (binary is from helix-term release build)
22 # Set default package to helix-term release build
23 defaultOutputs = {
24 app = "hx";
25 package = "helix";
26 };
27 overrides = {
28 cCompiler = common: if common.pkgs.stdenv.isLinux then common.pkgs.gcc else common.pkgs.clang;
29 crateOverrides = common: _: {
30 helix-term = prev:
31 let
32 inherit (common) pkgs;
33 grammars = pkgs.callPackage ./grammars.nix { };
34 runtimeDir = pkgs.runCommand "helix-runtime" { } ''
35 mkdir -p $out
36 ln -s ${common.root}/runtime/* $out
37 rm -r $out/grammars
38 ln -s ${grammars} $out/grammars
39 '';
40 in
41 {
42 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
43 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
44 # link languages and theme toml files since helix-term expects them (for tests)
45 preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} ..";
46 buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
47 nativeBuildInputs = [ pkgs.makeWrapper ];
49 postFixup = ''
50 if [ -f "$out/bin/hx" ]; then
51 wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
52 fi
53 '';
54 };
55 };
56 shell = common: prev: {
57 packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]);
58 env = prev.env ++ [
59 { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
60 { name = "RUST_BACKTRACE"; value = "1"; }
61 { name = "RUSTFLAGS"; value = if common.pkgs.stdenv.isLinux then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" else ""; }
62 ];
63 };
64 };
65 };