From 5b4a04718fd47f869d1ae20d2270b17a63a48040 Mon Sep 17 00:00:00 2001 From: Matt Rixman Date: Mon, 16 Sep 2024 02:20:38 +0000 Subject: [PATCH] Adding helix-cogs as a flake output These are necessary for creating dev environments which use the plugin system. Making them a flake output makes it easy to get them without having `cargo xtask code-gen` modify your ~/.config directory. --- flake.nix | 20 ++++++++++++++++++++ helix-term/src/commands/engine/steel.rs | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8bffdb669..e63caf91b 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,25 @@ # filter out unnecessary paths filter = ignorePaths; }; + + helix-cogs = craneLibStable.buildPackage (commonArgs // { + pname = "helix-cogs"; + version = "0.1.0"; + cargoArtifacts = craneLibStable.buildDepsOnly commonArgs; + + buildPhase = '' + export HOME=$PWD/build_home # code-gen will write files relative to $HOME + cargoBuildLog=$(mktemp cargoBuildLogXXXX.json) + cargo run --package xtask -- code-gen --message-format json-render-diagnostics >"$cargoBuildLog" + ''; + + postInstall = '' + mkdir -p $out/cogs + cp -r build_home/.config/helix/* "$out/cogs" + ''; + + }); + makeOverridableHelix = old: config: let grammars = pkgs.callPackage ./grammars.nix config; runtimeDir = pkgs.runCommand "helix-runtime" {} '' @@ -144,6 +163,7 @@ ''; }); helix = makeOverridableHelix self.packages.${system}.helix-unwrapped {}; + helix-cogs = helix-cogs; default = self.packages.${system}.helix; }; diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index d2c74f552..c0d4a8061 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -871,7 +871,10 @@ fn load_editor_api(engine: &mut Engine, generate_sources: bool) { let mut target_directory = helix_runtime_search_path(); if !target_directory.exists() { - std::fs::create_dir(&target_directory).unwrap(); + std::fs::create_dir_all(&target_directory).unwrap_or_else(|err| { + panic!("Failed to create directory {:?}: {}", target_directory, err) + }); + eprintln!("Created directory: {:?}", target_directory); } target_directory.push("editor.scm");