on 6c11708 help sign in
helix/flake.nix
84 lines 3.4 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: _: rec {
24 # link languages and theme toml files since helix-view expects them
25 helix-view = _: { preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} .."; };
26 helix-syntax = prev: {
27 src =
28 let
29 pkgs = common.pkgs;
30 helix = pkgs.fetchgit {
31 url = "https://github.com/helix-editor/helix.git";
32 rev = "a8fd33ac012a79069ef1409503a2edcf3a585153";
33 fetchSubmodules = true;
34 sha256 = "sha256-5AtOC55ttWT+7RYMboaFxpGZML51ix93wAkYJTt+8JI=";
35 };
36 in
37 pkgs.runCommand prev.src.name { } ''
38 mkdir -p $out
39 ln -s ${prev.src}/* $out
40 ln -sf ${helix}/helix-syntax/languages $out
41 '';
42 preConfigure = "mkdir -p ../runtime/grammars";
43 postInstall = "cp -r ../runtime $out/runtime";
44 };
45 helix-term = prev:
46 let
47 inherit (common) pkgs lib;
48 helixSyntax = lib.buildCrate {
49 root = self;
50 memberName = "helix-syntax";
51 defaultCrateOverrides = {
52 helix-syntax = helix-syntax;
53 };
54 release = false;
55 };
56 runtimeDir = pkgs.runCommand "helix-runtime" { } ''
57 mkdir -p $out
58 ln -s ${common.root}/runtime/* $out
59 ln -sf ${helixSyntax}/runtime/grammars $out
60 '';
61 in
62 {
63 # link languages and theme toml files since helix-term expects them (for tests)
64 preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} ..";
65 buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
66 nativeBuildInputs = [ pkgs.makeWrapper ];
67 postFixup = ''
68 if [ -f "$out/bin/hx" ]; then
69 wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
70 fi
71 '';
72 };
73 };
74 shell = common: prev: {
75 packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]);
76 env = prev.env ++ [
77 { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
78 { name = "RUST_BACKTRACE"; value = "1"; }
79 { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"; }
80 ];
81 };
82 };
83 };