{"id":13688012,"url":"https://github.com/yusdacra/nix-cargo-integration","last_synced_at":"2025-04-13T02:26:18.920Z","repository":{"id":36994900,"uuid":"356708265","full_name":"yusdacra/nix-cargo-integration","owner":"yusdacra","description":"Library to easily and effortlessly integrate Cargo projects with Nix.","archived":false,"fork":false,"pushed_at":"2025-04-12T06:15:18.000Z","size":2929,"stargazers_count":191,"open_issues_count":2,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T07:24:12.912Z","etag":null,"topics":["cargo","devshell","dream2nix","flake","flakes","integration","nix","nix-flake","rust","rust-lang"],"latest_commit_sha":null,"homepage":"https://flake.parts/options/nix-cargo-integration.html","language":"Nix","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/yusdacra.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-04-10T22:16:35.000Z","updated_at":"2025-04-12T06:15:22.000Z","dependencies_parsed_at":"2024-02-19T07:27:34.286Z","dependency_job_id":"16a011ed-4425-4cda-a2ee-dcbed7d409ee","html_url":"https://github.com/yusdacra/nix-cargo-integration","commit_stats":{"total_commits":1957,"total_committers":14,"mean_commits":"139.78571428571428","dds":0.2933060807358201,"last_synced_commit":"295ea83f3c3aa8b9cd482960a7a32f013e9c06ee"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusdacra%2Fnix-cargo-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusdacra%2Fnix-cargo-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusdacra%2Fnix-cargo-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusdacra%2Fnix-cargo-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusdacra","download_url":"https://codeload.github.com/yusdacra/nix-cargo-integration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248656378,"owners_count":21140686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cargo","devshell","dream2nix","flake","flakes","integration","nix","nix-flake","rust","rust-lang"],"created_at":"2024-08-02T15:01:04.977Z","updated_at":"2025-04-13T02:26:18.897Z","avatar_url":"https://github.com/yusdacra.png","language":"Nix","funding_links":[],"categories":["Nix","Programming Languages"],"sub_categories":["Rust"],"readme":"# nix-cargo-integration\n\nEasily and effortlessly integrate Cargo projects with Nix.\n\n- Uses [dream2nix](https://github.com/nix-community/dream2nix) to build Cargo packages and provide a development shell (dream2nix default, also supports numtide devshell, check examples).\n- It's a [flake-parts](https://github.com/hercules-ci/flake-parts) module, so you can easily include it in existing Nix code that also use `flake-parts`.\n- Has sensible defaults, and strives to be compatible with Cargo.\n- Aims to offload work from the user; comes with useful configuration options.\n\n## Documentation\n\nDocumentation for `master` branch is on [flake-parts website](https://flake.parts/options/nix-cargo-integration.html)\n(alternatively, read options directly in [`src/interface.nix`](./src/interface.nix) and [`src/modules`](./src/modules)).\n\nExamples can be found at [`examples`](./examples) directory.\nAlso see the [discussions](https://github.com/yusdacra/nix-cargo-integration/discussions) for answers to possible questions.\n\nImportant (mostly breaking) changes can be found in [`CHANGELOG.md`](./CHANGELOG.md).\n\n## Installation\n\nRun `nix flake init -t github:yusdacra/nix-cargo-integration` to initialize a simple `flake.nix`.\n\nYou can also run `nix flake init -t github:yusdacra/nix-cargo-integration#simple-crate` to initialize a Cargo crate alongside the `flake.nix`,\nor `nix flake init -t github:yusdacra/nix-cargo-integration#simple-workspace` for a Cargo workspace with a `flake.nix`.\n\nIf you already have a `flake.nix` with `flake-parts` setup, just add NCI to inputs:\n\n```nix\n{\n  # ...\n  inputs.nci.url = \"github:yusdacra/nix-cargo-integration\";\n  # ...\n}\n```\n\nand then inside the `mkFlake`:\n\n```nix\n{\n  imports = [\n    inputs.nci.flakeModule\n  ];\n}\n```\n\n## Tips and tricks\n\n### Ignoring `Cargo.lock` in Rust libraries\n\nThe [official recommendation](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)\nfor Rust libraries *used to* say to add `Cargo.lock` to the `.gitignore`.\n[This is now no longer the case](https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html),\nhowever older projects may still do this, which will cause conflicts\nwith the way paths are evaluated when using a `flake.nix`. Only files tracked\nby the version control system (i.e. git) can be accessed during evaluation.\nThis will manifest in the following warning:\n\n```console\n$ nix build\ntrace: Cargo.lock not found for project at path path/to/project.\nPlease ensure the lockfile exists for your project.\nIf you are using a VCS, ensure the lockfile is added to the VCS and not ignored (eg. run `git add path/to/project/Cargo.lock` for git).\n\nThis project will be skipped and won't have any outputs generated.\nRun `nix run .#generate-lockfiles` to generate lockfiles for projects that don't have one.\n```\n\nA neat fix for that is to track the path to `Cargo.lock` without staging it\n([thanks to @bew](https://github.com/yusdacra/nix-cargo-integration/issues/46#issuecomment-962589582)).\n\n```console\n$ git add --intent-to-add Cargo.lock\n```\n\nAdd `--force` if your `Cargo.lock` is listed in `.gitignore`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusdacra%2Fnix-cargo-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusdacra%2Fnix-cargo-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusdacra%2Fnix-cargo-integration/lists"}