parent
a6f4760ef5
commit
13d625fa4f
32
flake.lock
32
flake.lock
|
@ -1,24 +1,46 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"jolheiser": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730336659,
|
||||||
|
"narHash": "sha256-DYQUprBce8sXdBj7Ub1h/52GnGvxiXelvucVTcTXE8I=",
|
||||||
|
"ref": "refs/heads/main",
|
||||||
|
"rev": "69856a465c69e5b456ef652f0f5f17a12b9d8c02",
|
||||||
|
"revCount": 3,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.jolheiser.com/nixpkgs.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.jolheiser.com/nixpkgs.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1715653339,
|
"lastModified": 1729880355,
|
||||||
"narHash": "sha256-7lR9tpVXviSccl07GXI0+ve/natd24HAkuy1sQp0OlI=",
|
"narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "abd6d48f8c77bea7dc51beb2adfa6ed3950d2585",
|
"rev": "18536bf04cd71abd345f9579158841376fdd0c5a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"ref": "nixpkgs-unstable",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"jolheiser": "jolheiser",
|
||||||
|
"nixpkgs": [
|
||||||
|
"jolheiser",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
191
flake.nix
191
flake.nix
|
@ -1,106 +1,121 @@
|
||||||
{
|
{
|
||||||
description = "jolheiser helix derivation";
|
description = "jolheiser helix derivation";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
jolheiser.url = "git+https://git.jolheiser.com/nixpkgs.git";
|
||||||
|
nixpkgs.follows = "jolheiser/nixpkgs";
|
||||||
};
|
};
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
nixpkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
config = import ./config.nix { pkgs = pkgs; };
|
||||||
|
buildGrammar =
|
||||||
|
grammar:
|
||||||
|
let
|
||||||
|
source = pkgs.fetchgit {
|
||||||
|
inherit (grammar) url rev sha256;
|
||||||
|
};
|
||||||
|
linkQueries = pkgs.lib.optionalString (builtins.hasAttr "queries" grammar) "cp -r ${source}/${grammar.queries} $out/queries";
|
||||||
|
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
|
||||||
|
|
||||||
outputs = {
|
mkdir .helix
|
||||||
self,
|
cat << EOF > .helix/languages.toml
|
||||||
nixpkgs,
|
use-grammars = { only = ["${grammar.name}"] }
|
||||||
}: let
|
[[grammar]]
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
name = "${grammar.name}"
|
||||||
tomlFormat = pkgs.formats.toml {};
|
source = { git = "${grammar.url}", rev = "${grammar.rev}" }
|
||||||
config = import ./config.nix {pkgs = pkgs;};
|
EOF
|
||||||
buildGrammar = grammar: let
|
|
||||||
source = pkgs.fetchgit {
|
|
||||||
inherit (grammar) url rev sha256;
|
|
||||||
};
|
|
||||||
linkQueries = pkgs.lib.optionalString (builtins.hasAttr "queries" grammar) "cp -r ${source}/${grammar.queries} $out/queries";
|
|
||||||
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
|
mkdir -p runtime/grammars/sources
|
||||||
cat << EOF > .helix/languages.toml
|
cp -r ${source} runtime/grammars/sources/${grammar.name}
|
||||||
use-grammars = { only = ["${grammar.name}"] }
|
export CARGO_MANIFEST_DIR=$(pwd)/.helix
|
||||||
[[grammar]]
|
|
||||||
name = "${grammar.name}"
|
|
||||||
source = { git = "${grammar.url}", rev = "${grammar.rev}" }
|
|
||||||
EOF
|
|
||||||
|
|
||||||
mkdir -p runtime/grammars/sources
|
#hx -g fetch
|
||||||
cp -r ${source} runtime/grammars/sources/${grammar.name}
|
hx -g build
|
||||||
export CARGO_MANIFEST_DIR=$(pwd)/.helix
|
|
||||||
|
|
||||||
#hx -g fetch
|
mkdir $out
|
||||||
hx -g build
|
cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so
|
||||||
|
${linkQueries}
|
||||||
|
|
||||||
mkdir $out
|
runHook postBuild
|
||||||
cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so
|
'';
|
||||||
${linkQueries}
|
};
|
||||||
|
builtGrammars = builtins.map (grammar: {
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
builtGrammars =
|
|
||||||
builtins.map (grammar: {
|
|
||||||
inherit (grammar) name;
|
inherit (grammar) name;
|
||||||
artifact = buildGrammar grammar;
|
artifact = buildGrammar grammar;
|
||||||
})
|
}) config.grammars;
|
||||||
config.grammars;
|
ignoreFile = pkgs.writeText "ignore" (builtins.concatStringsSep "\n" config.ignore);
|
||||||
ignoreFile = pkgs.writeText "ignore" (builtins.concatStringsSep "\n" config.ignore);
|
configFile = pkgs.writeText "config.toml" (
|
||||||
configFile = pkgs.writeText "config.toml" (builtins.readFile (tomlFormat.generate "helix-config" config.settings));
|
builtins.readFile (tomlFormat.generate "helix-config" config.settings)
|
||||||
languageFile = pkgs.writeText "languages.toml" (builtins.readFile (tomlFormat.generate "helix-languages" config.languages));
|
);
|
||||||
themeFiles =
|
languageFile = pkgs.writeText "languages.toml" (
|
||||||
pkgs.lib.mapAttrsToList (
|
builtins.readFile (tomlFormat.generate "helix-languages" config.languages)
|
||||||
name: value: {
|
);
|
||||||
inherit name;
|
themeFiles = pkgs.lib.mapAttrsToList (name: value: {
|
||||||
file = pkgs.writeText "${name}.toml" (builtins.readFile (tomlFormat.generate "helix-theme-${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;
|
}) config.themes;
|
||||||
grammarLinks = builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/lib/runtime/grammars/${grammar.name}.so") builtGrammars;
|
themeLinks = builtins.map (
|
||||||
queryLinks = builtins.map (grammar: "ln -s ${grammar.artifact}/queries $out/lib/runtime/queries/${grammar.name}") builtGrammars;
|
theme: "ln -s ${theme.file} $out/home/helix/themes/${theme.name}.toml"
|
||||||
in {
|
) themeFiles;
|
||||||
packages.x86_64-linux.default =
|
grammarLinks = builtins.map (
|
||||||
pkgs.runCommand "hx" {
|
grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/lib/runtime/grammars/${grammar.name}.so"
|
||||||
buildInputs = [pkgs.makeWrapper];
|
) builtGrammars;
|
||||||
} ''
|
queryLinks = builtins.map (
|
||||||
mkdir $out
|
grammar: "ln -s ${grammar.artifact}/queries $out/lib/runtime/queries/${grammar.name}"
|
||||||
ln -s ${pkgs.helix}/* $out
|
) builtGrammars;
|
||||||
rm $out/bin
|
in
|
||||||
|
{
|
||||||
|
packages.x86_64-linux.default =
|
||||||
|
pkgs.runCommand "hx"
|
||||||
|
{
|
||||||
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
mkdir $out
|
||||||
|
ln -s ${pkgs.helix}/* $out
|
||||||
|
rm $out/bin
|
||||||
|
|
||||||
rm $out/lib
|
rm $out/lib
|
||||||
mkdir -p $out/lib/runtime
|
mkdir -p $out/lib/runtime
|
||||||
ln -s ${pkgs.helix}/lib/runtime/* $out/lib/runtime
|
ln -s ${pkgs.helix}/lib/runtime/* $out/lib/runtime
|
||||||
|
|
||||||
rm $out/lib/runtime/grammars
|
rm $out/lib/runtime/grammars
|
||||||
mkdir $out/lib/runtime/grammars
|
mkdir $out/lib/runtime/grammars
|
||||||
ln -s ${pkgs.helix}/lib/runtime/grammars/* $out/lib/runtime/grammars
|
ln -s ${pkgs.helix}/lib/runtime/grammars/* $out/lib/runtime/grammars
|
||||||
${builtins.concatStringsSep "\n" grammarLinks}
|
${builtins.concatStringsSep "\n" grammarLinks}
|
||||||
|
|
||||||
rm $out/lib/runtime/queries
|
rm $out/lib/runtime/queries
|
||||||
mkdir $out/lib/runtime/queries
|
mkdir $out/lib/runtime/queries
|
||||||
ln -s ${pkgs.helix}/lib/runtime/queries/* $out/lib/runtime/queries
|
ln -s ${pkgs.helix}/lib/runtime/queries/* $out/lib/runtime/queries
|
||||||
${builtins.concatStringsSep "\n" queryLinks}
|
${builtins.concatStringsSep "\n" queryLinks}
|
||||||
|
|
||||||
mkdir -p $out/home/helix/themes
|
mkdir -p $out/home/helix/themes
|
||||||
ln -s ${configFile} $out/home/helix/config.toml
|
ln -s ${configFile} $out/home/helix/config.toml
|
||||||
ln -s ${languageFile} $out/home/helix/languages.toml
|
ln -s ${languageFile} $out/home/helix/languages.toml
|
||||||
${builtins.concatStringsSep "\n" themeLinks}
|
${builtins.concatStringsSep "\n" themeLinks}
|
||||||
|
|
||||||
mkdir -p $out/home/git
|
mkdir -p $out/home/git
|
||||||
ln -s ${ignoreFile} $out/home/git/ignore
|
ln -s ${ignoreFile} $out/home/git/ignore
|
||||||
|
|
||||||
makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx --set HELIX_RUNTIME $out/lib/runtime --set XDG_CONFIG_HOME $out/home
|
makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx --set HELIX_RUNTIME $out/lib/runtime --set XDG_CONFIG_HOME $out/home
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue