116 lines
3.5 KiB
Nix
116 lines
3.5 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
inputs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
pkgs-unstable = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; };
|
|
commonLibs = with pkgs; [ alsa-lib ];
|
|
|
|
extraPackages = with pkgs; [
|
|
d2
|
|
pkg-config
|
|
protobuf
|
|
cargo-cross
|
|
# opusic-sys (via symphonia-adapter-libopus) compiles libopus from
|
|
# source with CMake; ninja is picked up automatically if present.
|
|
cmake
|
|
ninja
|
|
# Stream-URL sidecar for the ytdy provider: YouTube caps tokenless
|
|
# stream URLs at ~1 MiB and yt-dlp is the only maintained cipher
|
|
# solver (architecture/youtube-rustypipe.md, D2-revised).
|
|
yt-dlp
|
|
# Web client toolchain (architecture/web-client.md): trunk builds
|
|
# cbd-web to wasm, wasm-bindgen-cli must match the crate version,
|
|
# binaryen provides wasm-opt for release builds.
|
|
trunk
|
|
wasm-bindgen-cli
|
|
binaryen
|
|
];
|
|
in
|
|
{
|
|
imports = [ ./devenv-rust.nix ];
|
|
|
|
# The wasm target for cbd-web; merges with the languages.rust
|
|
# settings in devenv-rust.nix.
|
|
languages.rust.targets = [ "wasm32-unknown-unknown" ];
|
|
|
|
env = {
|
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath commonLibs;
|
|
};
|
|
|
|
# https://devenv.sh/packages/
|
|
packages = commonLibs ++ extraPackages;
|
|
|
|
# https://devenv.sh/processes/
|
|
# processes.cargo-watch.exec = "cargo-watch";
|
|
|
|
# https://devenv.sh/services/
|
|
# services.postgres.enable = true;
|
|
|
|
# https://devenv.sh/scripts/
|
|
scripts.hello.exec = ''
|
|
echo Welcome to rust devenv
|
|
'';
|
|
|
|
# Builds the web client bundle (cbd-web/dist), which crabidy-server
|
|
# embeds on its next build (architecture/web-client.md). RUSTFLAGS is
|
|
# cleared because the mold linker flag from the native toolchain
|
|
# (RUSTFLAGS wins over target-specific config) breaks rust-lld.
|
|
scripts.build-web.exec = ''
|
|
cd "$DEVENV_ROOT/cbd-web" && RUSTFLAGS="" trunk build --release "$@"
|
|
'';
|
|
# Dev loop: live-reloading trunk server proxying gRPC-web to a
|
|
# locally running crabidy-server.
|
|
scripts.serve-web.exec = ''
|
|
cd "$DEVENV_ROOT/cbd-web" && RUSTFLAGS="" trunk serve "$@"
|
|
'';
|
|
# Generates the CLI shell completions and man pages into dist/ by building
|
|
# the native binaries with CBD_ASSET_DIR set (architecture/cli.md D7). Each
|
|
# binary's build.rs copies its assets into $CBD_ASSET_DIR when present, so
|
|
# dist/completions/** and dist/man/*.1 appear after this runs. Unlike
|
|
# build-web (a wasm build) this is a native build, so RUSTFLAGS is left
|
|
# alone — the mold linker flag is correct for the native toolchain.
|
|
scripts.gen-cli-assets.exec = ''
|
|
cd "$DEVENV_ROOT" && CBD_ASSET_DIR="$DEVENV_ROOT/dist" cargo build "$@"
|
|
'';
|
|
|
|
enterShell = "";
|
|
|
|
# https://devenv.sh/tasks/
|
|
# tasks = {
|
|
# "myproj:setup".exec = "mytool build";
|
|
# "devenv:enterShell".after = [ "myproj:setup" ];
|
|
# };
|
|
|
|
# https://devenv.sh/tests/
|
|
enterTest = ''
|
|
echo "Running tests"
|
|
'';
|
|
# https://devenv.sh/git-hooks/
|
|
git-hooks.hooks = {
|
|
nixfmt.enable = true;
|
|
taplo.enable = true;
|
|
markdownlint.enable = true;
|
|
shellcheck.enable = true;
|
|
};
|
|
|
|
# https://devenv.sh/integrations/claude-code/
|
|
# Claude Code integration: writes .claude/{settings,commands,agents}. We keep
|
|
# ownership of .mcp.json (skills wiring), so stop devenv from writing it.
|
|
claude.code.enable = true;
|
|
claude.code.mcpServers = lib.mkForce { };
|
|
claude.code.hooks.git-hooks-run.command = ''
|
|
f=$(${pkgs.jq}/bin/jq -r '.tool_input.file_path // empty')
|
|
if [ -n "$f" ]; then
|
|
cd "''${CLAUDE_PROJECT_DIR:-.}"
|
|
${lib.getExe config.git-hooks.package} run --files "$f"
|
|
fi
|
|
'';
|
|
|
|
# See full reference at https://devenv.sh/reference/options/
|
|
}
|