on 2158366 help sign in
helix/flake.nix
88 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 nixCargoIntegration = {
7 url = "github:yusdacra/nix-cargo-integration";
8 inputs.nixpkgs.follows = "nixpkgs";
9 };
10 flakeCompat = {
11 url = "github:edolstra/flake-compat";
12 flake = false;
13 };
14 };
16 outputs = inputs@{ self, nixCargoIntegration, ... }:
17 nixCargoIntegration.lib.makeOutputs {
18 root = ./.;
19 buildPlatform = "crate2nix";
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 = { app = "hx"; package = "helix"; };
24 overrides = {
25 crateOverrides = common: _: {
26 helix-term = prev: {
27 # link languages and theme toml files since helix-term expects them (for tests)
28 preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} ..";
29 buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
30 };
31 # link languages and theme toml files since helix-view expects them
32 helix-view = _: { preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} .."; };
33 helix-syntax = prev: {
34 src =
35 let
36 pkgs = common.pkgs;
37 helix = pkgs.fetchgit {
38 url = "https://github.com/helix-editor/helix.git";
39 rev = "d4bd5b37669708361a0a6cd2917464b010e6b7f5";
40 fetchSubmodules = true;
41 sha256 = "sha256-KayR7K7UC0mT6EjHsZsCYY9IVDJzft63fGpPKGSY8nQ=";
42 };
43 in
44 pkgs.runCommand prev.src.name { } ''
45 mkdir -p $out
46 ln -s ${prev.src}/* $out
47 ln -sf ${helix}/helix-syntax/languages $out
48 '';
49 preConfigure = "mkdir -p ../runtime/grammars";
50 postInstall = "cp -r ../runtime $out/runtime";
51 };
52 };
53 mainBuild = common: prev:
54 let
55 inherit (common) pkgs lib;
56 helixSyntax = lib.buildCrate {
57 root = self;
58 memberName = "helix-syntax";
59 defaultCrateOverrides = {
60 helix-syntax = common.crateOverrides.helix-syntax;
61 };
62 release = false;
63 };
64 runtimeDir = pkgs.runCommand "helix-runtime" { } ''
65 mkdir -p $out
66 ln -s ${common.root}/runtime/* $out
67 ln -sf ${helixSyntax}/runtime/grammars $out
68 '';
69 in
70 lib.optionalAttrs (common.memberName == "helix-term") {
71 nativeBuildInputs = [ pkgs.makeWrapper ];
72 postFixup = ''
73 if [ -f "$out/bin/hx" ]; then
74 wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
75 fi
76 '';
77 };
78 shell = common: prev: {
79 packages = prev.packages ++ (with common.pkgs; [ lld_10 lldb cargo-tarpaulin ]);
80 env = prev.env ++ [
81 { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
82 { name = "RUST_BACKTRACE"; value = "1"; }
83 { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native"; }
84 ];
85 };
86 };
87 };