on master help sign in
build(nix): update nci, fixup flake (#4537)
3881fefYusuf Bera Ertan
flake.lock+53−18
@@ -1,5 +1,22 @@
1{
1{
2 "nodes": {
2 "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+ },
3 "crane": {
20 "crane": {
4 "flake": false,
21 "flake": false,
5 "locked": {
22 "locked": {
@@ -19,11 +36,11 @@
19 "devshell": {
36 "devshell": {
20 "flake": false,
37 "flake": false,
21 "locked": {
38 "locked": {
22− "lastModified": 1660811669,
39+ "lastModified": 1666548262,
23− "narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=",
40+ "narHash": "sha256-4DyN4KXqQQsCw0vCXkMThw4b5Q4/q87ZZgRb4st8COc=",
24 "owner": "numtide",
41 "owner": "numtide",
25 "repo": "devshell",
42 "repo": "devshell",
26− "rev": "c2feacb46ee69949124c835419861143c4016fb5",
43+ "rev": "c8ce8ed81726079c398f5f29c4b68a7d6a3c2fa2",
27 "type": "github"
44 "type": "github"
28 },
45 },
29 "original": {
46 "original": {
@@ -38,6 +55,7 @@
38 "nci",
55 "nci",
39 "nixpkgs"
56 "nixpkgs"
40 ],
57 ],
58+ "all-cabal-json": "all-cabal-json",
41 "crane": "crane",
59 "crane": "crane",
42 "devshell": [
60 "devshell": [
43 "nci",
61 "nci",
@@ -47,6 +65,7 @@
47 "nci",
65 "nci",
48 "nixpkgs"
66 "nixpkgs"
49 ],
67 ],
68+ "ghc-utils": "ghc-utils",
50 "gomod2nix": [
69 "gomod2nix": [
51 "nci",
70 "nci",
52 "nixpkgs"
71 "nixpkgs"
@@ -69,11 +88,11 @@
69 ]
88 ]
70 },
89 },
71 "locked": {
90 "locked": {
72− "lastModified": 1662176993,
91+ "lastModified": 1666993587,
73− "narHash": "sha256-Sy7DsGAveDUFBb6YDsUSYZd/AcXfP/MOMIwMt/NgY84=",
92+ "narHash": "sha256-4cLrs+CwWnceYXnCpL5gO3bybS9CjLxUoTEKjB2QFtg=",
74 "owner": "nix-community",
93 "owner": "nix-community",
75 "repo": "dream2nix",
94 "repo": "dream2nix",
76− "rev": "809bc5940214744eb29778a9a0b03f161979c1b2",
95+ "rev": "2b7456e3d2f0053bc2474fb0c461dd468545277f",
77 "type": "github"
96 "type": "github"
78 },
97 },
79 "original": {
98 "original": {
@@ -84,11 +103,11 @@
84 },
103 },
85 "flake-utils": {
104 "flake-utils": {
86 "locked": {
105 "locked": {
87− "lastModified": 1656928814,
106+ "lastModified": 1659877975,
88− "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
107+ "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
89 "owner": "numtide",
108 "owner": "numtide",
90 "repo": "flake-utils",
109 "repo": "flake-utils",
91− "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
110+ "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
92 "type": "github"
111 "type": "github"
93 },
112 },
94 "original": {
113 "original": {
@@ -97,6 +116,22 @@
97 "type": "github"
116 "type": "github"
98 }
117 }
99 },
118 },
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+ },
100 "nci": {
135 "nci": {
101 "inputs": {
136 "inputs": {
102 "devshell": "devshell",
137 "devshell": "devshell",
@@ -109,11 +144,11 @@
109 ]
144 ]
110 },
145 },
111 "locked": {
146 "locked": {
112− "lastModified": 1662177071,
147+ "lastModified": 1667232647,
113− "narHash": "sha256-x6XF//RdZlw81tFAYM1TkjY+iQIpyMCWZ46r9o4wVQY=",
148+ "narHash": "sha256-cFo7G8BqYShgL9m7yD6p+SHAZ+aIt2guuF69LV235n8=",
114 "owner": "yusdacra",
149 "owner": "yusdacra",
115 "repo": "nix-cargo-integration",
150 "repo": "nix-cargo-integration",
116− "rev": "65270dea87bb82fc02102a15221677eea237680e",
151+ "rev": "16082f7b4e42ce140a562fa630bcf8e96eadeb59",
117 "type": "github"
152 "type": "github"
118 },
153 },
119 "original": {
154 "original": {
@@ -124,11 +159,11 @@
124 },
159 },
125 "nixpkgs": {
160 "nixpkgs": {
126 "locked": {
161 "locked": {
127− "lastModified": 1662019588,
162+ "lastModified": 1667142599,
128− "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
163+ "narHash": "sha256-OLJxsg9VqfKjFkerOxWtNIkibsCvxsv5A8wNWO1MeWk=",
129 "owner": "nixos",
164 "owner": "nixos",
130 "repo": "nixpkgs",
165 "repo": "nixpkgs",
131− "rev": "2da64a81275b68fdad38af669afeda43d401e94b",
166+ "rev": "412b9917cea092f3d39f9cd5dead4effd5bc4053",
132 "type": "github"
167 "type": "github"
133 },
168 },
134 "original": {
169 "original": {
@@ -153,11 +188,11 @@
153 ]
188 ]
154 },
189 },
155 "locked": {
190 "locked": {
156− "lastModified": 1662087605,
191+ "lastModified": 1667184938,
157− "narHash": "sha256-Gpf2gp2JenKGf+TylX/YJpttY2bzsnvAMLdLaxoZRyU=",
192+ "narHash": "sha256-/kuCiXuAxiD0c0zrfDvJ1Yba3FuVdRk/ROfb393AeX4=",
158 "owner": "oxalica",
193 "owner": "oxalica",
159 "repo": "rust-overlay",
194 "repo": "rust-overlay",
160− "rev": "60c2cfaa8b90ed8cebd18b214fac8682dcf222dd",
195+ "rev": "8f81faec35508647ced65c44fd3e8648a5518afb",
161 "type": "github"
196 "type": "github"
162 },
197 },
163 "original": {
198 "original": {
flake.nix+112−113
@@ -21,57 +21,124 @@
21 ...
21 ...
22 }: let
22 }: let
23 lib = nixpkgs.lib;
23 lib = nixpkgs.lib;
24+ ncl = nci.lib.nci-lib;
24 mkRootPath = rel:
25 mkRootPath = rel:
25 builtins.path {
26 builtins.path {
26 path = "${toString ./.}/${rel}";
27 path = "${toString ./.}/${rel}";
27 name = rel;
28 name = rel;
28 };
29 };
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+ };
29 outputs = nci.lib.makeOutputs {
64 outputs = nci.lib.makeOutputs {
30 root = ./.;
65 root = ./.;
66+ config = common: {
67+ outputs = {
68+ # rename helix-term to helix since it's our main package
31− renameOutputs = {"helix-term" = "helix";};
69+ rename = {"helix-term" = "helix";};
32− # Set default app to hx (binary is from helix-term release build)
70+ # Set default app to hx (binary is from helix-term release build)
33− # Set default package to helix-term release build
71+ # Set default package to helix-term release build
34− defaultOutputs = {
72+ defaults = {
35− app = "hx";
73+ app = "hx";
36− package = "helix";
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+ };
37 };
104 };
38− overrides = {
105+ pkgConfig = common: {
39− cCompiler = common:
106+ helix-term = {
40− with common.pkgs;
107+ # Wrap helix with runtime
41− if stdenv.isLinux
108+ wrapper = _: old: let
42− then gcc
109+ inherit (common) pkgs;
43− else clang;
110+ makeOverridableHelix = old: config: let
44− crateOverrides = common: _: {
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
45− helix-term = prev: {
131+ helix-wrapped
46− src = builtins.path {
132+ // {override = makeOverridableHelix old;};
47− name = "helix-source";
133+ in
48− path = toString ./.;
134+ makeOverridableHelix old {};
49− # filter out unneeded stuff that cause rebuilds
135+ overrides.fix-build.overrideAttrs = prev: {
50− filter = path: type:
136+ src = filteredSource;
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− };
70
137
71 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
138 # disable fetching and building of tree-sitter grammars in the helix-term build.rs
72 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
139 HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
73
140
74− buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
141+ buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib];
75
142
76 # link languages and theme toml files since helix-term expects them (for tests)
143 # link languages and theme toml files since helix-term expects them (for tests)
77 preConfigure = ''
144 preConfigure = ''
@@ -87,88 +154,20 @@
87 meta.mainProgram = "hx";
154 meta.mainProgram = "hx";
88 };
155 };
89 };
156 };
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− };
119 };
157 };
120 };
158 };
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;};
147 in
159 in
148 outputs
160 outputs
149 // {
161 // {
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;
162 packages =
162 packages =
163 lib.mapAttrs
163 lib.mapAttrs
164 (
164 (
165− system: packages: rec {
165+ system: packages:
166− default = helix;
166+ packages
167− helix = makeOverridableHelix system helix-unwrapped {};
167+ // {
168− helix-debug = makeOverridableHelix system helix-unwrapped-debug {};
169− helix-unwrapped = packages.helix;
168+ helix-unwrapped = packages.helix.passthru.unwrapped;
170− helix-unwrapped-debug = packages.helix-debug;
169+ helix-unwrapped-debug = packages.helix-debug.passthru.unwrapped;
171− }
170+ }
172 )
171 )
173 outputs.packages;
172 outputs.packages;
174 };
173 };