Open-source project
nix-community/nix-init avatar
nix-community/nix-init

nix-init: URL-to-Nix package generation with prefetching

Generate Nix packages from URLs with hash prefetching, dependency inference, license detection, and more [maintainer=@figsoda]

1,485 stars45 forksRustMPL-2.0

At a glance

What is it?
nix-init generates starting points for Nix packages from source URLs, with dependency inference, license detection, and hash prefetching. It fits contributors who want a structured derivation draft, but the README explicitly warns that generated packages often require review and adjustment.
Who is it for?
Adopt nix-init when you need a repeatable starting point for a Nix derivation and can review its inferred metadata. Do not treat its output as publishable without checking the build, license, and description.
Can I use it commercially?
Yes, with conditions. MPL-2.0 is a weak copyleft licence: you can use it inside commercial and closed-source software, but if you distribute changes to its own files, you must publish those changes under the same licence.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • nix-community/nix-init1,485 ★ · +2
Star history
Repository2026-10-162026-10-23
nix-community/nix-init1.5k1.5k

2 Stars in the last 7 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

nix-init targets Nix package authors

nix-init addresses the first stage of adding software to nixpkgs: turning a source location into a package expression that can be inspected and corrected. Its intended users are contributors who already work with Nix but do not want to start every derivation from an empty file. The command accepts a URL, prompts for package information, selects a supported builder, and writes an output file or directory.

The tool is not limited to GitHub. The documented fetchers include `fetchFromGitHub`, `fetchFromGitLab`, `fetchFromGitea`, `fetchCrate`, and `fetchPypi`, while the README says that other fetchers supported by `nurl` can also be used. A tag or revision must be entered manually when the URL does not provide the required package metadata.

This is a package-generation aid, not a complete package-validation service. The README places a direct warning at the beginning: a generated package will probably not work without tweaks, and its license and description should be checked even if the build succeeds. That boundary is important for adoption. nix-init can remove repetitive setup, but it cannot decide whether project metadata is legally or editorially acceptable.

The generation flow follows source metadata

According to the README, nix-init combines interactive prompts with automated inspection. Fuzzy tab completion is available for prompts, while `--headless` disables prompting when a URL is supplied. The workflow therefore supports both an interactive contributor session and a scripted invocation, although the documented headless mode still requires `--url`.

The source URL drives fetcher selection. For recognized source services, nix-init can derive details such as the package name and revision, then ask for fields that cannot be inferred reliably. The `--rev` option accepts a tag or revision, while `--pname`, `--builder`, `--version`, and `--cargo-vendor` provide explicit overrides. The available builder choices cover native derivations, Rust, Python, Go, and npm projects:

- `stdenv.mkDerivation` and `stdenvNoCC.mkDerivation` - `buildRustPackage` - `buildPythonApplication` and `buildPythonPackage` - `buildGoModule` - `buildNpmPackage`

This is a useful boundary for evaluating the project. nix-init knows how to emit a shape for several ecosystems, but the list does not mean that every project in those ecosystems is supported. A package may still need changes for unusual build systems, source layouts, runtime dependencies, or project-specific setup.

Dependency and hash handling reduce manual boilerplate

Hash prefetching is powered by `nurl`. For Rust projects, nix-init supports both `cargoHash` and `vendorHash`, and `--cargo-vendor` selects how Cargo dependencies are handled through `fetchCargoVendor` or `importCargoLock`. Dependency inference also covers Go and Python projects, which means the generated expression can reflect the conventions of the selected builder rather than requiring every dependency field to be entered by hand.

The distinction between Cargo hash modes is a practical design choice. `fetchCargoVendor` represents a dependency vendoring approach, while `importCargoLock` uses the lockfile as the source of dependency information. The README does not explain when one mode is preferable for a particular repository, so users still need to inspect the generated expression and source lockfile. The command provides a mechanism, not a project-specific correctness guarantee.

The same caution applies to automatic dependency inference. It can identify common project structures, but it cannot account for every conditional dependency, test-only input, vendored patch, native library, or deployment requirement. The generated file should be treated as a derivation proposal whose dependency fields need the same review as the license and description.

Running nix-init from nixpkgs or a flake

The README says the latest release is packaged in nixpkgs and is kept up to date on unstable branches. For a newer snapshot, the documented flake invocation prints the command help. This gives a first check that Nix can locate and run the tool without installing a separate Rust binary.

Use this command when flakes are already enabled. It should display the `nix-init` usage text:

bash
nix run github:nix-community/nix-init -- --help

If flakes are not enabled, the README documents the experimental-feature form. The command is longer, but it preserves the same source location and help output:

bash
nix run --extra-experimental-features "flakes nix-command" github:nix-community/nix-init -- --help

