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

@ -14,7 +14,11 @@
};
};
outputs = inputs@{ nixCargoIntegration, ... }:
outputs = inputs @ {
nixpkgs,
nixCargoIntegration,
...
}:
nixCargoIntegration.lib.makeOutputs {
root = ./.;
renameOutputs = {"helix-term" = "helix";};
@ -25,24 +29,35 @@
package = "helix";
};
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: _: {
helix-term = prev:
let
helix-term = prev: let
inherit (common) pkgs;
mkRootPath = rel:
builtins.path {
path = "${common.root}/${rel}";
name = rel;
};
grammars = pkgs.callPackage ./grammars.nix {};
runtimeDir = pkgs.runCommand "helix-runtime" { } ''
runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} ''
mkdir -p $out
ln -s ${common.root}/runtime/* $out
ln -s ${mkRootPath "runtime"}/* $out
rm -r $out/grammars
ln -s ${grammars} $out/grammars
'';
in
{
in {
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
# 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 =
pkgs.lib.concatMapStringsSep
"\n"
(path: "ln -sf ${mkRootPath path} ..")
["languages.toml" "theme.toml" "base16_theme.toml"];
buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib];
nativeBuildInputs = [pkgs.makeWrapper];
@ -54,11 +69,29 @@
};
};
shell = common: prev: {
packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]);
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 ""; }
packages =
prev.packages
++ (
with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph]
);
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
# before parsing
languages-json = runCommand "languages-toml-to-json" { } ''
languages-json = runCommandLocal "languages-toml-to-json" {} ''
${yj}/bin/yj -t < ${./languages.toml} > $out
'';
languagesConfig = if lib.versionAtLeast builtins.nixVersion "2.6.0" then
builtins.fromTOML (builtins.readFile ./languages.toml)
else
builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
isGitGrammar = (grammar:
builtins.hasAttr "source" grammar && builtins.hasAttr "git" grammar.source
&& builtins.hasAttr "rev" grammar.source);
languagesConfig =
if lib.versionAtLeast builtins.nixVersion "2.6.0"
then builtins.fromTOML (builtins.readFile ./languages.toml)
else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
isGitGrammar = grammar:
builtins.hasAttr "source" grammar
&& builtins.hasAttr "git" grammar.source
&& builtins.hasAttr "rev" grammar.source;
isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git;
toGitHubFetcher = url: let
match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url;
@ -20,8 +26,7 @@ let
repo = builtins.elemAt match 1;
};
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
buildGrammar = grammar:
let
buildGrammar = grammar: let
gh = toGitHubFetcher grammar.source.git;
sourceGit = builtins.fetchTree {
type = "git";
@ -36,17 +41,21 @@ let
repo = gh.repo;
inherit (grammar.source) rev;
};
source = if isGitHubGrammar grammar then sourceGitHub else sourceGit;
in stdenv.mkDerivation rec {
source =
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
pname = "helix-tree-sitter-${grammar.name}";
version = grammar.source.rev;
src = if builtins.hasAttr "subpath" grammar.source then
"${source}/${grammar.source.subpath}"
else
source;
src =
if builtins.hasAttr "subpath" grammar.source
then "${source}/${grammar.source.subpath}"
else source;
dontUnpack = true;
dontConfigure = true;
@ -93,14 +102,17 @@ let
runHook postFixup
'';
};
builtGrammars = builtins.map (grammar: {
builtGrammars =
builtins.map (grammar: {
inherit (grammar) name;
artifact = buildGrammar grammar;
}) gitGrammars;
grammarLinks = builtins.map (grammar:
"ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so")
})
gitGrammars;
grammarLinks =
builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so")
builtGrammars;
in runCommand "consolidated-helix-grammars" { } ''
in
runCommandNoCC "consolidated-helix-grammars" {} ''
mkdir -p $out
${builtins.concatStringsSep "\n" grammarLinks}
''

@ -1,7 +1,6 @@
# Flake's devShell for non-flake-enabled nix instances
let
compat =
builtins.fetchGit {
compat = builtins.fetchGit {
url = "https://github.com/edolstra/flake-compat.git";
rev = "b4a34015c698c7793d592d66adbab377907a2be8";
};

Loading…
Cancel
Save