diff --git a/.gitignore b/.gitignore index eb5a316..e0b5492 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,25 @@ target + +/target + +# devenv +.devenv* +devenv.local.nix +devenv.local.yaml + +# direnv +.direnv + +# pre-commit / git-hooks +.pre-commit-config.yaml +.vim +AGENTS.md +CLAUDE.md +.mcp.json +.codex/ +opencode.json +.claude/ +.agents/ +.opencode/ +.explained/ +*.kickstart-new diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d7eac7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# crabidy diff --git a/devenv-rust.nix b/devenv-rust.nix new file mode 100644 index 0000000..d15ab1a --- /dev/null +++ b/devenv-rust.nix @@ -0,0 +1,61 @@ +{ pkgs, lib, ... }: + +{ + packages = with pkgs; [ + bacon + cargo-deny + cargo-duplicates + cargo-expand + cargo-features-manager + cargo-flamegraph + cargo-geiger + cargo-generate + cargo-hack + cargo-insta + cargo-llvm-cov + cargo-machete + cargo-mutants + cargo-nextest + cargo-rr + cargo-udeps + cargo-vet + cargo-workspaces + git + sccache + tokio-console + vulkan-tools + ]; + env.RUSTC_WRAPPER = "sccache"; + # https://devenv.sh/languages/ + languages.rust = { + enable = true; + channel = "stable"; + clangLinker.enable = true; + mold.enable = true; + rustflags = lib.concatStringsSep " " [ + ]; + components = [ + "rustc" + "cargo" + "clippy" + "rustfmt" + "rust-analyzer" + ]; + }; + tasks."devenv:git-hooks:prepare-shared-hooks-rust" = { + exec = '' + if hooks_dir="$(git rev-parse --git-path hooks 2>/dev/null)"; then + mkdir -p "$hooks_dir" + chmod u+rwx,g+rwx "$hooks_dir" 2>/dev/null || true + find "$hooks_dir" -maxdepth 1 -type f ! -user "$(id -un)" ! -name '*.sample' -delete 2>/dev/null || true + fi + ''; + after = [ "devenv:files" ]; + before = [ "devenv:git-hooks:install" ]; + }; + + git-hooks.hooks = { + rustfmt.enable = true; + clippy.enable = true; + }; +} diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..80570d5 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,141 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1784325378, + "narHash": "sha256-Gof6j4d43yX2qSLLp78JILke346IggDFIxTgl3ecVQE=", + "owner": "cachix", + "repo": "devenv", + "rev": "5f1cf17be0fc48689bd0ecb810de6d2e06d259a1", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1784288435, + "narHash": "sha256-ReRHaLgr/uVqdD8afFSn+myXIfpHeOhP0yYe0TJqAA8=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "43b3c1ab9d40fb1dbb008f451988a91e375825e9", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "nixpkgs": { + "inputs": { + "nixpkgs-src": "nixpkgs-src" + }, + "locked": { + "lastModified": 1783345554, + "narHash": "sha256-LZhOm4kqjHUnwP4CNHpaqqEVcumGNd1PvOEOad8LkS0=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "6004ea8c229fe9d41b21c6f4c76bf6c2e10771dd", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-src": { + "flake": false, + "locked": { + "lastModified": 1783279667, + "narHash": "sha256-/NAkDSsve+GNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f205b5574fd0cb7da5b702a2da51507b7f4fdd1b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1784453100, + "narHash": "sha256-zpGZb8FYui+i8KLtC0nlcmb0voR2zB80Qn8pe7lzIbk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b471514bed69eff5255c8e63c1f80e5fe56c616f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1784438913, + "narHash": "sha256-NYF7ZM5ip0u+w1pBFDpIGEbrbgN/wpnLFAmBkWkYMXw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "afacd6819d3765a05814ee8e3de74c77d42ac799", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} \ No newline at end of file diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..0b40265 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,72 @@ +{ + pkgs, + lib, + config, + inputs, + ... +}: + +let + pkgs-unstable = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; }; + commonLibs = with pkgs; [ alsa-lib ]; + + extraPackages = with pkgs; [ + pkg-config + ]; +in +{ + imports = [ ./devenv-rust.nix ]; + + 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 + ''; + + 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/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..4813749 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,16 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + nixpkgs-unstable: + url: github:nixos/nixpkgs/nixpkgs-unstable + rust-overlay: + url: github:oxalica/rust-overlay + inputs: + nixpkgs: + follows: nixpkgs + git-hooks: + url: github:cachix/git-hooks.nix + inputs: + nixpkgs: + follows: nixpkgs diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..292fe49 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable"