@@ -18,83 +18,115 @@
1818 nixpkgs,
1919 nixCargoIntegration,
2020 ...
21− }:
22− nixCargoIntegration.lib.makeOutputs {
23− root = ./.;
24− renameOutputs = {"helix-term" = "helix";};
25− # Set default app to hx (binary is from helix-term release build)
26− # Set default package to helix-term release build
27− defaultOutputs = {
28− app = "hx";
29− package = "helix";
30− };
31− overrides = {
32− cCompiler = common:
33− with common.pkgs;
34− if stdenv.isLinux
35− then gcc
36− else clang;
37− crateOverrides = common: _: {
38− helix-term = prev: let
39− inherit (common) pkgs;
40− mkRootPath = rel:
41− builtins.path {
42− path = "${common.root}/${rel}";
43− name = rel;
44− };
45− grammars = pkgs.callPackage ./grammars.nix {};
46− runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
47− mkdir -p $out
48− ln -s ${mkRootPath "runtime"}/* $out
49− rm -r $out/grammars
50− ln -s ${grammars} $out/grammars
51− '';
52− in {
53− # disable fetching and building of tree-sitter grammars in the helix-term build.rs
54− HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
55− # link languages and theme toml files since helix-term expects them (for tests)
56− preConfigure =
57− pkgs.lib.concatMapStringsSep
58− "\n"
59− (path: "ln -sf ${mkRootPath path} ..")
60− ["languages.toml" "theme.toml" "base16_theme.toml"];
61− buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
62− nativeBuildInputs = [pkgs.makeWrapper];
21+ }: let
22+ outputs = config:
23+ nixCargoIntegration.lib.makeOutputs {
24+ root = ./.;
25+ renameOutputs = {"helix-term" = "helix";};
26+ # Set default app to hx (binary is from helix-term release build)
27+ # Set default package to helix-term release build
28+ defaultOutputs = {
29+ app = "hx";
30+ package = "helix";
31+ };
32+ overrides = {
33+ cCompiler = common:
34+ with common.pkgs;
35+ if stdenv.isLinux
36+ then gcc
37+ else clang;
38+ crateOverrides = common: _: {
39+ helix-term = prev: let
40+ inherit (common) pkgs;
41+ mkRootPath = rel:
42+ builtins.path {
43+ path = "${common.root}/${rel}";
44+ name = rel;
45+ };
46+ grammars = pkgs.callPackage ./grammars.nix config;
47+ runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
48+ mkdir -p $out
49+ ln -s ${mkRootPath "runtime"}/* $out
50+ rm -r $out/grammars
51+ ln -s ${grammars} $out/grammars
52+ '';
53+ overridedAttrs = {
54+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
55+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
56+ # link languages and theme toml files since helix-term expects them (for tests)
57+ preConfigure =
58+ pkgs.lib.concatMapStringsSep
59+ "\n"
60+ (path: "ln -sf ${mkRootPath path} ..")
61+ ["languages.toml" "theme.toml" "base16_theme.toml"];
62+ buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
63+ nativeBuildInputs = [pkgs.makeWrapper];
6364
64− postFixup = ''
65− if [ -f "$out/bin/hx" ]; then
66− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
67− fi
68− '';
65+ postFixup = ''
66+ if [ -f "$out/bin/hx" ]; then
67+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
68+ fi
69+ '';
70+ };
71+ in
72+ overridedAttrs
73+ // (
74+ pkgs.lib.optionalAttrs
75+ (config ? makeWrapperArgs)
76+ {inherit (config) makeWrapperArgs;}
77+ );
78+ };
79+ shell = common: prev: {
80+ packages =
81+ prev.packages
82+ ++ (
83+ with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph rust-analyzer]
84+ );
85+ env =
86+ prev.env
87+ ++ [
88+ {
89+ name = "HELIX_RUNTIME";
90+ eval = "$PWD/runtime";
91+ }
92+ {
93+ name = "RUST_BACKTRACE";
94+ value = "1";
95+ }
96+ {
97+ name = "RUSTFLAGS";
98+ value =
99+ if common.pkgs.stdenv.isLinux
100+ then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
101+ else "";
102+ }
103+ ];
69104 };
70105 };
71− shell = common: prev: {
72− packages =
73− prev.packages
74− ++ (
75− with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph rust-analyzer]
76− );
77− env =
78− prev.env
79− ++ [
80− {
81− name = "HELIX_RUNTIME";
82− eval = "$PWD/runtime";
83− }
84− {
85− name = "RUST_BACKTRACE";
86− value = "1";
87− }
88− {
89− name = "RUSTFLAGS";
90− value =
91− if common.pkgs.stdenv.isLinux
92− then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
93− else "";
94− }
95− ];
96− };
97106 };
107+ defaultOutputs = outputs {};
108+ makeOverridableHelix = system: old:
109+ old
110+ // {
111+ override = args:
112+ makeOverridableHelix
113+ system
114+ (outputs args).packages.${system}.helix;
115+ };
116+ in
117+ defaultOutputs
118+ // {
119+ packages =
120+ nixpkgs.lib.mapAttrs
121+ (
122+ system: packages:
123+ packages
124+ // rec {
125+ default = helix;
126+ helix = makeOverridableHelix system packages.helix;
127+ }
128+ )
129+ defaultOutputs.packages;
98130 };
99131
100132 nixConfig = {