on master help sign in
build(nix): update nci, fixup flake (#4537)
commit3881fef39d01c94a09b8f5da67decc2c3ccb3660 authorYusuf Bera Ertan <y.bera003.06@protonmail.com> dateTue 1 Nov 2022, 03:52 (4 years ago) parente5319ea
2 files changed+165−131
flake.lock+53−18 flake.nix+112−113
flake.lock+53−18
@@ -1,5 +1,22 @@
11{
22 "nodes": {
3+ "all-cabal-json": {
4+ "flake": false,
5+ "locked": {
6+ "lastModified": 1665552503,
7+ "narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=",
8+ "owner": "nix-community",
9+ "repo": "all-cabal-json",
10+ "rev": "d7c0434eebffb305071404edcf9d5cd99703878e",
11+ "type": "github"
12+ },
13+ "original": {
14+ "owner": "nix-community",
15+ "ref": "hackage",
16+ "repo": "all-cabal-json",
17+ "type": "github"
18+ }
19+ },
320 "crane": {
421 "flake": false,
522 "locked": {
@@ -19,11 +36,11 @@
1936 "devshell": {
2037 "flake": false,
2138 "locked": {
22− "lastModified": 1660811669,
23− "narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=",
39+ "lastModified": 1666548262,
40+ "narHash": "sha256-4DyN4KXqQQsCw0vCXkMThw4b5Q4/q87ZZgRb4st8COc=",
2441 "owner": "numtide",
2542 "repo": "devshell",
26− "rev": "c2feacb46ee69949124c835419861143c4016fb5",
43+ "rev": "c8ce8ed81726079c398f5f29c4b68a7d6a3c2fa2",
2744 "type": "github"
2845 },
2946 "original": {
@@ -38,6 +55,7 @@
3855 "nci",
3956 "nixpkgs"
4057 ],
58+ "all-cabal-json": "all-cabal-json",
4159 "crane": "crane",
4260 "devshell": [
4361 "nci",
@@ -47,6 +65,7 @@
4765 "nci",
4866 "nixpkgs"
4967 ],
68+ "ghc-utils": "ghc-utils",
5069 "gomod2nix": [
5170 "nci",
5271 "nixpkgs"
@@ -69,11 +88,11 @@
6988 ]
7089 },
7190 "locked": {
72− "lastModified": 1662176993,
73− "narHash": "sha256-Sy7DsGAveDUFBb6YDsUSYZd/AcXfP/MOMIwMt/NgY84=",
91+ "lastModified": 1666993587,
92+ "narHash": "sha256-4cLrs+CwWnceYXnCpL5gO3bybS9CjLxUoTEKjB2QFtg=",
7493 "owner": "nix-community",
7594 "repo": "dream2nix",
76− "rev": "809bc5940214744eb29778a9a0b03f161979c1b2",
95+ "rev": "2b7456e3d2f0053bc2474fb0c461dd468545277f",
7796 "type": "github"
7897 },
7998 "original": {
@@ -84,11 +103,11 @@
84103 },
85104 "flake-utils": {
86105 "locked": {
87− "lastModified": 1656928814,
88− "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
106+ "lastModified": 1659877975,
107+ "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
89108 "owner": "numtide",
90109 "repo": "flake-utils",
91− "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
110+ "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
92111 "type": "github"
93112 },
94113 "original": {
@@ -97,6 +116,22 @@
97116 "type": "github"
98117 }
99118 },
119+ "ghc-utils": {
120+ "flake": false,
121+ "locked": {
122+ "lastModified": 1662774800,
123+ "narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
124+ "ref": "refs/heads/master",
125+ "rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
126+ "revCount": 1072,
127+ "type": "git",
128+ "url": "https://gitlab.haskell.org/bgamari/ghc-utils"
129+ },
130+ "original": {
131+ "type": "git",
132+ "url": "https://gitlab.haskell.org/bgamari/ghc-utils"
133+ }
134+ },
100135 "nci": {
101136 "inputs": {
102137 "devshell": "devshell",
@@ -109,11 +144,11 @@
109144 ]
110145 },
111146 "locked": {
112− "lastModified": 1662177071,
113− "narHash": "sha256-x6XF//RdZlw81tFAYM1TkjY+iQIpyMCWZ46r9o4wVQY=",
147+ "lastModified": 1667232647,
148+ "narHash": "sha256-cFo7G8BqYShgL9m7yD6p+SHAZ+aIt2guuF69LV235n8=",
114149 "owner": "yusdacra",
115150 "repo": "nix-cargo-integration",
116− "rev": "65270dea87bb82fc02102a15221677eea237680e",
151+ "rev": "16082f7b4e42ce140a562fa630bcf8e96eadeb59",
117152 "type": "github"
118153 },
119154 "original": {
@@ -124,11 +159,11 @@
124159 },
125160 "nixpkgs": {
126161 "locked": {
127− "lastModified": 1662019588,
128− "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
162+ "lastModified": 1667142599,
163+ "narHash": "sha256-OLJxsg9VqfKjFkerOxWtNIkibsCvxsv5A8wNWO1MeWk=",
129164 "owner": "nixos",
130165 "repo": "nixpkgs",
131− "rev": "2da64a81275b68fdad38af669afeda43d401e94b",
166+ "rev": "412b9917cea092f3d39f9cd5dead4effd5bc4053",
132167 "type": "github"
133168 },
134169 "original": {
@@ -153,11 +188,11 @@
153188 ]
154189 },
155190 "locked": {
156− "lastModified": 1662087605,
157− "narHash": "sha256-Gpf2gp2JenKGf+TylX/YJpttY2bzsnvAMLdLaxoZRyU=",
191+ "lastModified": 1667184938,
192+ "narHash": "sha256-/kuCiXuAxiD0c0zrfDvJ1Yba3FuVdRk/ROfb393AeX4=",
158193 "owner": "oxalica",
159194 "repo": "rust-overlay",
160− "rev": "60c2cfaa8b90ed8cebd18b214fac8682dcf222dd",
195+ "rev": "8f81faec35508647ced65c44fd3e8648a5518afb",
161196 "type": "github"
162197 },
163198 "original": {
flake.nix+112−113
@@ -21,57 +21,124 @@
2121 ...
2222 }: let
2323 lib = nixpkgs.lib;
24+ ncl = nci.lib.nci-lib;
2425 mkRootPath = rel:
2526 builtins.path {
2627 path = "${toString ./.}/${rel}";
2728 name = rel;
2829 };
30+ filteredSource = let
31+ pathsToIgnore = [
32+ ".envrc"
33+ ".ignore"
34+ ".github"
35+ "runtime"
36+ "screenshot.png"
37+ "book"
38+ "contrib"
39+ "docs"
40+ "README.md"
41+ "CHANGELOG.md"
42+ "shell.nix"
43+ "default.nix"
44+ "grammars.nix"
45+ "flake.nix"
46+ "flake.lock"
47+ ];
48+ ignorePaths = path: type: let
49+ # split the nix store path into its components
50+ components = lib.splitString "/" path;
51+ # drop off the `/nix/hash-source` section from the path
52+ relPathComponents = lib.drop 4 components;
53+ # reassemble the path components
54+ relPath = lib.concatStringsSep "/" relPathComponents;
55+ in
56+ lib.all (p: ! (lib.hasPrefix p relPath)) pathsToIgnore;
57+ in
58+ builtins.path {
59+ name = "helix-source";
60+ path = toString ./.;
61+ # filter out unnecessary paths
62+ filter = ignorePaths;
63+ };
2964 outputs = nci.lib.makeOutputs {
3065 root = ./.;
31− renameOutputs = {"helix-term" = "helix";};
32− # Set default app to hx (binary is from helix-term release build)
33− # Set default package to helix-term release build
34− defaultOutputs = {
35− app = "hx";
36− package = "helix";
66+ config = common: {
67+ outputs = {
68+ # rename helix-term to helix since it's our main package
69+ rename = {"helix-term" = "helix";};
70+ # Set default app to hx (binary is from helix-term release build)
71+ # Set default package to helix-term release build
72+ defaults = {
73+ app = "hx";
74+ package = "helix";
75+ };
76+ };
77+ cCompiler.package = with common.pkgs;
78+ if stdenv.isLinux
79+ then gcc
80+ else clang;
81+ shell = {
82+ packages = with common.pkgs;
83+ [lld_13 cargo-flamegraph rust-analyzer]
84+ ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
85+ ++ (lib.optional stdenv.isLinux lldb);
86+ env = [
87+ {
88+ name = "HELIX_RUNTIME";
89+ eval = "$PWD/runtime";
90+ }
91+ {
92+ name = "RUST_BACKTRACE";
93+ value = "1";
94+ }
95+ {
96+ name = "RUSTFLAGS";
97+ value =
98+ if common.pkgs.stdenv.isLinux
99+ then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
100+ else "";
101+ }
102+ ];
103+ };
37104 };
38− overrides = {
39− cCompiler = common:
40− with common.pkgs;
41− if stdenv.isLinux
42− then gcc
43− else clang;
44− crateOverrides = common: _: {
45− helix-term = prev: {
46− src = builtins.path {
47− name = "helix-source";
48− path = toString ./.;
49− # filter out unneeded stuff that cause rebuilds
50− filter = path: type:
51− lib.all
52− (n: builtins.baseNameOf path != n)
53− [
54− ".envrc"
55− ".ignore"
56− ".github"
57− "runtime"
58− "screenshot.png"
59− "book"
60− "contrib"
61− "docs"
62− "README.md"
63− "shell.nix"
64− "default.nix"
65− "grammars.nix"
66− "flake.nix"
67− "flake.lock"
68− ];
69− };
105+ pkgConfig = common: {
106+ helix-term = {
107+ # Wrap helix with runtime
108+ wrapper = _: old: let
109+ inherit (common) pkgs;
110+ makeOverridableHelix = old: config: let
111+ grammars = pkgs.callPackage ./grammars.nix config;
112+ runtimeDir = pkgs.runCommand "helix-runtime" {} ''
113+ mkdir -p $out
114+ ln -s ${mkRootPath "runtime"}/* $out
115+ rm -r $out/grammars
116+ ln -s ${grammars} $out/grammars
117+ '';
118+ helix-wrapped =
119+ common.internal.pkgsSet.utils.wrapDerivation old
120+ {
121+ nativeBuildInputs = [pkgs.makeWrapper];
122+ makeWrapperArgs = config.makeWrapperArgs or [];
123+ }
124+ ''
125+ rm -rf $out/bin
126+ mkdir -p $out/bin
127+ ln -sf ${old}/bin/* $out/bin/
128+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
129+ '';
130+ in
131+ helix-wrapped
132+ // {override = makeOverridableHelix old;};
133+ in
134+ makeOverridableHelix old {};
135+ overrides.fix-build.overrideAttrs = prev: {
136+ src = filteredSource;
70137
71138 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
72139 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
73140
74− buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
141+ buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib];
75142
76143 # link languages and theme toml files since helix-term expects them (for tests)
77144 preConfigure = ''
@@ -87,88 +154,20 @@
87154 meta.mainProgram = "hx";
88155 };
89156 };
90− shell = common: prev: {
91− packages =
92− prev.packages
93− ++ (
94− with common.pkgs;
95− [lld_13 cargo-flamegraph rust-analyzer]
96− ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
97− ++ (lib.optional stdenv.isLinux lldb)
98− );
99− env =
100− prev.env
101− ++ [
102− {
103− name = "HELIX_RUNTIME";
104− eval = "$PWD/runtime";
105− }
106− {
107− name = "RUST_BACKTRACE";
108− value = "1";
109− }
110− {
111− name = "RUSTFLAGS";
112− value =
113− if common.pkgs.stdenv.isLinux
114− then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
115− else "";
116− }
117− ];
118− };
119157 };
120158 };
121− makeOverridableHelix = system: old: config: let
122− pkgs = nixpkgs.legacyPackages.${system};
123− grammars = pkgs.callPackage ./grammars.nix config;
124− runtimeDir = pkgs.runCommand "helix-runtime" {} ''
125− mkdir -p $out
126− ln -s ${mkRootPath "runtime"}/* $out
127− rm -r $out/grammars
128− ln -s ${grammars} $out/grammars
129− '';
130− helix-wrapped =
131− pkgs.runCommand "${old.name}-wrapped"
132− {
133− inherit (old) pname version meta;
134−
135− nativeBuildInputs = [pkgs.makeWrapper];
136− makeWrapperArgs = config.makeWrapperArgs or [];
137− }
138− ''
139− mkdir -p $out
140− cp -r --no-preserve=mode,ownership ${old}/* $out/
141− chmod +x $out/bin/*
142− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
143− '';
144− in
145− helix-wrapped
146− // {override = makeOverridableHelix system old;};
147159 in
148160 outputs
149161 // {
150− apps =
151− lib.mapAttrs
152− (
153− system: apps: rec {
154− default = hx;
155− hx = {
156− type = "app";
157− program = lib.getExe self.${system}.packages.helix;
158− };
159− }
160− )
161− outputs.apps;
162162 packages =
163163 lib.mapAttrs
164164 (
165− system: packages: rec {
166− default = helix;
167− helix = makeOverridableHelix system helix-unwrapped {};
168− helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
169− helix-unwrapped = packages.helix;
170− helix-unwrapped-debug = packages.helix-debug;
171− }
165+ system: packages:
166+ packages
167+ // {
168+ helix-unwrapped = packages.helix.passthru.unwrapped;
169+ helix-unwrapped-debug = packages.helix-debug.passthru.unwrapped;
170+ }
172171 )
173172 outputs.packages;
174173 };