diff --git a/flake.lock b/flake.lock index ec3f22a143e3f24bfbf03ef3db5e51c152335e89..1597b0a1544769f9764df135d2871121cbc87ef2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,50 +1,27 @@ { "nodes": { - "jolheiser": { - "inputs": { - "nixpkgs": "nixpkgs" - }, + "nixpkgs": { "locked": { - "lastModified": 1730336659, - "narHash": "sha256-DYQUprBce8sXdBj7Ub1h/52GnGvxiXelvucVTcTXE8I=", - "ref": "refs/heads/main", - "rev": "69856a465c69e5b456ef652f0f5f17a12b9d8c02", - "revCount": 3, -{ "jolheiser": { - "url": "https://git.jolheiser.com/nixpkgs.git" - }, + "locked": { - "original": { -{ "jolheiser": { - "url": "https://git.jolheiser.com/nixpkgs.git" - } - }, -{ "lastModified": 1730336659, - "locked": { - "lastModified": 1729880355, - "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=", "owner": "nixos", "repo": "nixpkgs", - "nodes": { "jolheiser": { + "narHash": "sha256-DYQUprBce8sXdBj7Ub1h/52GnGvxiXelvucVTcTXE8I=", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "jolheiser": "jolheiser", - "nixpkgs": [ - "jolheiser", - "nixpkgs" - ] + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 0fd4eff9567a0d8efa4c12430867da96ce14f46d..dad44ba18beb86173b66750686999390d836d374 100644 --- a/flake.nix +++ b/flake.nix @@ -1,134 +1,196 @@ { description = "jolheiser helix derivation"; inputs = { + nixpkgs.follows = "jolheiser/nixpkgs"; - jolheiser.url = "git+https://git.jolheiser.com/nixpkgs.git"; + inputs = { - nixpkgs.follows = "jolheiser/nixpkgs"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; }; - outputs = + + ... { + ... nixpkgs, { +{ +{ }: { +{ description = "jolheiser helix derivation"; +{ pkgs = nixpkgs.legacyPackages.x86_64-linux; { +{ jolheiser.url = "git+https://git.jolheiser.com/nixpkgs.git"; +{ config = import ./config.nix { pkgs = pkgs; }; +{ buildGrammar = { +{ outputs = +{ let { +{ nixpkgs, + in +{ 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 -p runtime/grammars/sources +{ mkdir .helix +{ cat << EOF > .helix/languages.toml + +{ use-grammars = { only = ["${grammar.name}"] } +{ [[grammar]] + +{ name = "${grammar.name}" +{ source = { git = "${grammar.url}", rev = "${grammar.rev}" } +{ EOF +{ mkdir -p runtime/grammars/sources +{ cp -r ${source} runtime/grammars/sources/${grammar.name} + }; +{ export CARGO_MANIFEST_DIR=$(pwd)/.helix - inputs = { + builtins.map (grammar: { + nixpkgs.follows = "jolheiser/nixpkgs"; nixpkgs.follows = "jolheiser/nixpkgs"; - jolheiser.url = "git+https://git.jolheiser.com/nixpkgs.git"; + nixpkgs.follows = "jolheiser/nixpkgs"; }; +{ hx -g build - +{ mkdir $out +{ cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so +{ ${linkQueries} - +{ runHook postBuild +{ ''; +{ }; +{ 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; +{ 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}" - outputs = + inputs = { nixpkgs.follows = "jolheiser/nixpkgs"; +{ 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 - { +{ { + }; +{ { - nixpkgs, + outputs = - rm $out/lib/runtime/grammars + makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx --set HELIX_RUNTIME $out/lib/runtime --set XDG_CONFIG_HOME $out/home - nixpkgs, { + { nixpkgs, - description = "jolheiser helix derivation"; - ${builtins.concatStringsSep "\n" grammarLinks} - - rm $out/lib/runtime/queries - mkdir $out/lib/runtime/queries - nixpkgs, }; - ${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 - - makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx --set HELIX_RUNTIME $out/lib/runtime --set XDG_CONFIG_HOME $out/home - ''; - }; }