@@ -7,128 +7,169 @@
7 url = "github:oxalica/rust-overlay";
7 url = "github:oxalica/rust-overlay";
8 inputs.nixpkgs.follows = "nixpkgs";
8 inputs.nixpkgs.follows = "nixpkgs";
10− nixCargoIntegration = {
10+ nci = {
11 url = "github:yusdacra/nix-cargo-integration";
11 url = "github:yusdacra/nix-cargo-integration";
12 inputs.nixpkgs.follows = "nixpkgs";
12 inputs.nixpkgs.follows = "nixpkgs";
13 inputs.rust-overlay.follows = "rust-overlay";
13 inputs.rust-overlay.follows = "rust-overlay";
17− outputs = inputs @ {
17+ outputs = {
19− nixCargoIntegration,
20+ nci,
22− outputs = config:
23+ lib = nixpkgs.lib;
26+ path = "${toString ./.}/${rel}";
23− nixCargoIntegration.lib.makeOutputs {
29+ outputs = nci.lib.makeOutputs {
24− root = ./.;
30+ root = ./.;
25− renameOutputs = {"helix-term" = "helix";};
31+ renameOutputs = {"helix-term" = "helix";};
26− # Set default app to hx (binary is from helix-term release build)
32+ # Set default app to hx (binary is from helix-term release build)
27− # Set default package to helix-term release build
33+ # Set default package to helix-term release build
28− defaultOutputs = {
34+ defaultOutputs = {
29− app = "hx";
35+ app = "hx";
30− package = "helix";
36+ package = "helix";
32− overrides = {
38+ overrides = {
33− cCompiler = common:
39+ cCompiler = common:
34− with common.pkgs;
40+ with common.pkgs;
35− if stdenv.isLinux
41+ if stdenv.isLinux
37− else clang;
43+ else clang;
38− crateOverrides = common: _: {
44+ crateOverrides = common: _: {
39− helix-term = prev: let
45+ helix-term = prev: {
40− inherit (common) pkgs;
42− builtins.path {
46+ src = builtins.path {
43− path = "${common.root}/${rel}";
47+ name = "helix-source";
44− name = rel;
48+ path = toString ./.;
45− };
49+ # filter out unneeded stuff that cause rebuilds
46− grammars = pkgs.callPackage ./grammars.nix config;
50+ filter = path: type:
47− runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
51+ lib.all
48− mkdir -p $out
52+ (n: builtins.baseNameOf path != n)
49− ln -s ${mkRootPath "runtime"}/* $out
53+ [
50− rm -r $out/grammars
54+ ".envrc"
51− ln -s ${grammars} $out/grammars
55+ ".ignore"
53− overridedAttrs = {
57+ "runtime"
54− # disable fetching and building of tree-sitter grammars in the helix-term build.rs
58+ "screenshot.png"
55− HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
59+ "book"
56− # link languages and theme toml files since helix-term expects them (for tests)
60+ "contrib"
57− preConfigure =
61+ "docs"
58− pkgs.lib.concatMapStringsSep
62+ "README.md"
60− (path: "ln -sf ${mkRootPath path} ..")
64+ "default.nix"
61− ["languages.toml" "theme.toml" "base16_theme.toml"];
65+ "grammars.nix"
62− buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
66+ "flake.nix"
63− nativeBuildInputs = [pkgs.makeWrapper];
67+ "flake.lock"
65− postFixup = ''
71+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
66− if [ -f "$out/bin/hx" ]; then
72+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
67− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
73+
68− fi
74+ buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
70− };
76+ # link languages and theme toml files since helix-term expects them (for tests)
71− in
77+ preConfigure = ''
72− overridedAttrs
78+ ${prev.preConfigure or ""}
74− pkgs.lib.optionalAttrs
80+ lib.concatMapStringsSep
75− (config ? makeWrapperArgs)
81+ "\n"
76− {inherit (config) makeWrapperArgs;}
82+ (path: "ln -sf ${mkRootPath path} ..")
77− );
83+ ["languages.toml" "theme.toml" "base16_theme.toml"]
79− shell = common: prev: {
85+ '';
81− prev.packages
87+ meta.mainProgram = "hx";
84− [lld_13 lldb cargo-flamegraph rust-analyzer] ++
85− (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
91− name = "HELIX_RUNTIME";
92− eval = "$PWD/runtime";
95− name = "RUST_BACKTRACE";
101− if common.pkgs.stdenv.isLinux
102− then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
90+ shell = common: prev: {
95+ [lld_13 lldb cargo-flamegraph rust-analyzer]
96+ ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
102+ name = "HELIX_RUNTIME";
103+ eval = "$PWD/runtime";
106+ name = "RUST_BACKTRACE";
112+ if common.pkgs.stdenv.isLinux
113+ then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
109− defaultOutputs = outputs {};
119+ };
110− makeOverridableHelix = system: old:
120+ makeOverridableHelix = system: old: config: let
111− old
121+ pkgs = nixpkgs.legacyPackages.${system};
112− // {
122+ grammars = pkgs.callPackage ./grammars.nix config;
113− override = args:
123+ runtimeDir = pkgs.runCommand "helix-runtime" {} ''
114− makeOverridableHelix
124+ mkdir -p $out
115− system
125+ ln -s ${mkRootPath "runtime"}/* $out
116− (outputs args).packages.${system}.helix;
126+ rm -r $out/grammars
117− };
127+ ln -s ${grammars} $out/grammars
130+ pkgs.runCommand "${old.name}-wrapped"
132+ inherit (old) pname version meta;
134+ nativeBuildInputs = [pkgs.makeWrapper];
135+ makeWrapperArgs = config.makeWrapperArgs or [];
139+ cp -r --no-preserve=mode,ownership ${old}/* $out/
141+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
145+ // {override = makeOverridableHelix system old;};
119− defaultOutputs
147+ outputs
156+ program = lib.getExe self.${system}.packages.helix;
121 packages =
161 packages =
122− nixpkgs.lib.mapAttrs
162+ lib.mapAttrs
124− system: packages:
164+ system: packages: rec {
127− default = helix;
165+ default = helix;
128− helix = makeOverridableHelix system packages.helix;
166+ helix = makeOverridableHelix system helix-unwrapped {};
167+ helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
168+ helix-unwrapped = packages.helix;
169+ helix-unwrapped-debug = packages.helix-debug;
131− defaultOutputs.packages;
172+ outputs.packages;
134 nixConfig = {
175 nixConfig = {