Merge pull request #7 from MatrixManAtYrService/cogs-output

Add a flake output for the helix cogs
This commit is contained in:
Matthew Paras 2024-10-22 22:34:41 -07:00 committed by GitHub
commit 29ce6fffda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -74,6 +74,25 @@
# filter out unnecessary paths # filter out unnecessary paths
filter = ignorePaths; 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 makeOverridableHelix = old: config: let
grammars = pkgs.callPackage ./grammars.nix config; grammars = pkgs.callPackage ./grammars.nix config;
runtimeDir = pkgs.runCommand "helix-runtime" {} '' runtimeDir = pkgs.runCommand "helix-runtime" {} ''
@ -146,6 +165,7 @@
''; '';
}); });
helix = makeOverridableHelix self.packages.${system}.helix-unwrapped {}; helix = makeOverridableHelix self.packages.${system}.helix-unwrapped {};
helix-cogs = helix-cogs;
default = self.packages.${system}.helix; default = self.packages.${system}.helix;
}; };

View File

@ -871,7 +871,10 @@ fn load_editor_api(engine: &mut Engine, generate_sources: bool) {
let mut target_directory = helix_runtime_search_path(); let mut target_directory = helix_runtime_search_path();
if !target_directory.exists() { 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"); target_directory.push("editor.scm");