helix.drv @main -
refs -
log -
-
https://git.jolheiser.com/helix.drv.git
My Helix configuration as a Nix derivation
build with central nixpkgs
Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY
oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
AAAAQHamcKurJIIemlQH6rmeBN8PfXe5r9qs4Jg/QjOC6IucbK7PjNjuBW0P+ZTzMJMU2E
Qw91SjIiqW+H9Ox+JCfAU=
-----END SSH SIGNATURE-----
2 changed files, 143 additions(+), 14 deletions(-)
diff --git a/flake.lock b/flake.lock
index 1597b0a1544769f9764df135d2871121cbc87ef2..ec3f22a143e3f24bfbf03ef3db5e51c152335e89 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,28 +1,58 @@
{
"nodes": {
- "nixpkgs": {
+ "jolheiser": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
"locked": {
+ "nodes": {
"lastModified": 1715653339,
+ "nodes": {
"narHash": "sha256-7lR9tpVXviSccl07GXI0+ve/natd24HAkuy1sQp0OlI=",
+ "nodes": {
"owner": "nixos",
+ "nodes": {
"repo": "nixpkgs",
+ "nodes": {
"rev": "abd6d48f8c77bea7dc51beb2adfa6ed3950d2585",
+ "type": "git",
+ "nixpkgs": {
{
+ },
+ "original": {
+ "nixpkgs": {
+ "nixpkgs": {
{
{
+ "locked": {
{
+ "lastModified": 1715653339,
+ "nixpkgs": {
+ "locked": {
+ "nixpkgs": {
"nodes": {
+ "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=",
"owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "18536bf04cd71abd345f9579158841376fdd0c5a",
{
+ },
+ "original": {
+ "owner": "nixos",
"nixpkgs": {
+ "lastModified": 1715653339,
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
-{
+ "jolheiser": "jolheiser",
+ "nixpkgs": [
+ "nixpkgs": {
"repo": "nixpkgs",
+ "nixpkgs"
+ ]
}
}
},
diff --git a/flake.nix b/flake.nix
index dad44ba18beb86173b66750686999390d836d374..0fd4eff9567a0d8efa4c12430867da96ce14f46d 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,114 +1,213 @@
{
description = "jolheiser helix derivation";
+ inputs = {
+ nixpkgs,
+ nixpkgs,
inputs = {
+ };
+ nixpkgs,
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ nixpkgs,
};
+ nixpkgs,
+ ...
+ }:
+ let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ tomlFormat = pkgs.formats.toml { };
+ }: let
+ buildGrammar =
+ grammar:
+ let
+ }: let
outputs = {
+ }: let
self,
+ }: let
nixpkgs,
+{
}: let
+{
pkgs = nixpkgs.legacyPackages.x86_64-linux;
{
+{
description = "jolheiser helix derivation";
+{
config = import ./config.nix {pkgs = pkgs;};
+{
buildGrammar = grammar: let
{
+{
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+{
inherit (grammar) url rev sha256;
+{
};
{
+{
self,
+{
in
+{
pkgs.stdenv.mkDerivation {
+{
pname = "helix-tree-sitter-grammar-${grammar.name}";
+{
version = grammar.rev;
+
+{
buildInputs = [pkgs.helix pkgs.git];
+{
src = source;
+{
dontInstall = true;
+{
buildPhase = ''
+{
runHook preBuild
-
+{
mkdir .helix
+{
cat << EOF > .helix/languages.toml
+ config = import ./config.nix {pkgs = pkgs;};
+{
[[grammar]]
+{
name = "${grammar.name}"
+ config = import ./config.nix {pkgs = pkgs;};
+{
EOF
+{
mkdir -p runtime/grammars/sources
+{
cp -r ${source} runtime/grammars/sources/${grammar.name}
+{
export CARGO_MANIFEST_DIR=$(pwd)/.helix
+{
#hx -g fetch
+{
hx -g build
-
+{
mkdir $out
+{
cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so
inputs = {
- description = "jolheiser helix derivation";
+ outputs = {
-
+ artifact = buildGrammar grammar;
+ }) config.grammars;
+{
runHook postBuild
+{
'';
{
- outputs = {
builtGrammars =
+{
builtins.map (grammar: {
+{
inherit (grammar) name;
+{
artifact = buildGrammar grammar;
+ );
+{
})
+{
config.grammars;
+{
ignoreFile = pkgs.writeText "ignore" (builtins.concatStringsSep "\n" config.ignore);
+{
configFile = pkgs.writeText "config.toml" (builtins.readFile (tomlFormat.generate "helix-config" config.settings));
+{
languageFile = pkgs.writeText "languages.toml" (builtins.readFile (tomlFormat.generate "helix-languages" config.languages));
+{
themeFiles =
+{
pkgs.lib.mapAttrsToList (
+{
name: value: {
+{
inherit name;
+{
file = pkgs.writeText "${name}.toml" (builtins.readFile (tomlFormat.generate "helix-theme-${name}" value));
+{
}
+{
)
+{
config.themes;
+{
themeLinks = builtins.map (theme: "ln -s ${theme.file} $out/home/helix/themes/${theme.name}.toml") themeFiles;
+ ) builtGrammars;
+ in
+ {
+{
grammarLinks = builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/lib/runtime/grammars/${grammar.name}.so") builtGrammars;
+{
queryLinks = builtins.map (grammar: "ln -s ${grammar.artifact}/queries $out/lib/runtime/queries/${grammar.name}") builtGrammars;
+{
in {
+{
packages.x86_64-linux.default =
+{
pkgs.runCommand "hx" {
+{
buildInputs = [pkgs.makeWrapper];
+ mkdir $out
+{
} ''
+{
mkdir $out
+
+{
ln -s ${pkgs.helix}/* $out
+{
rm $out/bin
+ };
- outputs = {
+{
mkdir -p $out/lib/runtime
+{
ln -s ${pkgs.helix}/lib/runtime/* $out/lib/runtime
-
+{
rm $out/lib/runtime/grammars
+{
mkdir $out/lib/runtime/grammars
+
+{
ln -s ${pkgs.helix}/lib/runtime/grammars/* $out/lib/runtime/grammars
+{
${builtins.concatStringsSep "\n" grammarLinks}
-
+{
rm $out/lib/runtime/queries
+{
mkdir $out/lib/runtime/queries
+
+{
ln -s ${pkgs.helix}/lib/runtime/queries/* $out/lib/runtime/queries
+{
${builtins.concatStringsSep "\n" queryLinks}
-
+{
mkdir -p $out/home/helix/themes
+{
ln -s ${configFile} $out/home/helix/config.toml
+
+{
ln -s ${languageFile} $out/home/helix/languages.toml
+{
${builtins.concatStringsSep "\n" themeLinks}
+{
mkdir -p $out/home/git
- ln -s ${ignoreFile} $out/home/git/ignore
+{
nixpkgs,
- nixpkgs,
{
- };
+ ln -s ${ignoreFile} $out/home/git/ignore
}