mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-24 18:36:18 +04:00
build(nix): update nci, refactor flake, seperate wrapping, add source filtering (#3657)
This commit is contained in:
parent
3c38fe9c70
commit
e917a8e0be
2
.github/workflows/cachix.yml
vendored
2
.github/workflows/cachix.yml
vendored
@ -23,4 +23,4 @@ jobs:
|
|||||||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||||
|
|
||||||
- name: Build nix flake
|
- name: Build nix flake
|
||||||
run: nix build
|
run: nix build -L
|
||||||
|
66
flake.lock
66
flake.lock
@ -3,11 +3,11 @@
|
|||||||
"crane": {
|
"crane": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654444508,
|
"lastModified": 1661875961,
|
||||||
"narHash": "sha256-4OBvQ4V7jyt7afs6iKUvRzJ1u/9eYnKzVQbeQdiamuY=",
|
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "db5482bf225acc3160899124a1df5a617cfa27b5",
|
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -19,11 +19,11 @@
|
|||||||
"devshell": {
|
"devshell": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655976588,
|
"lastModified": 1660811669,
|
||||||
"narHash": "sha256-VreHyH6ITkf/1EX/8h15UqhddJnUleb0HgbC3gMkAEQ=",
|
"narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "899ca4629020592a13a46783587f6e674179d1db",
|
"rev": "c2feacb46ee69949124c835419861143c4016fb5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -35,49 +35,45 @@
|
|||||||
"dream2nix": {
|
"dream2nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"alejandra": [
|
"alejandra": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"devshell": [
|
"devshell": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"devshell"
|
"devshell"
|
||||||
],
|
],
|
||||||
"flake-utils-pre-commit": [
|
"flake-utils-pre-commit": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"gomod2nix": [
|
"gomod2nix": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"mach-nix": [
|
"mach-nix": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"node2nix": [
|
|
||||||
"nixCargoIntegration",
|
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"poetry2nix": [
|
"poetry2nix": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"pre-commit-hooks": [
|
"pre-commit-hooks": [
|
||||||
"nixCargoIntegration",
|
"nci",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655975833,
|
"lastModified": 1662083074,
|
||||||
"narHash": "sha256-g8sdfuglIZ24oWVbntVzniNTJW+Z3n9DNL9w9Tt+UCE=",
|
"narHash": "sha256-GL4/CLKPYUzkKD1l7oi2XB+vi3z4xGpCVLDdG3tRqvs=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "dream2nix",
|
"repo": "dream2nix",
|
||||||
"rev": "4e75e665ec3a1cddae5266bed0dd72fce0b74a23",
|
"rev": "c6c039fcc6abdf4d828b940b576944a224cf8622",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -88,11 +84,11 @@
|
|||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1637014545,
|
"lastModified": 1656928814,
|
||||||
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -101,7 +97,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixCargoIntegration": {
|
"nci": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"devshell": "devshell",
|
"devshell": "devshell",
|
||||||
"dream2nix": "dream2nix",
|
"dream2nix": "dream2nix",
|
||||||
@ -113,11 +109,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1656453541,
|
"lastModified": 1662143940,
|
||||||
"narHash": "sha256-ZCPVnS6zJOZJvIlwU3rKR8MBVm6A3F4/0mA7G1lQ3D0=",
|
"narHash": "sha256-3eJfehnZLWJGXylfpAMeLR0Q3sx8pAjGiHBQPqOH9+U=",
|
||||||
"owner": "yusdacra",
|
"owner": "yusdacra",
|
||||||
"repo": "nix-cargo-integration",
|
"repo": "nix-cargo-integration",
|
||||||
"rev": "9eb74345b30cd2e536d9dac9d4435d3c475605c7",
|
"rev": "e83f2598aecbe1114783ff9bdae0b85939de35a3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -128,11 +124,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655624069,
|
"lastModified": 1662019588,
|
||||||
"narHash": "sha256-7g1zwTdp35GMTERnSzZMWJ7PG3QdDE8VOX3WsnOkAtM=",
|
"narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa",
|
"rev": "2da64a81275b68fdad38af669afeda43d401e94b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -144,7 +140,7 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixCargoIntegration": "nixCargoIntegration",
|
"nci": "nci",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
@ -157,11 +153,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655779671,
|
"lastModified": 1662087605,
|
||||||
"narHash": "sha256-6feeiGa6fb7ZPVHR71uswkmN1701TAJpwYQA8QffmRk=",
|
"narHash": "sha256-Gpf2gp2JenKGf+TylX/YJpttY2bzsnvAMLdLaxoZRyU=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "8159585609a772b041cce6019d5c21d240709244",
|
"rev": "60c2cfaa8b90ed8cebd18b214fac8682dcf222dd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
251
flake.nix
251
flake.nix
@ -7,128 +7,169 @@
|
|||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
nixCargoIntegration = {
|
nci = {
|
||||||
url = "github:yusdacra/nix-cargo-integration";
|
url = "github:yusdacra/nix-cargo-integration";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.rust-overlay.follows = "rust-overlay";
|
inputs.rust-overlay.follows = "rust-overlay";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {
|
outputs = {
|
||||||
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
nixCargoIntegration,
|
nci,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
outputs = config:
|
lib = nixpkgs.lib;
|
||||||
nixCargoIntegration.lib.makeOutputs {
|
mkRootPath = rel:
|
||||||
root = ./.;
|
builtins.path {
|
||||||
renameOutputs = {"helix-term" = "helix";};
|
path = "${toString ./.}/${rel}";
|
||||||
# Set default app to hx (binary is from helix-term release build)
|
name = rel;
|
||||||
# Set default package to helix-term release build
|
};
|
||||||
defaultOutputs = {
|
outputs = nci.lib.makeOutputs {
|
||||||
app = "hx";
|
root = ./.;
|
||||||
package = "helix";
|
renameOutputs = {"helix-term" = "helix";};
|
||||||
};
|
# Set default app to hx (binary is from helix-term release build)
|
||||||
overrides = {
|
# Set default package to helix-term release build
|
||||||
cCompiler = common:
|
defaultOutputs = {
|
||||||
with common.pkgs;
|
app = "hx";
|
||||||
if stdenv.isLinux
|
package = "helix";
|
||||||
then gcc
|
};
|
||||||
else clang;
|
overrides = {
|
||||||
crateOverrides = common: _: {
|
cCompiler = common:
|
||||||
helix-term = prev: let
|
with common.pkgs;
|
||||||
inherit (common) pkgs;
|
if stdenv.isLinux
|
||||||
mkRootPath = rel:
|
then gcc
|
||||||
builtins.path {
|
else clang;
|
||||||
path = "${common.root}/${rel}";
|
crateOverrides = common: _: {
|
||||||
name = rel;
|
helix-term = prev: {
|
||||||
};
|
src = builtins.path {
|
||||||
grammars = pkgs.callPackage ./grammars.nix config;
|
name = "helix-source";
|
||||||
runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
|
path = toString ./.;
|
||||||
mkdir -p $out
|
# filter out unneeded stuff that cause rebuilds
|
||||||
ln -s ${mkRootPath "runtime"}/* $out
|
filter = path: type:
|
||||||
rm -r $out/grammars
|
lib.all
|
||||||
ln -s ${grammars} $out/grammars
|
(n: builtins.baseNameOf path != n)
|
||||||
'';
|
[
|
||||||
overridedAttrs = {
|
".envrc"
|
||||||
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
|
".ignore"
|
||||||
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
|
".github"
|
||||||
# link languages and theme toml files since helix-term expects them (for tests)
|
"runtime"
|
||||||
preConfigure =
|
"screenshot.png"
|
||||||
pkgs.lib.concatMapStringsSep
|
"book"
|
||||||
"\n"
|
"contrib"
|
||||||
(path: "ln -sf ${mkRootPath path} ..")
|
"docs"
|
||||||
["languages.toml" "theme.toml" "base16_theme.toml"];
|
"README.md"
|
||||||
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
|
"shell.nix"
|
||||||
nativeBuildInputs = [pkgs.makeWrapper];
|
"default.nix"
|
||||||
|
"grammars.nix"
|
||||||
|
"flake.nix"
|
||||||
|
"flake.lock"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
postFixup = ''
|
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
|
||||||
if [ -f "$out/bin/hx" ]; then
|
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
|
||||||
wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
|
|
||||||
fi
|
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
|
||||||
'';
|
|
||||||
};
|
# link languages and theme toml files since helix-term expects them (for tests)
|
||||||
in
|
preConfigure = ''
|
||||||
overridedAttrs
|
${prev.preConfigure or ""}
|
||||||
// (
|
${
|
||||||
pkgs.lib.optionalAttrs
|
lib.concatMapStringsSep
|
||||||
(config ? makeWrapperArgs)
|
"\n"
|
||||||
{inherit (config) makeWrapperArgs;}
|
(path: "ln -sf ${mkRootPath path} ..")
|
||||||
);
|
["languages.toml" "theme.toml" "base16_theme.toml"]
|
||||||
};
|
}
|
||||||
shell = common: prev: {
|
'';
|
||||||
packages =
|
|
||||||
prev.packages
|
meta.mainProgram = "hx";
|
||||||
++ (
|
|
||||||
with common.pkgs;
|
|
||||||
[lld_13 lldb cargo-flamegraph rust-analyzer] ++
|
|
||||||
(lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
|
|
||||||
);
|
|
||||||
env =
|
|
||||||
prev.env
|
|
||||||
++ [
|
|
||||||
{
|
|
||||||
name = "HELIX_RUNTIME";
|
|
||||||
eval = "$PWD/runtime";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "RUST_BACKTRACE";
|
|
||||||
value = "1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "RUSTFLAGS";
|
|
||||||
value =
|
|
||||||
if common.pkgs.stdenv.isLinux
|
|
||||||
then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
|
|
||||||
else "";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
shell = common: prev: {
|
||||||
|
packages =
|
||||||
|
prev.packages
|
||||||
|
++ (
|
||||||
|
with common.pkgs;
|
||||||
|
[lld_13 lldb cargo-flamegraph rust-analyzer]
|
||||||
|
++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
|
||||||
|
);
|
||||||
|
env =
|
||||||
|
prev.env
|
||||||
|
++ [
|
||||||
|
{
|
||||||
|
name = "HELIX_RUNTIME";
|
||||||
|
eval = "$PWD/runtime";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "RUST_BACKTRACE";
|
||||||
|
value = "1";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "RUSTFLAGS";
|
||||||
|
value =
|
||||||
|
if common.pkgs.stdenv.isLinux
|
||||||
|
then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
|
||||||
|
else "";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
defaultOutputs = outputs {};
|
};
|
||||||
makeOverridableHelix = system: old:
|
makeOverridableHelix = system: old: config: let
|
||||||
old
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
// {
|
grammars = pkgs.callPackage ./grammars.nix config;
|
||||||
override = args:
|
runtimeDir = pkgs.runCommand "helix-runtime" {} ''
|
||||||
makeOverridableHelix
|
mkdir -p $out
|
||||||
system
|
ln -s ${mkRootPath "runtime"}/* $out
|
||||||
(outputs args).packages.${system}.helix;
|
rm -r $out/grammars
|
||||||
};
|
ln -s ${grammars} $out/grammars
|
||||||
|
'';
|
||||||
|
helix-wrapped =
|
||||||
|
pkgs.runCommand "${old.name}-wrapped"
|
||||||
|
{
|
||||||
|
inherit (old) pname version meta;
|
||||||
|
|
||||||
|
nativeBuildInputs = [pkgs.makeWrapper];
|
||||||
|
makeWrapperArgs = config.makeWrapperArgs or [];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
mkdir -p $out
|
||||||
|
cp -r --no-preserve=mode,ownership ${old}/* $out/
|
||||||
|
chmod +x $out/bin/*
|
||||||
|
wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
helix-wrapped
|
||||||
|
// {override = makeOverridableHelix system old;};
|
||||||
in
|
in
|
||||||
defaultOutputs
|
outputs
|
||||||
// {
|
// {
|
||||||
packages =
|
apps =
|
||||||
nixpkgs.lib.mapAttrs
|
lib.mapAttrs
|
||||||
(
|
(
|
||||||
system: packages:
|
system: apps: rec {
|
||||||
packages
|
default = hx;
|
||||||
// rec {
|
hx = {
|
||||||
default = helix;
|
type = "app";
|
||||||
helix = makeOverridableHelix system packages.helix;
|
program = lib.getExe self.${system}.packages.helix;
|
||||||
}
|
};
|
||||||
|
}
|
||||||
)
|
)
|
||||||
defaultOutputs.packages;
|
outputs.apps;
|
||||||
|
packages =
|
||||||
|
lib.mapAttrs
|
||||||
|
(
|
||||||
|
system: packages: rec {
|
||||||
|
default = helix;
|
||||||
|
helix = makeOverridableHelix system helix-unwrapped {};
|
||||||
|
helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
|
||||||
|
helix-unwrapped = packages.helix;
|
||||||
|
helix-unwrapped-debug = packages.helix-debug;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
outputs.packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
|
Loading…
Reference in New Issue
Block a user