on master help sign in
build(nix): update flake to use flake-parts and nci flake-parts module
e5af0f1Yusuf Bera Ertan
flake.lock+80−52
@@ -16,22 +16,6 @@
16 "type": "github"
16 "type": "github"
17 }
17 }
18 },
18 },
19− "devshell": {
20− "flake": false,
21− "locked": {
22− "lastModified": 1667210711,
23− "narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=",
24− "owner": "numtide",
25− "repo": "devshell",
26− "rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7",
27− "type": "github"
28− },
29− "original": {
30− "owner": "numtide",
31− "repo": "devshell",
32− "type": "github"
33− }
34− },
35 "dream2nix": {
19 "dream2nix": {
36 "inputs": {
20 "inputs": {
37 "alejandra": [
21 "alejandra": [
@@ -42,10 +26,12 @@
42 ],
26 ],
43 "crane": "crane",
27 "crane": "crane",
44 "devshell": [
28 "devshell": [
29+ "nci"
30+ ],
31+ "flake-parts": [
45 "nci",
32 "nci",
46− "devshell"
33+ "parts"
47 ],
34 ],
48− "flake-parts": "flake-parts",
49 "flake-utils-pre-commit": [
35 "flake-utils-pre-commit": [
50 "nci"
36 "nci"
51 ],
37 ],
@@ -70,14 +56,17 @@
70 ],
56 ],
71 "pre-commit-hooks": [
57 "pre-commit-hooks": [
72 "nci"
58 "nci"
59+ ],
60+ "pruned-racket-catalog": [
61+ "nci"
73 ]
62 ]
74 },
63 },
75 "locked": {
64 "locked": {
76− "lastModified": 1671323629,
65+ "lastModified": 1677289985,
77− "narHash": "sha256-9KHTPjIDjfnzZ4NjpE3gGIVHVHopy6weRDYO/7Y3hF8=",
66+ "narHash": "sha256-lUp06cTTlWubeBGMZqPl9jODM99LpWMcwxRiscFAUJg=",
78 "owner": "nix-community",
67 "owner": "nix-community",
79 "repo": "dream2nix",
68 "repo": "dream2nix",
80− "rev": "2d7d68505c8619410df2c6b6463985f97cbcba6e",
69+ "rev": "28b973a8d4c30cc1cbb3377ea2023a76bc3fb889",
81 "type": "github"
70 "type": "github"
82 },
71 },
83 "original": {
72 "original": {
@@ -86,24 +75,6 @@
86 "type": "github"
75 "type": "github"
87 }
76 }
88 },
77 },
89− "flake-parts": {
90− "inputs": {
91− "nixpkgs-lib": "nixpkgs-lib"
92− },
93− "locked": {
94− "lastModified": 1668450977,
95− "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=",
96− "owner": "hercules-ci",
97− "repo": "flake-parts",
98− "rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa",
99− "type": "github"
100− },
101− "original": {
102− "owner": "hercules-ci",
103− "repo": "flake-parts",
104− "type": "github"
105− }
106− },
107 "flake-utils": {
78 "flake-utils": {
108 "locked": {
79 "locked": {
109 "lastModified": 1659877975,
80 "lastModified": 1659877975,
@@ -119,23 +90,40 @@
119 "type": "github"
90 "type": "github"
120 }
91 }
121 },
92 },
93+ "mk-naked-shell": {
94+ "flake": false,
95+ "locked": {
96+ "lastModified": 1676572903,
97+ "narHash": "sha256-oQoDHHUTxNVSURfkFcYLuAK+btjs30T4rbEUtCUyKy8=",
98+ "owner": "yusdacra",
99+ "repo": "mk-naked-shell",
100+ "rev": "aeca9f8aa592f5e8f71f407d081cb26fd30c5a57",
101+ "type": "github"
102+ },
103+ "original": {
104+ "owner": "yusdacra",
105+ "repo": "mk-naked-shell",
106+ "type": "github"
107+ }
108+ },
122 "nci": {
109 "nci": {
123 "inputs": {
110 "inputs": {
124− "devshell": "devshell",
125 "dream2nix": "dream2nix",
111 "dream2nix": "dream2nix",
112+ "mk-naked-shell": "mk-naked-shell",
126 "nixpkgs": [
113 "nixpkgs": [
127 "nixpkgs"
114 "nixpkgs"
128 ],
115 ],
116+ "parts": "parts",
129 "rust-overlay": [
117 "rust-overlay": [
130 "rust-overlay"
118 "rust-overlay"
131 ]
119 ]
132 },
120 },
133 "locked": {
121 "locked": {
134− "lastModified": 1671430291,
122+ "lastModified": 1677294491,
135− "narHash": "sha256-UIc7H8F3N8rK72J/Vj5YJdV72tvDvYjH+UPsOFvlcsE=",
123+ "narHash": "sha256-p09IOJqhUOM6egRJe4Ou1EXdTs/I9Pmm8e7pMYDlIWM=",
136 "owner": "yusdacra",
124 "owner": "yusdacra",
137 "repo": "nix-cargo-integration",
125 "repo": "nix-cargo-integration",
138− "rev": "b1b0d38b8c3b0d0e6a38638d5bbe10b0bc67522c",
126+ "rev": "a525ed36c440854f296cd958f4ebf574f0ebe22c",
139 "type": "github"
127 "type": "github"
140 },
128 },
141 "original": {
129 "original": {
@@ -146,11 +134,11 @@
146 },
134 },
147 "nixpkgs": {
135 "nixpkgs": {
148 "locked": {
136 "locked": {
149− "lastModified": 1671359686,
137+ "lastModified": 1677063315,
150− "narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=",
138+ "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=",
151 "owner": "nixos",
139 "owner": "nixos",
152 "repo": "nixpkgs",
140 "repo": "nixpkgs",
153− "rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4",
141+ "rev": "988cc958c57ce4350ec248d2d53087777f9e1949",
154 "type": "github"
142 "type": "github"
155 },
143 },
156 "original": {
144 "original": {
@@ -163,11 +151,11 @@
163 "nixpkgs-lib": {
151 "nixpkgs-lib": {
164 "locked": {
152 "locked": {
165 "dir": "lib",
153 "dir": "lib",
166− "lastModified": 1665349835,
154+ "lastModified": 1675183161,
167− "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=",
155+ "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",
168 "owner": "NixOS",
156 "owner": "NixOS",
169 "repo": "nixpkgs",
157 "repo": "nixpkgs",
170− "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1",
158+ "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",
171 "type": "github"
159 "type": "github"
172 },
160 },
173 "original": {
161 "original": {
@@ -178,10 +166,50 @@
178 "type": "github"
166 "type": "github"
179 }
167 }
180 },
168 },
169+ "parts": {
170+ "inputs": {
171+ "nixpkgs-lib": [
172+ "nci",
173+ "nixpkgs"
174+ ]
175+ },
176+ "locked": {
177+ "lastModified": 1675933616,
178+ "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
179+ "owner": "hercules-ci",
180+ "repo": "flake-parts",
181+ "rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
182+ "type": "github"
183+ },
184+ "original": {
185+ "owner": "hercules-ci",
186+ "repo": "flake-parts",
187+ "type": "github"
188+ }
189+ },
190+ "parts_2": {
191+ "inputs": {
192+ "nixpkgs-lib": "nixpkgs-lib"
193+ },
194+ "locked": {
195+ "lastModified": 1675933616,
196+ "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
197+ "owner": "hercules-ci",
198+ "repo": "flake-parts",
199+ "rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
200+ "type": "github"
201+ },
202+ "original": {
203+ "owner": "hercules-ci",
204+ "repo": "flake-parts",
205+ "type": "github"
206+ }
207+ },
181 "root": {
208 "root": {
182 "inputs": {
209 "inputs": {
183 "nci": "nci",
210 "nci": "nci",
184 "nixpkgs": "nixpkgs",
211 "nixpkgs": "nixpkgs",
212+ "parts": "parts_2",
185 "rust-overlay": "rust-overlay"
213 "rust-overlay": "rust-overlay"
186 }
214 }
187 },
215 },
@@ -193,11 +221,11 @@
193 ]
221 ]
194 },
222 },
195 "locked": {
223 "locked": {
196− "lastModified": 1671416426,
224+ "lastModified": 1677292251,
197− "narHash": "sha256-kpSH1Jrxfk2qd0pRPJn1eQdIOseGv5JuE+YaOrqU9s4=",
225+ "narHash": "sha256-D+6q5Z2MQn3UFJtqsM5/AvVHi3NXKZTIMZt1JGq/spA=",
198 "owner": "oxalica",
226 "owner": "oxalica",
199 "repo": "rust-overlay",
227 "repo": "rust-overlay",
200− "rev": "fbaaff24f375ac25ec64268b0a0d63f91e474b7d",
228+ "rev": "34cdbf6ad480ce13a6a526f57d8b9e609f3d65dc",
201 "type": "github"
229 "type": "github"
202 },
230 },
203 "original": {
231 "original": {
flake.nix+100−117
@@ -12,16 +12,10 @@
12 inputs.nixpkgs.follows = "nixpkgs";
12 inputs.nixpkgs.follows = "nixpkgs";
13 inputs.rust-overlay.follows = "rust-overlay";
13 inputs.rust-overlay.follows = "rust-overlay";
14 };
14 };
15+ parts.url = "github:hercules-ci/flake-parts";
15 };
16 };
16
17
17− outputs = {
18+ outputs = inp: let
18− self,
19− nixpkgs,
20− nci,
21− ...
22− }: let
23− lib = nixpkgs.lib;
24− ncl = nci.lib.nci-lib;
25 mkRootPath = rel:
19 mkRootPath = rel:
26 builtins.path {
20 builtins.path {
27 path = "${toString ./.}/${rel}";
21 path = "${toString ./.}/${rel}";
@@ -32,6 +26,12 @@
32 ".envrc"
26 ".envrc"
33 ".ignore"
27 ".ignore"
34 ".github"
28 ".github"
29+ ".gitignore"
30+ "logo.svg"
31+ "logo_dark.svg"
32+ "logo_light.svg"
33+ "rust-toolchain.toml"
34+ "rustfmt.toml"
35 "runtime"
35 "runtime"
36 "screenshot.png"
36 "screenshot.png"
37 "book"
37 "book"
@@ -46,6 +46,7 @@
46 "flake.lock"
46 "flake.lock"
47 ];
47 ];
48 ignorePaths = path: type: let
48 ignorePaths = path: type: let
49+ inherit (inp.nixpkgs) lib;
49 # split the nix store path into its components
50 # split the nix store path into its components
50 components = lib.splitString "/" path;
51 components = lib.splitString "/" path;
51 # drop off the `/nix/hash-source` section from the path
52 # drop off the `/nix/hash-source` section from the path
@@ -61,123 +62,105 @@
61 # filter out unnecessary paths
62 # filter out unnecessary paths
62 filter = ignorePaths;
63 filter = ignorePaths;
63 };
64 };
64− outputs = nci.lib.makeOutputs {
65+ in
65− root = ./.;
66+ inp.parts.lib.mkFlake {inputs = inp;} {
66− config = common: {
67+ imports = [inp.nci.flakeModule];
67− outputs = {
68+ systems = [
68− # rename helix-term to helix since it's our main package
69+ "x86_64-linux"
69− rename = {"helix-term" = "helix";};
70+ "x86_64-darwin"
70− # Set default app to hx (binary is from helix-term release build)
71+ "aarch64-linux"
71− # Set default package to helix-term release build
72+ "aarch64-darwin"
72− defaults = {
73+ "i686-linux"
73− app = "hx";
74+ ];
74− package = "helix";
75+ perSystem = {
75− };
76+ config,
76− };
77+ pkgs,
77− cCompiler.package = with common.pkgs;
78+ lib,
78− if stdenv.isLinux
79+ ...
79− then gcc
80+ }: let
80− else clang;
81+ makeOverridableHelix = old: config: let
81− shell = {
82+ grammars = pkgs.callPackage ./grammars.nix config;
82− packages = with common.pkgs;
83+ runtimeDir = pkgs.runCommand "helix-runtime" {} ''
83− [lld_13 cargo-flamegraph rust-analyzer]
84+ mkdir -p $out
84− ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
85+ ln -s ${mkRootPath "runtime"}/* $out
85− ++ (lib.optional stdenv.isLinux lldb)
86+ rm -r $out/grammars
86− ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation);
87+ ln -s ${grammars} $out/grammars
87− env = [
88+ '';
88− {
89+ helix-wrapped =
89− name = "HELIX_RUNTIME";
90+ pkgs.runCommand
90− eval = "$PWD/runtime";
91+ old.name
91− }
92− {
93− name = "RUST_BACKTRACE";
94− value = "1";
95− }
96 {
92 {
97− name = "RUSTFLAGS";
93+ inherit (old) pname version;
98− eval =
94+ meta = old.meta or {};
99− if common.pkgs.stdenv.isLinux
95+ passthru =
100− then "$RUSTFLAGS\" -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment\""
96+ (old.passthru or {})
101− else "$RUSTFLAGS";
97+ // {
98+ unwrapped = old;
99+ };
100+ nativeBuildInputs = [pkgs.makeWrapper];
101+ makeWrapperArgs = config.makeWrapperArgs or [];
102 }
102 }
103− ];
103+ ''
104− };
104+ cp -rs --no-preserve=mode,ownership ${old} $out
105− };
106− pkgConfig = common: {
107− helix-term = let
108− # Wrap helix with runtime
109− wrapper = _: old: let
110− inherit (common) pkgs;
111− makeOverridableHelix = old: config: let
112− grammars = pkgs.callPackage ./grammars.nix config;
113− runtimeDir = pkgs.runCommand "helix-runtime" {} ''
114− mkdir -p $out
115− ln -s ${mkRootPath "runtime"}/* $out
116− rm -r $out/grammars
117− ln -s ${grammars} $out/grammars
118− '';
119− helix-wrapped =
120− common.internal.pkgsSet.utils.wrapDerivation old
121− {
122− nativeBuildInputs = [pkgs.makeWrapper];
123− makeWrapperArgs = config.makeWrapperArgs or [];
124− }
125− ''
126− rm -rf $out/bin
127− mkdir -p $out/bin
128− ln -sf ${old}/bin/* $out/bin/
129− wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
105+ wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}"
130− '';
106+ '';
131− in
107+ in
108+ helix-wrapped
109+ // {
110+ override = makeOverridableHelix old;
111+ passthru =
132− helix-wrapped
112+ helix-wrapped.passthru
133 // {
113 // {
134− override = makeOverridableHelix old;
114+ wrapper = old: makeOverridableHelix old config;
135− passthru = helix-wrapped.passthru // {wrapper = wrapper {};};
136 };
115 };
137− in
116+ };
138− makeOverridableHelix old {};
117+ stdenv =
118+ if pkgs.stdenv.isLinux
119+ then pkgs.stdenv
120+ else pkgs.clangStdenv;
121+ rustFlagsEnv =
122+ if stdenv.isLinux
123+ then "$RUSTFLAGS\" -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment\""
124+ else "$RUSTFLAGS";
139− in {
125+ in {
140− inherit wrapper;
126+ nci.projects."helix-project".relPath = "";
127+ nci.crates."helix-term" = {
128+ overrides = {
129+ add-meta.override = _: {meta.mainProgram = "hx";};
141− overrides.fix-build.overrideAttrs = prev: {
130+ add-inputs.overrideAttrs = prev: {
142− src = filteredSource;
131+ buildInputs = (prev.buildInputs or []) ++ [stdenv.cc.cc.lib];
143−
132+ };
133+ disable-grammar-builds = {
144− # disable fetching and building of tree-sitter grammars in the helix-term build.rs
134+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
145− HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
135+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
146−
136+ };
147− buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib];
148−
149− # link languages and theme toml files since helix-term expects them (for tests)
150− preConfigure = ''
151− ${prev.preConfigure or ""}
152− ${
153− lib.concatMapStringsSep
154− "\n"
155− (path: "ln -sf ${mkRootPath path} ..")
156− ["languages.toml" "theme.toml" "base16_theme.toml"]
157− }
158− '';
159− checkPhase = ":";
137+ disable-tests = {checkPhase = ":";};
160−
138+ set-stdenv.override = _: {inherit stdenv;};
161− meta.mainProgram = "hx";
139+ set-filtered-src.override = _: {src = filteredSource;};
162 };
140 };
163 };
141 };
142+
143+ packages.helix-unwrapped = config.nci.outputs."helix-term".packages.release;
144+ packages.helix-unwrapped-dev = config.nci.outputs."helix-term".packages.dev;
145+ packages.helix = makeOverridableHelix config.packages.helix-unwrapped {};
146+ packages.helix-dev = makeOverridableHelix config.packages.helix-unwrapped-dev {};
147+ packages.default = config.packages.helix;
148+
149+ devShells.default = config.nci.outputs."helix-project".devShell.overrideAttrs (old: {
150+ nativeBuildInputs =
151+ (old.nativeBuildInputs or [])
152+ ++ (with pkgs; [lld_13 cargo-flamegraph rust-analyzer])
153+ ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) pkgs.cargo-tarpaulin)
154+ ++ (lib.optional stdenv.isLinux pkgs.lldb)
155+ ++ (lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.CoreFoundation);
156+ shellHook = ''
157+ export HELIX_RUNTIME="$PWD/runtime"
158+ export RUST_BACKTRACE="1"
159+ export RUSTFLAGS="${rustFlagsEnv}"
160+ '';
161+ });
164 };
162 };
165 };
163 };
166− in
167− outputs
168− // {
169− packages =
170− lib.mapAttrs
171− (
172− system: packages:
173− packages
174− // {
175− helix-unwrapped = packages.helix.passthru.unwrapped;
176− helix-unwrapped-dev = packages.helix-dev.passthru.unwrapped;
177− }
178− )
179− outputs.packages;
180− };
181
164
182 nixConfig = {
165 nixConfig = {
183 extra-substituters = ["https://helix.cachix.org"];
166 extra-substituters = ["https://helix.cachix.org"];
helix-term/Cargo.toml−4
@@ -12,10 +12,6 @@ include = ["src/**/*", "README.md"]
12default-run = "hx"
12default-run = "hx"
13rust-version = "1.57"
13rust-version = "1.57"
14
14
15−[package.metadata.nix]
16−build = true
17−app = true
18−
19[features]
15[features]
20default = ["git"]
16default = ["git"]
21unicode-lines = ["helix-core/unicode-lines"]
17unicode-lines = ["helix-core/unicode-lines"]