2021-01-19 10:54:51 +04:00
|
|
|
{
|
|
|
|
description = "A post-modern text editor.";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
2022-03-03 05:45:45 +04:00
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-09-03 02:54:07 +04:00
|
|
|
nci = {
|
2021-06-13 09:03:42 +04:00
|
|
|
url = "github:yusdacra/nix-cargo-integration";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2022-06-22 00:59:46 +04:00
|
|
|
inputs.rust-overlay.follows = "rust-overlay";
|
2021-06-13 09:03:42 +04:00
|
|
|
};
|
2023-02-25 07:27:13 +04:00
|
|
|
parts.url = "github:hercules-ci/flake-parts";
|
2021-01-19 10:54:51 +04:00
|
|
|
};
|
|
|
|
|
2023-02-25 07:27:13 +04:00
|
|
|
outputs = inp: let
|
2022-09-03 02:54:07 +04:00
|
|
|
mkRootPath = rel:
|
|
|
|
builtins.path {
|
|
|
|
path = "${toString ./.}/${rel}";
|
|
|
|
name = rel;
|
|
|
|
};
|
2022-11-01 04:52:03 +04:00
|
|
|
filteredSource = let
|
|
|
|
pathsToIgnore = [
|
|
|
|
".envrc"
|
|
|
|
".ignore"
|
|
|
|
".github"
|
2023-02-25 07:27:13 +04:00
|
|
|
".gitignore"
|
|
|
|
"logo.svg"
|
|
|
|
"logo_dark.svg"
|
|
|
|
"logo_light.svg"
|
|
|
|
"rust-toolchain.toml"
|
|
|
|
"rustfmt.toml"
|
2022-11-01 04:52:03 +04:00
|
|
|
"runtime"
|
|
|
|
"screenshot.png"
|
|
|
|
"book"
|
|
|
|
"contrib"
|
|
|
|
"docs"
|
|
|
|
"README.md"
|
|
|
|
"CHANGELOG.md"
|
|
|
|
"shell.nix"
|
|
|
|
"default.nix"
|
|
|
|
"grammars.nix"
|
|
|
|
"flake.nix"
|
|
|
|
"flake.lock"
|
|
|
|
];
|
|
|
|
ignorePaths = path: type: let
|
2023-02-25 07:27:13 +04:00
|
|
|
inherit (inp.nixpkgs) lib;
|
2022-11-01 04:52:03 +04:00
|
|
|
# split the nix store path into its components
|
|
|
|
components = lib.splitString "/" path;
|
|
|
|
# drop off the `/nix/hash-source` section from the path
|
|
|
|
relPathComponents = lib.drop 4 components;
|
|
|
|
# reassemble the path components
|
|
|
|
relPath = lib.concatStringsSep "/" relPathComponents;
|
|
|
|
in
|
|
|
|
lib.all (p: ! (lib.hasPrefix p relPath)) pathsToIgnore;
|
|
|
|
in
|
|
|
|
builtins.path {
|
|
|
|
name = "helix-source";
|
|
|
|
path = toString ./.;
|
|
|
|
# filter out unnecessary paths
|
|
|
|
filter = ignorePaths;
|
|
|
|
};
|
2023-02-25 07:27:13 +04:00
|
|
|
in
|
|
|
|
inp.parts.lib.mkFlake {inputs = inp;} {
|
|
|
|
imports = [inp.nci.flakeModule];
|
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-linux"
|
|
|
|
"aarch64-darwin"
|
|
|
|
"i686-linux"
|
|
|
|
];
|
|
|
|
perSystem = {
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
makeOverridableHelix = old: config: let
|
|
|
|
grammars = pkgs.callPackage ./grammars.nix config;
|
|
|
|
runtimeDir = pkgs.runCommand "helix-runtime" {} ''
|
|
|
|
mkdir -p $out
|
|
|
|
ln -s ${mkRootPath "runtime"}/* $out
|
|
|
|
rm -r $out/grammars
|
|
|
|
ln -s ${grammars} $out/grammars
|
|
|
|
'';
|
|
|
|
helix-wrapped =
|
|
|
|
pkgs.runCommand
|
|
|
|
old.name
|
2022-11-01 04:52:03 +04:00
|
|
|
{
|
2023-02-25 07:27:13 +04:00
|
|
|
inherit (old) pname version;
|
|
|
|
meta = old.meta or {};
|
|
|
|
passthru =
|
|
|
|
(old.passthru or {})
|
|
|
|
// {
|
|
|
|
unwrapped = old;
|
|
|
|
};
|
|
|
|
nativeBuildInputs = [pkgs.makeWrapper];
|
|
|
|
makeWrapperArgs = config.makeWrapperArgs or [];
|
2022-11-01 04:52:03 +04:00
|
|
|
}
|
2023-02-25 07:27:13 +04:00
|
|
|
''
|
|
|
|
cp -rs --no-preserve=mode,ownership ${old} $out
|
|
|
|
wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
helix-wrapped
|
|
|
|
// {
|
|
|
|
override = makeOverridableHelix old;
|
|
|
|
passthru =
|
|
|
|
helix-wrapped.passthru
|
2023-02-17 10:17:38 +04:00
|
|
|
// {
|
2023-02-25 07:27:13 +04:00
|
|
|
wrapper = old: makeOverridableHelix old config;
|
2023-02-17 10:17:38 +04:00
|
|
|
};
|
2023-02-25 07:27:13 +04:00
|
|
|
};
|
|
|
|
stdenv =
|
|
|
|
if pkgs.stdenv.isLinux
|
|
|
|
then pkgs.stdenv
|
|
|
|
else pkgs.clangStdenv;
|
|
|
|
rustFlagsEnv =
|
|
|
|
if stdenv.isLinux
|
2023-02-25 08:06:30 +04:00
|
|
|
then ''$RUSTFLAGS -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment''
|
2023-02-25 07:27:13 +04:00
|
|
|
else "$RUSTFLAGS";
|
|
|
|
in {
|
2023-02-25 08:06:30 +04:00
|
|
|
# by default NCI adds rust-analyzer component, but helix toolchain doesn't have rust-analyzer
|
|
|
|
nci.toolchains.shell.components = ["rust-src" "rustfmt" "clippy"];
|
2023-02-25 07:27:13 +04:00
|
|
|
nci.projects."helix-project".relPath = "";
|
|
|
|
nci.crates."helix-term" = {
|
|
|
|
overrides = {
|
|
|
|
add-meta.override = _: {meta.mainProgram = "hx";};
|
|
|
|
add-inputs.overrideAttrs = prev: {
|
|
|
|
buildInputs = (prev.buildInputs or []) ++ [stdenv.cc.cc.lib];
|
|
|
|
};
|
|
|
|
disable-grammar-builds = {
|
|
|
|
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
|
|
|
|
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
|
|
|
|
};
|
|
|
|
disable-tests = {checkPhase = ":";};
|
|
|
|
set-stdenv.override = _: {inherit stdenv;};
|
|
|
|
set-filtered-src.override = _: {src = filteredSource;};
|
2022-06-06 23:24:52 +04:00
|
|
|
};
|
2022-01-13 04:40:07 +04:00
|
|
|
};
|
2023-02-25 07:27:13 +04:00
|
|
|
|
|
|
|
packages.helix-unwrapped = config.nci.outputs."helix-term".packages.release;
|
|
|
|
packages.helix-unwrapped-dev = config.nci.outputs."helix-term".packages.dev;
|
|
|
|
packages.helix = makeOverridableHelix config.packages.helix-unwrapped {};
|
|
|
|
packages.helix-dev = makeOverridableHelix config.packages.helix-unwrapped-dev {};
|
|
|
|
packages.default = config.packages.helix;
|
|
|
|
|
|
|
|
devShells.default = config.nci.outputs."helix-project".devShell.overrideAttrs (old: {
|
|
|
|
nativeBuildInputs =
|
|
|
|
(old.nativeBuildInputs or [])
|
|
|
|
++ (with pkgs; [lld_13 cargo-flamegraph rust-analyzer])
|
|
|
|
++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) pkgs.cargo-tarpaulin)
|
|
|
|
++ (lib.optional stdenv.isLinux pkgs.lldb)
|
|
|
|
++ (lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.CoreFoundation);
|
|
|
|
shellHook = ''
|
|
|
|
export HELIX_RUNTIME="$PWD/runtime"
|
|
|
|
export RUST_BACKTRACE="1"
|
|
|
|
export RUSTFLAGS="${rustFlagsEnv}"
|
|
|
|
'';
|
|
|
|
});
|
2021-06-10 01:56:11 +04:00
|
|
|
};
|
2022-09-03 02:54:07 +04:00
|
|
|
};
|
2022-07-09 20:09:37 +04:00
|
|
|
|
|
|
|
nixConfig = {
|
|
|
|
extra-substituters = ["https://helix.cachix.org"];
|
|
|
|
extra-trusted-public-keys = ["helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="];
|
|
|
|
};
|
2021-01-19 10:54:51 +04:00
|
|
|
}
|