on febee2d help sign in
helix/flake.nix
71 lines 2.8 kB history raw
1{
2 description = "A post-modern text editor.";
4 inputs = {
5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6 rust-overlay.url = "github:oxalica/rust-overlay";
7 nixCargoIntegration = {
8 url = "github:yusdacra/nix-cargo-integration";
9 inputs.nixpkgs.follows = "nixpkgs";
10 inputs.rustOverlay.follows = "rust-overlay";
11 };
12 };
14 outputs = inputs@{ self, nixCargoIntegration, ... }:
15 nixCargoIntegration.lib.makeOutputs {
16 root = ./.;
17 buildPlatform = "crate2nix";
18 renameOutputs = { "helix-term" = "helix"; };
19 # Set default app to hx (binary is from helix-term release build)
20 # Set default package to helix-term release build
21 defaultOutputs = { app = "hx"; package = "helix"; };
22 overrides = {
23 crateOverrides = common: _: {
24 helix-term = prev: {
25 # link languages and theme toml files since helix-term expects them (for tests)
26 preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} ..";
27 buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
28 };
29 # link languages and theme toml files since helix-view expects them
30 helix-view = _: { preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} .."; };
31 helix-syntax = _prev: {
32 preConfigure = "mkdir -p ../runtime/grammars";
33 postInstall = "cp -r ../runtime $out/runtime";
34 };
35 };
36 mainBuild = common: prev:
37 let
38 inherit (common) pkgs lib;
39 helixSyntax = lib.buildCrate {
40 root = self;
41 memberName = "helix-syntax";
42 defaultCrateOverrides = {
43 helix-syntax = common.crateOverrides.helix-syntax;
44 };
45 release = false;
46 };
47 runtimeDir = pkgs.runCommand "helix-runtime" { } ''
48 mkdir -p $out
49 ln -s ${common.root}/runtime/* $out
50 ln -sf ${helixSyntax}/runtime/grammars $out
51 '';
52 in
53 lib.optionalAttrs (common.memberName == "helix-term") {
54 nativeBuildInputs = [ pkgs.makeWrapper ];
55 postFixup = ''
56 if [ -f "$out/bin/hx" ]; then
57 wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
58 fi
59 '';
60 };
61 shell = common: prev: {
62 packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin ]);
63 env = prev.env ++ [
64 { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
65 { name = "RUST_BACKTRACE"; value = "1"; }
66 { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native"; }
67 ];
68 };
69 };
70 };