@@ -21,57 +21,124 @@
23 lib = nixpkgs.lib;
23 lib = nixpkgs.lib;
24+ ncl = nci.lib.nci-lib;
24 mkRootPath = rel:
25 mkRootPath = rel:
25 builtins.path {
26 builtins.path {
26 path = "${toString ./.}/${rel}";
27 path = "${toString ./.}/${rel}";
27 name = rel;
28 name = rel;
48+ ignorePaths = path: type: let
49+ # split the nix store path into its components
50+ components = lib.splitString "/" path;
51+ # drop off the `/nix/hash-source` section from the path
52+ relPathComponents = lib.drop 4 components;
53+ # reassemble the path components
54+ relPath = lib.concatStringsSep "/" relPathComponents;
56+ lib.all (p: ! (lib.hasPrefix p relPath)) pathsToIgnore;
59+ name = "helix-source";
61+ # filter out unnecessary paths
62+ filter = ignorePaths;
29 outputs = nci.lib.makeOutputs {
64 outputs = nci.lib.makeOutputs {
30 root = ./.;
65 root = ./.;
68+ # rename helix-term to helix since it's our main package
31− renameOutputs = {"helix-term" = "helix";};
69+ rename = {"helix-term" = "helix";};
32− # Set default app to hx (binary is from helix-term release build)
70+ # Set default app to hx (binary is from helix-term release build)
33− # Set default package to helix-term release build
71+ # Set default package to helix-term release build
34− defaultOutputs = {
72+ defaults = {
35− app = "hx";
73+ app = "hx";
36− package = "helix";
74+ package = "helix";
77+ cCompiler.package = with common.pkgs;
82+ packages = with common.pkgs;
83+ [lld_13 cargo-flamegraph rust-analyzer]
84+ ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
85+ ++ (lib.optional stdenv.isLinux lldb);
88+ name = "HELIX_RUNTIME";
89+ eval = "$PWD/runtime";
92+ name = "RUST_BACKTRACE";
98+ if common.pkgs.stdenv.isLinux
99+ then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
38− overrides = {
105+ pkgConfig = common: {
39− cCompiler = common:
106+ helix-term = {
40− with common.pkgs;
107+ # Wrap helix with runtime
41− if stdenv.isLinux
108+ wrapper = _: old: let
42− then gcc
109+ inherit (common) pkgs;
43− else clang;
110+ makeOverridableHelix = old: config: let
44− crateOverrides = common: _: {
111+ grammars = pkgs.callPackage ./grammars.nix config;
112+ runtimeDir = pkgs.runCommand "helix-runtime" {} ''
114+ ln -s ${mkRootPath "runtime"}/* $out
116+ ln -s ${grammars} $out/grammars
119+ common.internal.pkgsSet.utils.wrapDerivation old
121+ nativeBuildInputs = [pkgs.makeWrapper];
122+ makeWrapperArgs = config.makeWrapperArgs or [];
127+ ln -sf ${old}/bin/* $out/bin/
128+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
45− helix-term = prev: {
131+ helix-wrapped
46− src = builtins.path {
132+ // {override = makeOverridableHelix old;};
47− name = "helix-source";
133+ in
48− path = toString ./.;
134+ makeOverridableHelix old {};
49− # filter out unneeded stuff that cause rebuilds
135+ overrides.fix-build.overrideAttrs = prev: {
50− filter = path: type:
136+ src = filteredSource;
52− (n: builtins.baseNameOf path != n)
71 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
138 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
72 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
139 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
74− buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
141+ buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib];
76 # link languages and theme toml files since helix-term expects them (for tests)
143 # link languages and theme toml files since helix-term expects them (for tests)
77 preConfigure = ''
144 preConfigure = ''
@@ -87,88 +154,20 @@
87 meta.mainProgram = "hx";
154 meta.mainProgram = "hx";
90− shell = common: prev: {
95− [lld_13 cargo-flamegraph rust-analyzer]
96− ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
97− ++ (lib.optional stdenv.isLinux lldb)
103− name = "HELIX_RUNTIME";
104− eval = "$PWD/runtime";
107− name = "RUST_BACKTRACE";
113− if common.pkgs.stdenv.isLinux
114− then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
121− makeOverridableHelix = system: old: config: let
122− pkgs = nixpkgs.legacyPackages.${system};
123− grammars = pkgs.callPackage ./grammars.nix config;
124− runtimeDir = pkgs.runCommand "helix-runtime" {} ''
126− ln -s ${mkRootPath "runtime"}/* $out
128− ln -s ${grammars} $out/grammars
131− pkgs.runCommand "${old.name}-wrapped"
133− inherit (old) pname version meta;
135− nativeBuildInputs = [pkgs.makeWrapper];
136− makeWrapperArgs = config.makeWrapperArgs or [];
140− cp -r --no-preserve=mode,ownership ${old}/* $out/
142− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
146− // {override = makeOverridableHelix system old;};
157− program = lib.getExe self.${system}.packages.helix;
162 packages =
162 packages =
163 lib.mapAttrs
163 lib.mapAttrs
165− system: packages: rec {
165+ system: packages:
166− default = helix;
166+ packages
167− helix = makeOverridableHelix system helix-unwrapped {};
167+ // {
168− helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
169− helix-unwrapped = packages.helix;
168+ helix-unwrapped = packages.helix.passthru.unwrapped;
170− helix-unwrapped-debug = packages.helix-debug;
169+ helix-unwrapped-debug = packages.helix-debug.passthru.unwrapped;
173 outputs.packages;
172 outputs.packages;