After that check, the first real generation can be started interactively by supplying a source URL. The exact URL and output path are project-specific, so no fictional package command is included here. The usage text documents `[OUTPUT]` as the path or directory for the generated file, and `-u, --url <URL>` as the source selection option. The README does not document a separate binary installation procedure beyond the nixpkgs package and flake invocation.

Configuration controls nixpkgs, formatting, and repository access

nix-init searches XDG configuration directories for `nix-init/config.toml`. The configuration can define maintainers, select the nixpkgs source, enable commits for name-based output under RFC 140, and provide access tokens for private repositories or rate limits. A formatter can also be configured. If no formatter is specified, nix-init looks for `nixfmt` in `PATH`, while the example uses `alejandra`.

A minimal configuration can set maintainers and a nixpkgs expression. The commented flake example shows how to use a flake registry value, but the actual value is left as a placeholder in the README:

toml
maintainers = ["figsoda"]
nixpkgs = "<nixpkgs>"
commit = true

[access-tokens]
"github.com" = "ghp_blahblahblah..."

[format]
command = ["alejandra"]

The access-token section is more than a convenience for public packages. It supports direct values, commands, and files, including `"gitlab.com".command` and `"gitlab.gnome.org".file`. Token values should not be committed into a shared configuration file. The README documents the syntax but does not describe token scope or rotation policy, so those operational decisions remain outside the project documentation.

The generated package still needs editorial review

The clearest limitation is stated by the project itself: generated packages are likely to need tweaks. The tool automates package metadata, dependency inference, hash prefetching, and license detection, but those steps can produce a draft that is incomplete or contextually wrong. A contributor may need to adjust the builder, replace an inferred dependency, add patches, change source selection, or correct the package description.

License detection is especially not a substitute for checking the repository's actual licensing files and metadata. The README calls out both license and description for double-checking. That is appropriate because automated detection can confuse a repository's declared license with the terms that apply to a particular release, vendored code, or bundled asset. This article does not interpret the MPL-2.0 license or provide legal advice. It only records the project's stated license and the need to verify the license field for each generated package.

The output format also creates workflow considerations. `nix-init` can commit changes when the output path is name-based, which means the tool is close to repository maintenance rather than merely a local code generator. The `-y, --overwrite` option controls automatic file replacement, and `-C, --commit` controls the commit behavior for name-based output. Before using either option in a real nixpkgs checkout, reviewers should inspect the destination and generated diff rather than accepting automation as a substitute for review.

Maintenance status and upgrade work

The repository is not archived, and its last push was on 2026-10-15. Recent releases include v0.3.6 on 2026-05-15, v0.3.5 on 2026-05-15, and v0.3.4 on 2026-03-11. The repository identifies MPL-2.0 as its license, and `Cargo.toml` uses Rust edition 2024 with version 0.3.6. These facts describe the project state without implying that every generated package will remain compatible as nixpkgs changes.

Upgrade work is likely to involve checking the selected builder and fetcher conventions, reviewing dependency inference for the target ecosystem, and confirming that the generated hash and license metadata still match the source. The README does not document a compatibility matrix or a migration procedure for generated expressions. For that reason, an existing automation pipeline around nix-init should not assume that a new release will produce identical output for the same URL.

Editorial conclusion

Adopt nix-init when you need a repeatable starting point for a Nix derivation and can review its inferred metadata. Do not treat its output as publishable without checking the build, license, and description. For the first project-specific check, inspect the generated builder, dependency mode, fetched hash, and license metadata against the source repository.

Frequently asked questions

How do I install or run nix-init?

The README says the latest release is packaged in nixpkgs. It also documents `nix run github:nix-community/nix-init -- --help`, with an alternate command for systems without flakes enabled.

Which package ecosystems does nix-init support?

The documented builders support Rust, Python, Go, and npm projects, along with `stdenv.mkDerivation` and `stdenvNoCC.mkDerivation`. Dependency inference is documented for Rust, Go, and Python.

Does nix-init generate a package that is ready to submit?

No. The README warns that generated packages will likely need tweaks. It specifically says to double-check the license and description even when the generated package works.

Can nix-init access private repositories?

Yes, the configuration supports access tokens for GitHub, GitLab, and other configured hosts. Tokens can be supplied as values, commands, or files, according to the documented configuration examples.

How does nix-init handle Rust dependency hashes?

The README says hash prefetching supports `cargoHash` and `vendorHash`. The `--cargo-vendor` option selects `fetchCargoVendor` or `importCargoLock` for Cargo dependency handling.

Official sources

  1. Issues
  2. License: MPL-2.0
  3. nix-community/nix-init on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nix-community-nix-init.svg)](https://hysenlabs.com/projects/nix-community-nix-init)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/nix-community-nix-init.svg)](https://hysenlabs.com/projects/nix-community-nix-init)

Was this useful?