{ 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, using the gnumake generator from stdenv. Do NOT add ninja: # its mere presence flips cmake's generator (Make -> Ninja), which then # conflicts with any build dir already cached under the other generator # ("Does not match the generator used previously"). Keeping only cmake # makes the generator deterministic. cmake # 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 ./devenv-docs.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 "$@" ''; # The build-feature matrix (architecture/build-features.md D11, # quality/build-features.md G6/G7). Feature combinations are where cfg rot # hides: a curated set catches what matters without a powerset sweep. Every # entry must be clippy-clean under -D warnings; the two extremes (defaults # and nothing) also run their tests. scripts.check-features.exec = '' set -euo pipefail cd "$DEVENV_ROOT" clippy() { echo "==> clippy $*" cargo clippy --all-targets "$@" -- -D warnings } test_it() { echo "==> test $*" cargo test "$@" } # The two extremes, tests included. clippy -p crabidy-server test_it -p crabidy-server clippy -p crabidy-server --no-default-features test_it -p crabidy-server --no-default-features # Each provider on its own: nothing else may be needed to compile it. for feature in tidal youtube fyyd abs soundcloud jamendo rss fs; do clippy -p crabidy-server --no-default-features --features "$feature" done # Each non-provider axis dropped from an otherwise full build. clippy -p crabidy-server --no-default-features --features all-providers,spectrum,web-ui clippy -p crabidy-server --no-default-features --features all-providers,opus,web-ui clippy -p crabidy-server --no-default-features --features all-providers,opus,spectrum # The local-files appliance and the streaming box from the docs. clippy -p crabidy-server --no-default-features --features fs,opus clippy -p crabidy-server --no-default-features --features tidal,web-ui,opus,spectrum # The other feature-carrying crates. clippy -p audio-player --no-default-features clippy -p cbd-tui --no-default-features test_it -p cbd-tui --no-default-features clippy -p cbd --no-default-features clippy -p cbd --no-default-features --features fs,opus,notifications echo "all feature combinations are clean" ''; 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/ }