build(nix): update nci, refactor flake, seperate wrapping, add source filtering (#3657)

imgbot
Yusuf Bera Ertan 2 years ago committed by GitHub
parent 3c38fe9c70
commit e917a8e0be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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": {

@ -7,20 +7,26 @@
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:
builtins.path {
path = "${toString ./.}/${rel}";
name = rel;
};
outputs = nci.lib.makeOutputs {
root = ./.; root = ./.;
renameOutputs = {"helix-term" = "helix";}; renameOutputs = {"helix-term" = "helix";};
# Set default app to hx (binary is from helix-term release build) # Set default app to hx (binary is from helix-term release build)
@ -36,53 +42,58 @@
then gcc then gcc
else clang; else clang;
crateOverrides = common: _: { crateOverrides = common: _: {
helix-term = prev: let helix-term = prev: {
inherit (common) pkgs; src = builtins.path {
mkRootPath = rel: name = "helix-source";
builtins.path { path = toString ./.;
path = "${common.root}/${rel}"; # filter out unneeded stuff that cause rebuilds
name = rel; filter = path: type:
lib.all
(n: builtins.baseNameOf path != n)
[
".envrc"
".ignore"
".github"
"runtime"
"screenshot.png"
"book"
"contrib"
"docs"
"README.md"
"shell.nix"
"default.nix"
"grammars.nix"
"flake.nix"
"flake.lock"
];
}; };
grammars = pkgs.callPackage ./grammars.nix config;
runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
mkdir -p $out
ln -s ${mkRootPath "runtime"}/* $out
rm -r $out/grammars
ln -s ${grammars} $out/grammars
'';
overridedAttrs = {
# disable fetching and building of tree-sitter grammars in the helix-term build.rs # disable fetching and building of tree-sitter grammars in the helix-term build.rs
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
# link languages and theme toml files since helix-term expects them (for tests) # link languages and theme toml files since helix-term expects them (for tests)
preConfigure = preConfigure = ''
pkgs.lib.concatMapStringsSep ${prev.preConfigure or ""}
${
lib.concatMapStringsSep
"\n" "\n"
(path: "ln -sf ${mkRootPath path} ..") (path: "ln -sf ${mkRootPath path} ..")
["languages.toml" "theme.toml" "base16_theme.toml"]; ["languages.toml" "theme.toml" "base16_theme.toml"]
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib]; }
nativeBuildInputs = [pkgs.makeWrapper];
postFixup = ''
if [ -f "$out/bin/hx" ]; then
wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
fi
''; '';
meta.mainProgram = "hx";
}; };
in
overridedAttrs
// (
pkgs.lib.optionalAttrs
(config ? makeWrapperArgs)
{inherit (config) makeWrapperArgs;}
);
}; };
shell = common: prev: { shell = common: prev: {
packages = packages =
prev.packages prev.packages
++ ( ++ (
with common.pkgs; with common.pkgs;
[lld_13 lldb cargo-flamegraph rust-analyzer] ++ [lld_13 lldb cargo-flamegraph rust-analyzer]
(lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
); );
env = env =
prev.env prev.env
@ -106,29 +117,59 @@
}; };
}; };
}; };
defaultOutputs = outputs {}; makeOverridableHelix = system: old: config: let
makeOverridableHelix = system: old: pkgs = nixpkgs.legacyPackages.${system};
old grammars = pkgs.callPackage ./grammars.nix config;
// { runtimeDir = pkgs.runCommand "helix-runtime" {} ''
override = args: mkdir -p $out
makeOverridableHelix ln -s ${mkRootPath "runtime"}/* $out
system rm -r $out/grammars
(outputs args).packages.${system}.helix; 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 in
defaultOutputs helix-wrapped
// {override = makeOverridableHelix system old;};
in
outputs
// { // {
apps =
lib.mapAttrs
(
system: apps: rec {
default = hx;
hx = {
type = "app";
program = lib.getExe self.${system}.packages.helix;
};
}
)
outputs.apps;
packages = packages =
nixpkgs.lib.mapAttrs lib.mapAttrs
( (
system: packages: system: packages: rec {
packages
// rec {
default = helix; default = helix;
helix = makeOverridableHelix system packages.helix; helix = makeOverridableHelix system helix-unwrapped {};
helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
helix-unwrapped = packages.helix;
helix-unwrapped-debug = packages.helix-debug;
} }
) )
defaultOutputs.packages; outputs.packages;
}; };
nixConfig = { nixConfig = {

Loading…
Cancel
Save