on master help sign in
chore(nix): format nix files with alejandra, update deps, minor code refactors (#2683)
bb83ea8Yusuf Bera Ertan
flake.lock+24−41
@@ -3,11 +3,11 @@
3 "crane": {
3 "crane": {
4 "flake": false,
4 "flake": false,
5 "locked": {
5 "locked": {
6− "lastModified": 1644785799,
6+ "lastModified": 1654444508,
7− "narHash": "sha256-VpAJO1L0XeBvtCuNGK4IDKp6ENHIpTrlaZT7yfBCvwo=",
7+ "narHash": "sha256-4OBvQ4V7jyt7afs6iKUvRzJ1u/9eYnKzVQbeQdiamuY=",
8 "owner": "ipetkov",
8 "owner": "ipetkov",
9 "repo": "crane",
9 "repo": "crane",
10− "rev": "fc7a94f841347c88f2cb44217b2a3faa93e2a0b2",
10+ "rev": "db5482bf225acc3160899124a1df5a617cfa27b5",
11 "type": "github"
11 "type": "github"
12 },
12 },
13 "original": {
13 "original": {
@@ -17,19 +17,13 @@
17 }
17 }
18 },
18 },
19 "devshell": {
19 "devshell": {
20− "inputs": {
20+ "flake": false,
21− "flake-utils": "flake-utils",
22− "nixpkgs": [
23− "nixCargoIntegration",
24− "nixpkgs"
25− ]
26− },
27 "locked": {
21 "locked": {
28− "lastModified": 1652959711,
22+ "lastModified": 1653917170,
29− "narHash": "sha256-wpQhlE/NocxlU3jLiMoF1KYHOEFD5MEFJZkyXXVVef8=",
23+ "narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=",
30 "owner": "numtide",
24 "owner": "numtide",
31 "repo": "devshell",
25 "repo": "devshell",
32− "rev": "a5327cd01e58d2848c73062f2661278ad615748f",
26+ "rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92",
33 "type": "github"
27 "type": "github"
34 },
28 },
35 "original": {
29 "original": {
@@ -45,6 +39,10 @@
45 "nixpkgs"
39 "nixpkgs"
46 ],
40 ],
47 "crane": "crane",
41 "crane": "crane",
42+ "devshell": [
43+ "nixCargoIntegration",
44+ "devshell"
45+ ],
48 "flake-utils-pre-commit": [
46 "flake-utils-pre-commit": [
49 "nixCargoIntegration",
47 "nixCargoIntegration",
50 "nixpkgs"
48 "nixpkgs"
@@ -75,11 +73,11 @@
75 ]
73 ]
76 },
74 },
77 "locked": {
75 "locked": {
78− "lastModified": 1653135531,
76+ "lastModified": 1654451959,
79− "narHash": "sha256-pYwJrEQrG8BgeVcI+lveK3KbOBDx9MT28HxV09v+jgI=",
77+ "narHash": "sha256-yWztC96o8Dw65jDbmNUxV1i61T3uLqvqhC3ziwnB/Fk=",
80 "owner": "nix-community",
78 "owner": "nix-community",
81 "repo": "dream2nix",
79 "repo": "dream2nix",
82− "rev": "4b3dfb101fd2fdbe25bd128072f138276aa4bc82",
80+ "rev": "90b353682ef927bd39b59085e0dc6b7454888de7",
83 "type": "github"
81 "type": "github"
84 },
82 },
85 "original": {
83 "original": {
@@ -89,21 +87,6 @@
89 }
87 }
90 },
88 },
91 "flake-utils": {
89 "flake-utils": {
92− "locked": {
93− "lastModified": 1642700792,
94− "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
95− "owner": "numtide",
96− "repo": "flake-utils",
97− "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
98− "type": "github"
99− },
100− "original": {
101− "owner": "numtide",
102− "repo": "flake-utils",
103− "type": "github"
104− }
105− },
106− "flake-utils_2": {
107 "locked": {
90 "locked": {
108 "lastModified": 1637014545,
91 "lastModified": 1637014545,
109 "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
92 "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
@@ -130,11 +113,11 @@
130 ]
113 ]
131 },
114 },
132 "locked": {
115 "locked": {
133− "lastModified": 1653286465,
116+ "lastModified": 1654531591,
134− "narHash": "sha256-CEI2prA74sy9SgAJKdDpyAMv1nnp91c8e5Fw9QbtR/Q=",
117+ "narHash": "sha256-DtDAwkl2Pn8w1BW1z2OssT/bWjVhMZQBBpr2uDY7tHY=",
135 "owner": "yusdacra",
118 "owner": "yusdacra",
136 "repo": "nix-cargo-integration",
119 "repo": "nix-cargo-integration",
137− "rev": "95efd76ab68b20aba45b7d647460319b88c2a4c0",
120+ "rev": "c935099d6851d0ff94098e9a12f42147524f0c5b",
138 "type": "github"
121 "type": "github"
139 },
122 },
140 "original": {
123 "original": {
@@ -145,11 +128,11 @@
145 },
128 },
146 "nixpkgs": {
129 "nixpkgs": {
147 "locked": {
130 "locked": {
148− "lastModified": 1653060744,
131+ "lastModified": 1654230545,
149− "narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=",
132+ "narHash": "sha256-8Vlwf0x8ow6pPOK2a04bT+pxIeRnM1+O0Xv9/CuDzRs=",
150 "owner": "nixos",
133 "owner": "nixos",
151 "repo": "nixpkgs",
134 "repo": "nixpkgs",
152− "rev": "dfd82985c273aac6eced03625f454b334daae2e8",
135+ "rev": "236cc2971ac72acd90f0ae3a797f9f83098b17ec",
153 "type": "github"
136 "type": "github"
154 },
137 },
155 "original": {
138 "original": {
@@ -168,17 +151,17 @@
168 },
151 },
169 "rust-overlay": {
152 "rust-overlay": {
170 "inputs": {
153 "inputs": {
171− "flake-utils": "flake-utils_2",
154+ "flake-utils": "flake-utils",
172 "nixpkgs": [
155 "nixpkgs": [
173 "nixpkgs"
156 "nixpkgs"
174 ]
157 ]
175 },
158 },
176 "locked": {
159 "locked": {
177− "lastModified": 1653273659,
160+ "lastModified": 1654483484,
178− "narHash": "sha256-dHXYaNL1axhZZyiZXxt1WKhvZrYXq7bjCs3y5VjgyGI=",
161+ "narHash": "sha256-Ki/sMgrUEj+31P3YMzZZp5Nea7+MQVVTdaRWQVS1PL4=",
179 "owner": "oxalica",
162 "owner": "oxalica",
180 "repo": "rust-overlay",
163 "repo": "rust-overlay",
181− "rev": "0fa3e01da1ce98e3b40063b8e2678095943402b1",
164+ "rev": "6bc59b9c4ad1cc1089219e935aa727a96d948c5d",
182 "type": "github"
165 "type": "github"
183 },
166 },
184 "original": {
167 "original": {
flake.nix+66−33
@@ -14,10 +14,14 @@
14 };
14 };
15 };
15 };
16
16
17+ outputs = inputs @ {
18+ nixpkgs,
17− outputs = inputs@{ nixCargoIntegration, ... }:
19+ nixCargoIntegration,
20+ ...
21+ }:
18 nixCargoIntegration.lib.makeOutputs {
22 nixCargoIntegration.lib.makeOutputs {
19 root = ./.;
23 root = ./.;
20− renameOutputs = { "helix-term" = "helix"; };
24+ renameOutputs = {"helix-term" = "helix";};
21 # Set default app to hx (binary is from helix-term release build)
25 # Set default app to hx (binary is from helix-term release build)
22 # Set default package to helix-term release build
26 # Set default package to helix-term release build
23 defaultOutputs = {
27 defaultOutputs = {
@@ -25,41 +29,70 @@
25 package = "helix";
29 package = "helix";
26 };
30 };
27 overrides = {
31 overrides = {
28− cCompiler = common: if common.pkgs.stdenv.isLinux then common.pkgs.gcc else common.pkgs.clang;
32+ cCompiler = common:
33+ with common.pkgs;
34+ if stdenv.isLinux
35+ then gcc
36+ else clang;
29 crateOverrides = common: _: {
37 crateOverrides = common: _: {
30− helix-term = prev:
38+ helix-term = prev: let
31− let
32− inherit (common) pkgs;
39+ inherit (common) pkgs;
40+ mkRootPath = rel:
41+ builtins.path {
42+ path = "${common.root}/${rel}";
43+ name = rel;
44+ };
33− grammars = pkgs.callPackage ./grammars.nix { };
45+ grammars = pkgs.callPackage ./grammars.nix {};
34− runtimeDir = pkgs.runCommand "helix-runtime" { } ''
46+ runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
35− mkdir -p $out
47+ mkdir -p $out
36− ln -s ${common.root}/runtime/* $out
48+ ln -s ${mkRootPath "runtime"}/* $out
37− rm -r $out/grammars
49+ rm -r $out/grammars
38− ln -s ${grammars} $out/grammars
50+ ln -s ${grammars} $out/grammars
39− '';
51+ '';
40− in
52+ in {
41− {
42− # disable fetching and building of tree-sitter grammars in the helix-term build.rs
53+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
43− HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
54+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
44− # link languages and theme toml files since helix-term expects them (for tests)
55+ # link languages and theme toml files since helix-term expects them (for tests)
56+ preConfigure =
57+ pkgs.lib.concatMapStringsSep
58+ "\n"
59+ (path: "ln -sf ${mkRootPath path} ..")
45− preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} ..";
60+ ["languages.toml" "theme.toml" "base16_theme.toml"];
46− buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
61+ buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
47− nativeBuildInputs = [ pkgs.makeWrapper ];
62+ nativeBuildInputs = [pkgs.makeWrapper];
48
63
49− postFixup = ''
64+ postFixup = ''
50− if [ -f "$out/bin/hx" ]; then
65+ if [ -f "$out/bin/hx" ]; then
51− wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
66+ wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
52− fi
67+ fi
53− '';
68+ '';
54− };
69+ };
55 };
70 };
56 shell = common: prev: {
71 shell = common: prev: {
72+ packages =
73+ prev.packages
74+ ++ (
57− packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]);
75+ with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph]
76+ );
77+ env =
58− env = prev.env ++ [
78+ prev.env
79+ ++ [
80+ {
59− { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
81+ name = "HELIX_RUNTIME";
82+ eval = "$PWD/runtime";
83+ }
84+ {
60− { name = "RUST_BACKTRACE"; value = "1"; }
85+ name = "RUST_BACKTRACE";
86+ value = "1";
87+ }
88+ {
89+ name = "RUSTFLAGS";
90+ value =
91+ if common.pkgs.stdenv.isLinux
61− { 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 ""; }
92+ then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"
93+ else "";
94+ }
62− ];
95+ ];
63 };
96 };
64 };
97 };
65 };
98 };
grammars.nix+54−42
@@ -1,17 +1,23 @@
1+{
1−{ stdenv, lib, runCommand, yj }:
2+ stdenv,
3+ lib,
4+ runCommandLocal,
5+ runCommandNoCC,
6+ yj,
2−let
7+}: let
3 # HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON
8 # HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON
4 # before parsing
9 # before parsing
5− languages-json = runCommand "languages-toml-to-json" { } ''
10+ languages-json = runCommandLocal "languages-toml-to-json" {} ''
6 ${yj}/bin/yj -t < ${./languages.toml} > $out
11 ${yj}/bin/yj -t < ${./languages.toml} > $out
7 '';
12 '';
13+ languagesConfig =
8− languagesConfig = if lib.versionAtLeast builtins.nixVersion "2.6.0" then
14+ if lib.versionAtLeast builtins.nixVersion "2.6.0"
9− builtins.fromTOML (builtins.readFile ./languages.toml)
15+ then builtins.fromTOML (builtins.readFile ./languages.toml)
10− else
11− builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
16+ else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
12− isGitGrammar = (grammar:
17+ isGitGrammar = grammar:
18+ builtins.hasAttr "source" grammar
13− builtins.hasAttr "source" grammar && builtins.hasAttr "git" grammar.source
19+ && builtins.hasAttr "git" grammar.source
14− && builtins.hasAttr "rev" grammar.source);
20+ && builtins.hasAttr "rev" grammar.source;
15 isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git;
21 isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git;
16 toGitHubFetcher = url: let
22 toGitHubFetcher = url: let
17 match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url;
23 match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url;
@@ -20,33 +26,36 @@ let
20 repo = builtins.elemAt match 1;
26 repo = builtins.elemAt match 1;
21 };
27 };
22 gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
28 gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
23− buildGrammar = grammar:
29+ buildGrammar = grammar: let
24− let
25− gh = toGitHubFetcher grammar.source.git;
30+ gh = toGitHubFetcher grammar.source.git;
26− sourceGit = builtins.fetchTree {
31+ sourceGit = builtins.fetchTree {
27− type = "git";
32+ type = "git";
28− url = grammar.source.git;
33+ url = grammar.source.git;
29− rev = grammar.source.rev;
34+ rev = grammar.source.rev;
30− ref = grammar.source.ref or "HEAD";
35+ ref = grammar.source.ref or "HEAD";
31− shallow = true;
36+ shallow = true;
32− };
37+ };
33− sourceGitHub = builtins.fetchTree {
38+ sourceGitHub = builtins.fetchTree {
34− type = "github";
39+ type = "github";
35− owner = gh.owner;
40+ owner = gh.owner;
36− repo = gh.repo;
41+ repo = gh.repo;
37− inherit (grammar.source) rev;
42+ inherit (grammar.source) rev;
38− };
43+ };
44+ source =
39− source = if isGitHubGrammar grammar then sourceGitHub else sourceGit;
45+ if isGitHubGrammar grammar
46+ then sourceGitHub
47+ else sourceGit;
48+ in
40− in stdenv.mkDerivation rec {
49+ stdenv.mkDerivation rec {
41 # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
50 # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
42
51
43 pname = "helix-tree-sitter-${grammar.name}";
52 pname = "helix-tree-sitter-${grammar.name}";
44 version = grammar.source.rev;
53 version = grammar.source.rev;
45
54
55+ src =
46− src = if builtins.hasAttr "subpath" grammar.source then
56+ if builtins.hasAttr "subpath" grammar.source
47− "${source}/${grammar.source.subpath}"
57+ then "${source}/${grammar.source.subpath}"
48− else
49− source;
58+ else source;
50
59
51 dontUnpack = true;
60 dontUnpack = true;
52 dontConfigure = true;
61 dontConfigure = true;
@@ -93,14 +102,17 @@ let
93 runHook postFixup
102 runHook postFixup
94 '';
103 '';
95 };
104 };
105+ builtGrammars =
96− builtGrammars = builtins.map (grammar: {
106+ builtins.map (grammar: {
97− inherit (grammar) name;
107+ inherit (grammar) name;
98− artifact = buildGrammar grammar;
108+ artifact = buildGrammar grammar;
109+ })
99− }) gitGrammars;
110+ gitGrammars;
100− grammarLinks = builtins.map (grammar:
111+ grammarLinks =
101− "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so")
112+ builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so")
102 builtGrammars;
113 builtGrammars;
114+in
103−in runCommand "consolidated-helix-grammars" { } ''
115+ runCommandNoCC "consolidated-helix-grammars" {} ''
104− mkdir -p $out
116+ mkdir -p $out
105− ${builtins.concatStringsSep "\n" grammarLinks}
117+ ${builtins.concatStringsSep "\n" grammarLinks}
106−''
118+ ''
shell.nix+5−6
@@ -1,9 +1,8 @@
1# Flake's devShell for non-flake-enabled nix instances
1# Flake's devShell for non-flake-enabled nix instances
2let
2let
3− compat =
4− builtins.fetchGit {
3+ compat = builtins.fetchGit {
5− url = "https://github.com/edolstra/flake-compat.git";
4+ url = "https://github.com/edolstra/flake-compat.git";
6− rev = "b4a34015c698c7793d592d66adbab377907a2be8";
5+ rev = "b4a34015c698c7793d592d66adbab377907a2be8";
7− };
6+ };
8in
7in
9−(import compat { src = ./.; }).shellNix.default
8+ (import compat {src = ./.;}).shellNix.default