@@ -12,16 +12,10 @@
12 inputs.nixpkgs.follows = "nixpkgs";
12 inputs.nixpkgs.follows = "nixpkgs";
13 inputs.rust-overlay.follows = "rust-overlay";
13 inputs.rust-overlay.follows = "rust-overlay";
15+ parts.url = "github:hercules-ci/flake-parts";
17− outputs = {
18+ outputs = inp: let
24− ncl = nci.lib.nci-lib;
25 mkRootPath = rel:
19 mkRootPath = rel:
26 builtins.path {
20 builtins.path {
27 path = "${toString ./.}/${rel}";
21 path = "${toString ./.}/${rel}";
@@ -32,6 +26,12 @@
33+ "rust-toolchain.toml"
36 "screenshot.png"
36 "screenshot.png"
@@ -46,6 +46,7 @@
46 "flake.lock"
46 "flake.lock"
48 ignorePaths = path: type: let
48 ignorePaths = path: type: let
49+ inherit (inp.nixpkgs) lib;
49 # split the nix store path into its components
50 # split the nix store path into its components
50 components = lib.splitString "/" path;
51 components = lib.splitString "/" path;
51 # drop off the `/nix/hash-source` section from the path
52 # drop off the `/nix/hash-source` section from the path
@@ -61,123 +62,105 @@
61 # filter out unnecessary paths
62 # filter out unnecessary paths
62 filter = ignorePaths;
63 filter = ignorePaths;
64− outputs = nci.lib.makeOutputs {
65+ in
65− root = ./.;
66+ inp.parts.lib.mkFlake {inputs = inp;} {
66− config = common: {
67+ imports = [inp.nci.flakeModule];
67− outputs = {
68+ systems = [
68− # rename helix-term to helix since it's our main package
69+ "x86_64-linux"
69− rename = {"helix-term" = "helix";};
70+ "x86_64-darwin"
70− # Set default app to hx (binary is from helix-term release build)
71+ "aarch64-linux"
71− # Set default package to helix-term release build
72+ "aarch64-darwin"
72− defaults = {
73+ "i686-linux"
74− package = "helix";
75+ perSystem = {
77− cCompiler.package = with common.pkgs;
78+ lib,
78− if stdenv.isLinux
79+ ...
80− else clang;
81+ makeOverridableHelix = old: config: let
81− shell = {
82+ grammars = pkgs.callPackage ./grammars.nix config;
82− packages = with common.pkgs;
83+ runtimeDir = pkgs.runCommand "helix-runtime" {} ''
83− [lld_13 cargo-flamegraph rust-analyzer]
84+ mkdir -p $out
84− ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
85+ ln -s ${mkRootPath "runtime"}/* $out
85− ++ (lib.optional stdenv.isLinux lldb)
86+ rm -r $out/grammars
86− ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation);
87+ ln -s ${grammars} $out/grammars
89− name = "HELIX_RUNTIME";
90+ pkgs.runCommand
90− eval = "$PWD/runtime";
91+ old.name
93− name = "RUST_BACKTRACE";
97− name = "RUSTFLAGS";
93+ inherit (old) pname version;
98− eval =
94+ meta = old.meta or {};
99− if common.pkgs.stdenv.isLinux
95+ passthru =
100− then "$RUSTFLAGS\" -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment\""
96+ (old.passthru or {})
101− else "$RUSTFLAGS";
97+ // {
100+ nativeBuildInputs = [pkgs.makeWrapper];
101+ makeWrapperArgs = config.makeWrapperArgs or [];
104− };
104+ cp -rs --no-preserve=mode,ownership ${old} $out
106− pkgConfig = common: {
108− # Wrap helix with runtime
109− wrapper = _: old: let
110− inherit (common) pkgs;
111− makeOverridableHelix = old: config: let
112− grammars = pkgs.callPackage ./grammars.nix config;
113− runtimeDir = pkgs.runCommand "helix-runtime" {} ''
115− ln -s ${mkRootPath "runtime"}/* $out
117− ln -s ${grammars} $out/grammars
120− common.internal.pkgsSet.utils.wrapDerivation old
122− nativeBuildInputs = [pkgs.makeWrapper];
123− makeWrapperArgs = config.makeWrapperArgs or [];
128− ln -sf ${old}/bin/* $out/bin/
129− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
105+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
110+ override = makeOverridableHelix old;
132− helix-wrapped
112+ helix-wrapped.passthru
134− override = makeOverridableHelix old;
114+ wrapper = old: makeOverridableHelix old config;
135− passthru = helix-wrapped.passthru // {wrapper = wrapper {};};
138− makeOverridableHelix old {};
117+ stdenv =
118+ if pkgs.stdenv.isLinux
120+ else pkgs.clangStdenv;
123+ then "$RUSTFLAGS\" -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment\""
140− inherit wrapper;
126+ nci.projects."helix-project".relPath = "";
127+ nci.crates."helix-term" = {
129+ add-meta.override = _: {meta.mainProgram = "hx";};
141− overrides.fix-build.overrideAttrs = prev: {
130+ add-inputs.overrideAttrs = prev: {
142− src = filteredSource;
131+ buildInputs = (prev.buildInputs or []) ++ [stdenv.cc.cc.lib];
133+ disable-grammar-builds = {
144− # disable fetching and building of tree-sitter grammars in the helix-term build.rs
134+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
145− HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
135+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
147− buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib];
149− # link languages and theme toml files since helix-term expects them (for tests)
151− ${prev.preConfigure or ""}
153− lib.concatMapStringsSep
155− (path: "ln -sf ${mkRootPath path} ..")
156− ["languages.toml" "theme.toml" "base16_theme.toml"]
159− checkPhase = ":";
137+ disable-tests = {checkPhase = ":";};
160−
138+ set-stdenv.override = _: {inherit stdenv;};
161− meta.mainProgram = "hx";
139+ set-filtered-src.override = _: {src = filteredSource;};
143+ packages.helix-unwrapped = config.nci.outputs."helix-term".packages.release;
144+ packages.helix-unwrapped-dev = config.nci.outputs."helix-term".packages.dev;
145+ packages.helix = makeOverridableHelix config.packages.helix-unwrapped {};
146+ packages.helix-dev = makeOverridableHelix config.packages.helix-unwrapped-dev {};
147+ packages.default = config.packages.helix;
149+ devShells.default = config.nci.outputs."helix-project".devShell.overrideAttrs (old: {
151+ (old.nativeBuildInputs or [])
152+ ++ (with pkgs; [lld_13 cargo-flamegraph rust-analyzer])
153+ ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) pkgs.cargo-tarpaulin)
154+ ++ (lib.optional stdenv.isLinux pkgs.lldb)
155+ ++ (lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.CoreFoundation);
157+ export HELIX_RUNTIME="$PWD/runtime"
158+ export RUST_BACKTRACE="1"
159+ export RUSTFLAGS="${rustFlagsEnv}"
175− helix-unwrapped = packages.helix.passthru.unwrapped;
176− helix-unwrapped-dev = packages.helix-dev.passthru.unwrapped;
182 nixConfig = {
165 nixConfig = {
183 extra-substituters = ["https://helix.cachix.org"];
166 extra-substituters = ["https://helix.cachix.org"];