chore(nix): format nix files with alejandra, update deps, minor code refactors (#2683)

pull/2689/head
Yusuf Bera Ertan 2 years ago committed by GitHub
parent f0d1c85553
commit bb83ea8393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,11 +3,11 @@
"crane": { "crane": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1644785799, "lastModified": 1654444508,
"narHash": "sha256-VpAJO1L0XeBvtCuNGK4IDKp6ENHIpTrlaZT7yfBCvwo=", "narHash": "sha256-4OBvQ4V7jyt7afs6iKUvRzJ1u/9eYnKzVQbeQdiamuY=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "fc7a94f841347c88f2cb44217b2a3faa93e2a0b2", "rev": "db5482bf225acc3160899124a1df5a617cfa27b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,19 +17,13 @@
} }
}, },
"devshell": { "devshell": {
"inputs": { "flake": false,
"flake-utils": "flake-utils",
"nixpkgs": [
"nixCargoIntegration",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1652959711, "lastModified": 1653917170,
"narHash": "sha256-wpQhlE/NocxlU3jLiMoF1KYHOEFD5MEFJZkyXXVVef8=", "narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "a5327cd01e58d2848c73062f2661278ad615748f", "rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -45,6 +39,10 @@
"nixpkgs" "nixpkgs"
], ],
"crane": "crane", "crane": "crane",
"devshell": [
"nixCargoIntegration",
"devshell"
],
"flake-utils-pre-commit": [ "flake-utils-pre-commit": [
"nixCargoIntegration", "nixCargoIntegration",
"nixpkgs" "nixpkgs"
@ -75,11 +73,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1653135531, "lastModified": 1654451959,
"narHash": "sha256-pYwJrEQrG8BgeVcI+lveK3KbOBDx9MT28HxV09v+jgI=", "narHash": "sha256-yWztC96o8Dw65jDbmNUxV1i61T3uLqvqhC3ziwnB/Fk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "4b3dfb101fd2fdbe25bd128072f138276aa4bc82", "rev": "90b353682ef927bd39b59085e0dc6b7454888de7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -89,21 +87,6 @@
} }
}, },
"flake-utils": { "flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": { "locked": {
"lastModified": 1637014545, "lastModified": 1637014545,
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
@ -130,11 +113,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1653286465, "lastModified": 1654531591,
"narHash": "sha256-CEI2prA74sy9SgAJKdDpyAMv1nnp91c8e5Fw9QbtR/Q=", "narHash": "sha256-DtDAwkl2Pn8w1BW1z2OssT/bWjVhMZQBBpr2uDY7tHY=",
"owner": "yusdacra", "owner": "yusdacra",
"repo": "nix-cargo-integration", "repo": "nix-cargo-integration",
"rev": "95efd76ab68b20aba45b7d647460319b88c2a4c0", "rev": "c935099d6851d0ff94098e9a12f42147524f0c5b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -145,11 +128,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1653060744, "lastModified": 1654230545,
"narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=", "narHash": "sha256-8Vlwf0x8ow6pPOK2a04bT+pxIeRnM1+O0Xv9/CuDzRs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "dfd82985c273aac6eced03625f454b334daae2e8", "rev": "236cc2971ac72acd90f0ae3a797f9f83098b17ec",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -168,17 +151,17 @@
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1653273659, "lastModified": 1654483484,
"narHash": "sha256-dHXYaNL1axhZZyiZXxt1WKhvZrYXq7bjCs3y5VjgyGI=", "narHash": "sha256-Ki/sMgrUEj+31P3YMzZZp5Nea7+MQVVTdaRWQVS1PL4=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "0fa3e01da1ce98e3b40063b8e2678095943402b1", "rev": "6bc59b9c4ad1cc1089219e935aa727a96d948c5d",
"type": "github" "type": "github"
}, },
"original": { "original": {

@ -14,10 +14,14 @@
}; };
}; };
outputs = inputs@{ nixCargoIntegration, ... }: outputs = inputs @ {
nixpkgs,
nixCargoIntegration,
...
}:
nixCargoIntegration.lib.makeOutputs { nixCargoIntegration.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)
# Set default package to helix-term release build # Set default package to helix-term release build
defaultOutputs = { defaultOutputs = {
@ -25,26 +29,37 @@
package = "helix"; package = "helix";
}; };
overrides = { overrides = {
cCompiler = common: if common.pkgs.stdenv.isLinux then common.pkgs.gcc else common.pkgs.clang; cCompiler = common:
with common.pkgs;
if stdenv.isLinux
then gcc
else clang;
crateOverrides = common: _: { crateOverrides = common: _: {
helix-term = prev: helix-term = prev: let
let
inherit (common) pkgs; inherit (common) pkgs;
grammars = pkgs.callPackage ./grammars.nix { }; mkRootPath = rel:
runtimeDir = pkgs.runCommand "helix-runtime" { } '' builtins.path {
path = "${common.root}/${rel}";
name = rel;
};
grammars = pkgs.callPackage ./grammars.nix {};
runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
mkdir -p $out mkdir -p $out
ln -s ${common.root}/runtime/* $out ln -s ${mkRootPath "runtime"}/* $out
rm -r $out/grammars rm -r $out/grammars
ln -s ${grammars} $out/grammars ln -s ${grammars} $out/grammars
''; '';
in in {
{
# 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";
# 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 = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} .."; preConfigure =
buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ]; pkgs.lib.concatMapStringsSep
nativeBuildInputs = [ pkgs.makeWrapper ]; "\n"
(path: "ln -sf ${mkRootPath path} ..")
["languages.toml" "theme.toml" "base16_theme.toml"];
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
nativeBuildInputs = [pkgs.makeWrapper];
postFixup = '' postFixup = ''
if [ -f "$out/bin/hx" ]; then if [ -f "$out/bin/hx" ]; then
@ -54,11 +69,29 @@
}; };
}; };
shell = common: prev: { shell = common: prev: {
packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]); packages =
env = prev.env ++ [ prev.packages
{ name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; } ++ (
{ name = "RUST_BACKTRACE"; value = "1"; } with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph]
{ 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 ""; } );
env =
prev.env
++ [
{
name = "HELIX_RUNTIME";
eval = "$PWD/runtime";
}
{
name = "RUST_BACKTRACE";
value = "1";
}
{
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 "";
}
]; ];
}; };
}; };

@ -1,17 +1,23 @@
{ stdenv, lib, runCommand, yj }: {
let stdenv,
lib,
runCommandLocal,
runCommandNoCC,
yj,
}: let
# HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON # HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON
# before parsing # before parsing
languages-json = runCommand "languages-toml-to-json" { } '' languages-json = runCommandLocal "languages-toml-to-json" {} ''
${yj}/bin/yj -t < ${./languages.toml} > $out ${yj}/bin/yj -t < ${./languages.toml} > $out
''; '';
languagesConfig = if lib.versionAtLeast builtins.nixVersion "2.6.0" then languagesConfig =
builtins.fromTOML (builtins.readFile ./languages.toml) if lib.versionAtLeast builtins.nixVersion "2.6.0"
else then builtins.fromTOML (builtins.readFile ./languages.toml)
builtins.fromJSON (builtins.readFile (builtins.toPath languages-json)); else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
isGitGrammar = (grammar: isGitGrammar = grammar:
builtins.hasAttr "source" grammar && builtins.hasAttr "git" grammar.source builtins.hasAttr "source" grammar
&& builtins.hasAttr "rev" grammar.source); && builtins.hasAttr "git" grammar.source
&& builtins.hasAttr "rev" grammar.source;
isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git; isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git;
toGitHubFetcher = url: let toGitHubFetcher = url: let
match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url; match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url;
@ -20,8 +26,7 @@ let
repo = builtins.elemAt match 1; repo = builtins.elemAt match 1;
}; };
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar; gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
buildGrammar = grammar: buildGrammar = grammar: let
let
gh = toGitHubFetcher grammar.source.git; gh = toGitHubFetcher grammar.source.git;
sourceGit = builtins.fetchTree { sourceGit = builtins.fetchTree {
type = "git"; type = "git";
@ -36,17 +41,21 @@ let
repo = gh.repo; repo = gh.repo;
inherit (grammar.source) rev; inherit (grammar.source) rev;
}; };
source = if isGitHubGrammar grammar then sourceGitHub else sourceGit; source =
in stdenv.mkDerivation rec { if isGitHubGrammar grammar
then sourceGitHub
else sourceGit;
in
stdenv.mkDerivation rec {
# see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
pname = "helix-tree-sitter-${grammar.name}"; pname = "helix-tree-sitter-${grammar.name}";
version = grammar.source.rev; version = grammar.source.rev;
src = if builtins.hasAttr "subpath" grammar.source then src =
"${source}/${grammar.source.subpath}" if builtins.hasAttr "subpath" grammar.source
else then "${source}/${grammar.source.subpath}"
source; else source;
dontUnpack = true; dontUnpack = true;
dontConfigure = true; dontConfigure = true;
@ -93,14 +102,17 @@ let
runHook postFixup runHook postFixup
''; '';
}; };
builtGrammars = builtins.map (grammar: { builtGrammars =
builtins.map (grammar: {
inherit (grammar) name; inherit (grammar) name;
artifact = buildGrammar grammar; artifact = buildGrammar grammar;
}) gitGrammars; })
grammarLinks = builtins.map (grammar: gitGrammars;
"ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so") grammarLinks =
builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so")
builtGrammars; builtGrammars;
in runCommand "consolidated-helix-grammars" { } '' in
runCommandNoCC "consolidated-helix-grammars" {} ''
mkdir -p $out mkdir -p $out
${builtins.concatStringsSep "\n" grammarLinks} ${builtins.concatStringsSep "\n" grammarLinks}
'' ''

@ -1,9 +1,8 @@
# Flake's devShell for non-flake-enabled nix instances # Flake's devShell for non-flake-enabled nix instances
let let
compat = compat = builtins.fetchGit {
builtins.fetchGit {
url = "https://github.com/edolstra/flake-compat.git"; url = "https://github.com/edolstra/flake-compat.git";
rev = "b4a34015c698c7793d592d66adbab377907a2be8"; rev = "b4a34015c698c7793d592d66adbab377907a2be8";
}; };
in in
(import compat { src = ./.; }).shellNix.default (import compat {src = ./.;}).shellNix.default

Loading…
Cancel
Save