
This PR includes lots of small fixes to get our `build.nix` and
`shell.nix` back to a working state.
I've tested this by running `cargo run` (inside the devshell) and `nix
run` on x86 nixos and arm64 darwin machines. I'd appreciate it if others
could test building inside the devshell to double-check that it's not
just working because I happen to have some system-level packages
installed, as well as seeing if it works on other platforms (non-nixos
linux, arm linux, x86 darwin).
I couldn't get the full test suite (`cargo nextest run --workspace`)
passing in the devshell on darwin, but they _are_ all passing on nixos.
nixpkgs [disables some of our
tests](92d11f06d5/pkgs/by-name/ze/zed-editor/package.nix (L226-L234)
)
that apparently fail or are flakey on hydra, but they don't know why.
I'm going to punt on debugging those for now, especially given that they
seem to be working for me. I'm also unsure of whether we actually want
the nix checkPhase to run the full test suite (it's currently not
passing `--workspace`) given that we have separate CI that should
enforce that those pass on all PRs.
Here's an overview of the changes made:
- Fix our `generate-licenses` script
- Relaxes the `cargo-about` version requirement slightly so it doesn't
try to install an older binary when the nixpkgs one is newer than our
requirement
- Add a workaround for [this cargo-about
issue](https://github.com/zed-industries/zed/issues/19971) obviating the
need for the patching done in the nixpkgs package
- Set the new `--frozen` flag to avoid network access/mutating the
lockfile
- Use dynamic webrtc lib from nixpkgs, and fixes up the build script in
webrtc-sys that hardcodes it to be statically linked.
- Use `inputsFrom` in `shell.nix` and avoid duplicating everything from
`build.nix`
- Add a temporary workaround for an [upstream crane
bug](https://github.com/ipetkov/crane/issues/808).
- Fix shebangs in our `script` dir to not hard-code `/bin/bash`
There are still a bunch of issues that aren't resolved here, I'll make a
tracking issue for those and try to land this first just to get back to
an unbroken state. Eventually among other things I'd like to use a
`libgit2` from `staticPkgs` and musl cross compilation to build the
remote server under nix, and then add that as a separate flake output
and include it in the shell's `inputsFrom` list.
Thanks @niklaskorz, @GaetanLepage, @bbigras and all the other nixpkgs
maintainers that have kept the `zed-editor` package working and up to
date! I seriously considered just making our flake `overrideAttrs` the
package in nixpkgs given how well maintained it is.
Thanks @WeetHet for your volunteer maintinance of this flake. I
referenced #24953 while working on these fixes, and I'd love to
collaborate on adding some of those pieces like treefmt and a github
action. If you're interested I'd really appreciate some help debugging
why crane's `buildDepsOnly` isn't working for us. I'm assuming it'd make
our `nix build` times go way down from the improved dep caching if we
could get it working.
Thanks @rrbutani for all the help on this PR 💙.
Release Notes:
- N/A
---------
Co-authored-by: Rahul Butani <rrbutani@users.noreply.github.com>
Co-authored-by: Rahul Butani <rr.butani@gmail.com>
61 lines
2.8 KiB
Bash
Executable file
61 lines
2.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# This script manages prompt overrides for the Zed editor.
|
|
#
|
|
# It provides functionality to:
|
|
# 1. Link the current repository's prompt templates to Zed's configuration.
|
|
# 2. Create and link a separate Git worktree for prompt management.
|
|
# 3. Unlink previously linked prompt overrides.
|
|
#
|
|
# Usage:
|
|
# ./script_name.sh link # Link current repo's prompts
|
|
# ./script_name.sh link --worktree # Create and link a separate worktree
|
|
# ./script_name.sh unlink # Remove existing prompt override link
|
|
#
|
|
# The script ensures proper Git branch and worktree setup when using the
|
|
# --worktree option. It also provides informative output and error handling.
|
|
|
|
if [ "$1" = "link" ]; then
|
|
# Remove existing link (or directory)
|
|
rm -rf ~/.config/zed/prompt_overrides
|
|
if [ "$2" = "--worktree" ]; then
|
|
# Check if 'prompts' branch exists, create if not
|
|
if ! git show-ref --quiet refs/heads/prompts; then
|
|
git branch prompts
|
|
fi
|
|
# Check if 'prompts' worktree exists
|
|
if git worktree list | grep -q "../zed_prompts"; then
|
|
echo "Worktree already exists at ../zed_prompts."
|
|
else
|
|
# Create worktree if it doesn't exist
|
|
git worktree add ../zed_prompts prompts || git worktree add ../zed_prompts -b prompts
|
|
fi
|
|
ln -sf "$(realpath "$(pwd)/../zed_prompts/assets/prompts")" ~/.config/zed/prompt_overrides
|
|
echo "Linked $(realpath "$(pwd)/../zed_prompts/assets/prompts") to ~/.config/zed/prompt_overrides"
|
|
echo -e "\033[0;33mDon't forget you have it linked, or your prompts will go stale\033[0m"
|
|
else
|
|
ln -sf "$(pwd)/assets/prompts" ~/.config/zed/prompt_overrides
|
|
echo "Linked $(pwd)/assets/prompts to ~/.config/zed/prompt_overrides"
|
|
fi
|
|
elif [ "$1" = "unlink" ]; then
|
|
if [ -e ~/.config/zed/prompt_overrides ]; then
|
|
# Remove symbolic link
|
|
rm -rf ~/.config/zed/prompt_overrides
|
|
echo "Unlinked ~/.config/zed/prompt_overrides"
|
|
else
|
|
echo -e "\033[33mWarning: No file exists at ~/.config/zed/prompt_overrides\033[0m"
|
|
fi
|
|
else
|
|
echo "This script helps you manage prompt overrides for Zed."
|
|
echo "You can link this directory to have Zed use the contents of your current repo templates as your active prompts,"
|
|
echo "or store your modifications in a separate Git worktree."
|
|
echo
|
|
echo "Usage: $0 [link [--worktree]|unlink]"
|
|
echo
|
|
echo "Options:"
|
|
echo " link Create a symbolic link from ./assets/prompts to ~/.config/zed/prompt_overrides"
|
|
echo " link --worktree Create a 'prompts' Git worktree in ../prompts, then link ../prompts/assets/prompts"
|
|
echo " to ~/.config/zed/prompt_overrides"
|
|
echo " unlink Remove the symbolic link at ~/.config/zed/prompt_overrides"
|
|
exit 1
|
|
fi
|