{"id":35154578,"url":"https://github.com/7mind/squish-find-the-brains","last_synced_at":"2026-05-23T14:31:26.388Z","repository":{"id":325156119,"uuid":"1100063474","full_name":"7mind/squish-find-the-brains","owner":"7mind","description":"Nix wrapper for SBT","archived":false,"fork":false,"pushed_at":"2026-03-29T23:33:42.000Z","size":61,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-13T10:38:36.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/7mind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-19T19:43:47.000Z","updated_at":"2026-04-01T19:48:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/7mind/squish-find-the-brains","commit_stats":null,"previous_names":["7mind/sbt-nix"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/7mind/squish-find-the-brains","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7mind%2Fsquish-find-the-brains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7mind%2Fsquish-find-the-brains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7mind%2Fsquish-find-the-brains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7mind%2Fsquish-find-the-brains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7mind","download_url":"https://codeload.github.com/7mind/squish-find-the-brains/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7mind%2Fsquish-find-the-brains/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33400245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-28T16:18:17.001Z","updated_at":"2026-05-23T14:31:26.382Z","avatar_url":"https://github.com/7mind.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# squish-find-the-brains\n\n[![CI](https://github.com/7mind/squish-find-the-brains/actions/workflows/ci.yml/badge.svg)](https://github.com/7mind/squish-find-the-brains/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Nix](https://img.shields.io/badge/Built%20with-Nix-5277C3.svg?logo=nixos\u0026logoColor=white)](https://builtwithnix.org)\n[![Nix Flake](https://img.shields.io/badge/Nix-Flake-blue.svg)](https://nixos.wiki/wiki/Flakes)\n\nReusable Nix flake for building sbt projects with lockfile-based dependency management.\n\n## Overview\n\nThis flake provides a two-phase approach to building sbt projects in Nix:\n\n1. **Lockfile generation**: Run sbt with network access to discover dependencies, then generate a lockfile with SHA256 hashes\n2. **Offline build**: Use the lockfile to fetch dependencies as content-addressed Nix store paths, then build in offline mode\n\nThis approach avoids fixed-output derivations (FODs) and provides fully reproducible builds.\n\n## Quick Start\n\n### 1. Add to your flake\n\n```nix\n{\n  inputs = {\n    nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n    flake-utils.url = \"github:numtide/flake-utils\";\n    squish-find-the-brains.url = \"github:7mind/squish-find-the-brains\";\n  };\n\n  outputs = { self, nixpkgs, flake-utils, squish-find-the-brains }:\n    flake-utils.lib.eachDefaultSystem (system:\n      let\n        pkgs = import nixpkgs {\n          inherit system;\n          config.allowUnfree = true;\n        };\n\n        coursierCache = squish-find-the-brains.lib.mkCoursierCache {\n          inherit pkgs;\n          lockfilePath = ./deps.lock.json;\n        };\n\n        sbtSetup = squish-find-the-brains.lib.mkSbtSetup {\n          inherit pkgs coursierCache;\n        };\n      in\n      {\n        packages.default = pkgs.stdenv.mkDerivation {\n          pname = \"my-app\";\n          version = \"1.0.0\";\n          src = ./.;\n\n          nativeBuildInputs = sbtSetup.nativeBuildInputs;\n          inherit (sbtSetup) JAVA_HOME;\n\n          buildPhase = ''\n            ${sbtSetup.setupScript}\n            sbt --batch compile assembly\n          '';\n\n          installPhase = ''\n            mkdir -p $out/lib\n            cp target/scala-*/my-app.jar $out/lib/\n          '';\n        };\n      }\n    );\n}\n```\n\n### 2. Create lockfile config\n\nCreate `lockfile-config.json`:\n\n```json\n{\n  \"sbt_runs\": [\n    {\"args\": [\";reload plugins; update; reload return\"]},\n    {\"args\": [\"+update\", \"+compile\"]}\n  ]\n}\n```\n\nthe `{\"args\": [\";reload plugins; update; reload return\"]},` line is especially important to make sure all the plugins were pulled in.\n\n### 3. Generate lockfile\n\n```bash\nnix run github:7mind/squish-find-the-brains -- lockfile-config.json -o deps.lock.json\n```\n\n### 4. Build\n\n```bash\nnix build\n```\n\n## API Reference\n\n### `mkCoursierCache`\n\nBuilds a Coursier cache from a lockfile.\n\n```nix\nsquish-find-the-brains.lib.mkCoursierCache {\n  pkgs = pkgs;                    # required: nixpkgs package set\n  lockfilePath = ./deps.lock.json; # required: path to lockfile\n}\n```\n\nReturns a derivation containing the reconstructed Coursier cache.\n\n### `mkSbtSetup`\n\nGenerates sbt setup configuration for use in custom derivations.\n\n```nix\nsquish-find-the-brains.lib.mkSbtSetup {\n  pkgs = pkgs;                    # required: nixpkgs package set\n  coursierCache = coursierCache;  # required: from mkCoursierCache\n  jdk = pkgs.jdk21;              # optional: JDK to use (default: jdk21)\n  extraSbtOpts = \"\";             # optional: additional SBT_OPTS\n}\n```\n\nReturns an attrset with:\n- `setupScript`: shell script to set up sbt environment\n- `nativeBuildInputs`: packages needed for building (sbt, jdk, which)\n- `JAVA_HOME`: path to JDK\n\n### `mkSbtShell`\n\nCreates a development shell for sbt projects.\n\n```nix\nsquish-find-the-brains.lib.mkSbtShell {\n  pkgs = pkgs;                    # required: nixpkgs package set\n  jdk = pkgs.jdk21;              # optional: JDK to use\n  extraPackages = [];            # optional: additional packages\n  shellHook = \"\";                # optional: additional shell hook\n}\n```\n\n## Lockfile Format\n\nThe lockfile is a JSON file with the following structure:\n\n```json\n{\n  \"version\": 1,\n  \"artifacts\": [\n    {\n      \"url\": \"https://repo1.maven.org/maven2/...\",\n      \"sha256\": \"base32-encoded-hash\"\n    }\n  ]\n}\n```\n\n## Local Development\n\n```bash\n# Enter development shell\nnix develop\n\n# Generate lockfile\npython scripts/generate-lockfile.py lockfile-config.json -o deps.lock.json\n\n# Build\nnix build\n```\n\n## Testing\n\nThe `test/` directory contains a sample project demonstrating usage:\n\n```bash\ncd test\n\n# Generate lockfile\nnix develop ..#default --command python ../scripts/generate-lockfile.py lockfile-config.json -o deps.lock.json\n\n# Build with local squish-find-the-brains\nnix build --override-input squish-find-the-brains path:..\n\n# Run\n./result/bin/squish-find-the-brains-test\n```\n\n## Alternatives\n\n### sbt-derivation\n\n[sbt-derivation](https://github.com/zaninime/sbt-derivation) is another approach to building sbt projects in Nix. It uses a fixed-output derivation (FOD) to fetch dependencies, which has different trade-offs:\n\n**sbt-derivation (FOD approach)**:\n- Simpler setup - no lockfile generation step\n- Dependencies fetched in a single FOD\n- Hash must be updated when dependencies change\n- Less granular caching\n\n**squish-find-the-brains (lockfile approach)**:\n- Each dependency is a separate content-addressed derivation\n- Better caching - unchanged dependencies are reused\n- Lockfile provides visibility into exact dependencies\n- Requires lockfile generation step\n\nChoose based on your needs:\n- Use **sbt-derivation** for simpler projects or when you prefer less setup\n- Use **squish-find-the-brains** for better caching, reproducibility, and dependency visibility\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7mind%2Fsquish-find-the-brains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7mind%2Fsquish-find-the-brains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7mind%2Fsquish-find-the-brains/lists"}