on 549cdee help sign in
helix/flake.nix
75 lines 2.9 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 flakeCompat = {
13 url = "github:edolstra/flake-compat";
14 flake = false;
15 };
16 };
18 outputs = inputs@{ self, nixCargoIntegration, ... }:
19 nixCargoIntegration.lib.makeOutputs {
20 root = ./.;
21 buildPlatform = "crate2nix";
22 renameOutputs = { "helix-term" = "helix"; };
23 # Set default app to hx (binary is from helix-term release build)
24 # Set default package to helix-term release build
25 defaultOutputs = { app = "hx"; package = "helix"; };
26 overrides = {
27 crateOverrides = common: _: {
28 helix-term = prev: {
29 # link languages and theme toml files since helix-term expects them (for tests)
30 preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} ..";
31 buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
32 };
33 # link languages and theme toml files since helix-view expects them
34 helix-view = _: { preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} .."; };
35 helix-syntax = _prev: {
36 preConfigure = "mkdir -p ../runtime/grammars";
37 postInstall = "cp -r ../runtime $out/runtime";
38 };
39 };
40 mainBuild = common: prev:
41 let
42 inherit (common) pkgs lib;
43 helixSyntax = lib.buildCrate {
44 root = self;
45 memberName = "helix-syntax";
46 defaultCrateOverrides = {
47 helix-syntax = common.crateOverrides.helix-syntax;
48 };
49 release = false;
50 };
51 runtimeDir = pkgs.runCommand "helix-runtime" { } ''
52 mkdir -p $out
53 ln -s ${common.root}/runtime/* $out
54 ln -sf ${helixSyntax}/runtime/grammars $out
55 '';
56 in
57 lib.optionalAttrs (common.memberName == "helix-term") {
58 nativeBuildInputs = [ pkgs.makeWrapper ];
59 postFixup = ''
60 if [ -f "$out/bin/hx" ]; then
61 wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
62 fi
63 '';
64 };
65 shell = common: prev: {
66 packages = prev.packages ++ (with common.pkgs; [ lld_12 lldb cargo-tarpaulin ]);
67 env = prev.env ++ [
68 { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
69 { name = "RUST_BACKTRACE"; value = "1"; }
70 { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native"; }
71 ];
72 };
73 };
74 };