Generate Nix packages from URLs

Overview

nix-init

release version deps license ci

Generate Nix packages from URLs

Note: It is likely that the generated package will not work without some tweaks, also remember to double check the license and description even if it does work

  • Hash prefetching powered by nurl with support for cargoHash and vendorHash
  • Dependency inference for Rust packages using the Riff registry and python projects
  • Interactive prompts with fuzzy tab completions
  • License detection

Installation

The latest release of nix-init is packaged in nixpkgs and kept up to date on the unstable branches

If you want to use a more recent snapshot of nix-init, it is also available as a flake. The following command is equivalent to running nix-init --help:

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

or if you don't have flakes enabled:

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

Usage

Usage: nix-init [OPTIONS] 

Arguments:
    The path to output the generated file to

Options:
  -u, --url         Specify the URL
  -c, --config   Specify the config file
  -h, --help             Print help
  -V, --version          Print version

Supported builders

  • stdenv.mkDerivation
  • buildRustPackage
  • buildPythonApplication and buildPythonPackage
  • buildGoModule

Supported fetchers

  • fetchCrate
  • fetchFromGitHub
  • fetchFromGitLab
  • fetchFromGitea
  • fetchPypi
  • All other fetchers supported by nurl are also supported, you just have to manually input the tag/revision of the package

Configuration

nix-init will try to find nix-init/config.toml under XDG configuration directories

# ~/.config/nix-init/config.toml

# maintainers that will get added to the package meta
maintainers = ["figsoda"]

# access tokens to access private repositories and avoid rate limits
[access-tokens]
"github.com" = "ghp_blahblahblah..."
"gitlab.com".command = ["secret-tool", "or", "whatever", "you", "use"]
"gitlab.gnome.org".file = "/path/to/api/token"

Changelog

See CHANGELOG.md

Comments
  • `error: attribute 'fetchPypi' missing`

    `error: attribute 'fetchPypi' missing`

    Running nix-init against https://pypi.org/project/countryguess/ fails:

    Enter url
    ❯ https://pypi.org/project/countryguess/
    Enter tag or revision (defaults to 0.2.1)
    ❯ 0.2.1
    Enter version
    ❯ 0.2.1
    Enter pname
    ❯ countryguess
    Error: command exited with exit status: 1
    stdout:
    
    stderr:
    error: attribute 'fetchPypi' missing
    
           at «string»:1:44:
    
                1| let pname="countryguess";version="0.2.1";in(import<nixpkgs>{}).fetchPypi {
                 |                                            ^
                2|     inherit pname version;
    

    A cursory glance suggests that this happens in main.rs:282 because it assumes that src_expr makes sense relative to nixpkgs. But for fetchPypi (and presumably fetchCrate, too?) while the argument to the generated nix function will be called fetchPypi, it'll be provided by <nixpkgs>.python3Packages.fetchPypi.

    bug 
    opened by dominikh 3
  • edge case in pyproject parser

    edge case in pyproject parser

    https://github.com/nix-community/nix-init/blob/4c94dd20f91ea24cc176670b7b2eea6236f97c0d/src/python.rs#L70-L83

    dependencies = [
        "Click>=7.0",
        "GitPython~=3.1.30",
        "honcho",
        "Jinja2~=3.0.3",
        "python-crontab~=2.6.0",
        "requests",
        "semantic-version~=2.8.2",
        "setuptools>40.9.0",
        "tomli;python_version<'3.11'",
    ]
    

    tomli;python_version is parsed as tomlipython-version but is appears to be the https://pypi.org/project/tomli/ package. Not sure what the ; notation conveys.

    bug 
    opened by blaggacao 2
  • Python: detect format by inspecting source

    Python: detect format by inspecting source

    The format can be determined by checking the source/sdist. In case there is a pyproject.toml with a build-system section, then the format should be pyproject. It is also possible then to extract the nativeBuildInputs from it. If it is not, but there is a setup.py, it should be setuptools. When neither, it is probably best to keep it open.

    question 
    opened by FRidh 2
  • Fails without NIX_PATH set

    Fails without NIX_PATH set

    stderr:
    error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
    
           at «string»:1:45:
    
                1| let pname="scribe";version="0.0.1";in(import<nixpkgs>{}).fetchFromGitHub {
                 |                                             ^
                2|     owner = "mergestat";
    (use '--show-trace' to show detailed location information)
    
    enhancement good first issue 
    opened by domenkozar 2
  • Bump bstr from 1.1.0 to 1.2.0

    Bump bstr from 1.1.0 to 1.2.0

    Bumps bstr from 1.1.0 to 1.2.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump toml from 0.7.0 to 0.7.1

    Bump toml from 0.7.0 to 0.7.1

    Bumps toml from 0.7.0 to 0.7.1.

    Commits
    • 9a80a78 chore: Release
    • e90b292 chore: Update release process
    • 410ee66 docs: Update changelog
    • 03bd127 Merge pull request #502 from robjtede/doc-features
    • f2e6c0e docs(toml): display feature guarded items on docs.rs
    • 2d728d4 docs(toml-edit): display feature guarded items on docs.rs
    • 5df84a5 docs(toml-datetime): display feature guarded items on docs.rs
    • 08ad143 docs(serde-spanned): display feature guarded items on docs.rs
    • 55d44e7 docs(toml): Point people to 'toml_edit'
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump async-trait from 0.1.63 to 0.1.64

    Bump async-trait from 0.1.63 to 0.1.64

    Bumps async-trait from 0.1.63 to 0.1.64.

    Release notes

    Sourced from async-trait's releases.

    0.1.64

    • Suppress async_yields_async clippy correctness lint in generated code (#236, #237)
    Commits
    • 6a13fce Release 0.1.64
    • ea573a3 Merge pull request #237 from dtolnay/asyncyieldsasync
    • 54cc1ce Suppress async_yields_async clippy correctness lint in generated code
    • e6e736f Add regression test for issue 236
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump indoc from 1.0.8 to 2.0.0

    Bump indoc from 1.0.8 to 2.0.0

    Bumps indoc from 1.0.8 to 2.0.0.

    Release notes

    Sourced from indoc's releases.

    2.0.0

    • Change handling of final newline at zero levels of indentation (#55)
    • Add concatdoc! macro (#56)
    • Raise oldest supported rustc to 1.56

    1.0.9

    • Fix parsing of some edge cases involving angle brackets in writedoc's expr argument (#54)
    Commits
    • bbbec14 Release 2.0.0
    • 24a804e Add concatdoc docs
    • 476b937 Delete paths from .cargo/config
    • b5fb2dc Merge pull request #57 from dtolnay/fromstr
    • 623d666 Replace TokenStream::from_str with Literal::from_str
    • 28d6d25 Switch to 2021 edition
    • 46d38c0 Merge pull request #56 from dtolnay/concat
    • 4fec8a9 Add concatdoc macro
    • 1f70529 Merge pull request #55 from dtolnay/trailing
    • 31694b5 Preserve last newline even if not indented
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump rustyline from `45b9e3d` to `1986b16`

    Bump rustyline from `45b9e3d` to `1986b16`

    Bumps rustyline from 45b9e3d to 1986b16.

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump tokio from 1.24.2 to 1.25.0

    Bump tokio from 1.24.2 to 1.25.0

    Bumps tokio from 1.24.2 to 1.25.0.

    Release notes

    Sourced from tokio's releases.

    Tokio v1.25.0

    1.25.0 (January 28, 2023)

    Fixed

    • rt: fix runtime metrics reporting (#5330)

    Added

    • sync: add broadcast::Sender::len (#5343)

    Changed

    • fs: increase maximum read buffer size to 2MiB (#5397)

    #5330: tokio-rs/tokio#5330 #5343: tokio-rs/tokio#5343 #5397: tokio-rs/tokio#5397

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Bump clap from 4.1.3 to 4.1.4

    Bump clap from 4.1.3 to 4.1.4

    Bumps clap from 4.1.3 to 4.1.4.

    Release notes

    Sourced from clap's releases.

    v4.1.4

    [4.1.4] - 2023-01-24

    Fixes

    • (help) Respect disable_colored_help when using arg_required_else_help

    Performance

    • Speed up compiling arg! macro
    Changelog

    Sourced from clap's changelog.

    [4.1.4] - 2023-01-24

    Fixes

    • (help) Respect disable_colored_help when using arg_required_else_help

    Performance

    • Speed up compiling arg! macro
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • python: detection of the build system as dep

    python: detection of the build system as dep

    https://github.com/frappe/bench/blob/b9e9eac4115b74e3f6adccc2739ae2f7f8f9db1f/pyproject.toml#L45-L48

    hatchling wasn't detected as the build system

    moved from here

    enhancement 
    opened by blaggacao 0
  • More quality-of-life stuff ...

    More quality-of-life stuff ...

    such as, potentially:

    • get commit & source date epoch
    • postinstall completions
    • set ldflags
    {
      src = fetchFromGitHub {
        owner = "yuzutech";
        repo = "kroki-cli";
        rev = "v${version}";
        hash = "sha256-nvmfuG+i1vw2SZIb1g5mS48uZKnjUgKSN/hip5nY2ig=";
        # populate values that require us to use git. By doing this in postFetch we
        # can delete .git afterwards and maintain better reproducibility of the src.
        leaveDotGit = true;
        postFetch = ''
          cd "$out"
          git rev-parse --short HEAD > $out/COMMIT
          # in format of 0000-00-00T00:00:00Z
          date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
          find "$out" -name .git -print0 | xargs -0 rm -rf
        '';
      };
    
      vendorHash = "sha256-HqiNdNpNuFBfwmp2s0gsa2YVf3o0O2ILMQWfKf1Mfaw=";
    
      nativeBuildInputs = [ installShellFiles ];
    
      # ldflags based on metadata from git and source
      preBuild = ''
        ldflags+=" -X main.commit=$(cat COMMIT)"
        ldflags+=" -X main.date=$(cat SOURCE_DATE_EPOCH)"
      '';
    
      ldflags = [
        "-s"
        "-w"
        "-X main.version=v${version}"
      ];
    
      postInstall = ''
        installShellCompletion --cmd kroki \
          --bash <($out/bin/kroki completion bash) \
          --fish <($out/bin/kroki completion fish) \
          --zsh <($out/bin/kroki completion zsh)
      '';
    }
    

    I understand this is hard to maintain, and since these look essentially like workarounds of an non-optimized build* function, hence we might rather need better interfaces in upstream nixpkgs for this.

    enhancement 
    opened by blaggacao 4
  • suggest unstable version if latest tag is too old

    suggest unstable version if latest tag is too old

    example: https://github.com/frida/vala

    2018-08-11 latest tag 0.41.91 2022-11-07 latest commit 62ee2b101a5e5f37ce2a073fdb36e7f6ffb553d1 difference are over 2000 commits

    enhancement 
    opened by milahu 0
  • parse dependencies from meson.build file

    parse dependencies from meson.build file

    just an idea ...

    • parse the top-level meson.build file with muon/src/lang/parser.c
    • find calls to dependency and executable (docs)
    • if has dependencies, add dependency pkg-config

    bonus points:

    • parse option calls from meson_options.txt file
    • parse conditions
    • translate dependencies to nixpkgs names
    enhancement help wanted 
    opened by milahu 1
Releases(v0.1.0)
Owner
Nix community projects
A project incubator that works in parallel of the @NixOS org
Nix community projects
A `nix` and `nix-shell` wrapper for shells other than `bash`

nix-your-shell A nix and nix-shell wrapper for shells other than bash. nix develop and nix-shell use bash as the default shell, so nix-your-shell prin

Mercury 15 Apr 10, 2023
Progress In Nix - Pacman inspired frontend for Nix

Progress In Nix Pinix is a Pacman inspired frontend for Nix. It wraps a regular Nix command and replaces the output with a more modern and informative

Rémi Dupré 23 Mar 9, 2024
fixred is a command line utility to fix outdated links in files with redirect URLs.

fixred fixred is a command line utility to fix outdated links in files with redirect URLs. Installation fixred is installed via cargo package manager.

Linda_pp 35 Aug 6, 2022
A CLI tool for getting screenshots of URLs using headless chrome

rustywitness ?? ?? ?? Web screenshot utility A CLI tool for getting screenshots of URLs using headless chrome Built with ❤︎ by swanandx and contributo

Swanand Mulay 16 Jan 3, 2023
CLI tool that extracts a regex pattern from a list of urls ( Rust )

rextract CLI tool that extracts a regex pattern from a list of urls. The tool is written in Rust and supports PCRE. Installation Step 1: Visit https:/

null 45 Dec 11, 2022
Decode URLs in your files!

urldecoder English | 简体中文 A tool to batch decode URLs in your files. A toy project written in Rust. Decoding URLs shortens the string length and incre

Absolutex 3 Feb 18, 2024
Check the reproducibility status of your Arch Linux packages (read-only mirror)

arch-repro-status A CLI tool for querying the reproducibility status of the Arch Linux packages using data from a rebuilderd instance such as reproduc

Arch Linux 12 Nov 16, 2022
Search PyPI for packages from the command line.

PPS -- Python Package Index Search Search the PyPI for packages by name, which was done by pip search in the past. This was heavily inspired by pip_se

null 5 Nov 2, 2021
A Rust CLI to provide last publish dates for packages in a package-lock.json file

NPM Package Age A Rust CLI which if you provide a npm lockfile (package-lock.json to start), it will give you a listing of all of the packages & the l

Benjamin Lannon 1 Feb 4, 2022
Interface definition generator and standard for Move packages.

Move IDL Interface definition generator and standard for Move packages. Documentation is currently extremely sparse but will be improved in the near f

The Moving Company 10 Aug 25, 2022
Readme generator for Move packages.

Move Readme Readme generator for Move packages. Documentation is currently extremely sparse but will be improved in the near future. Setup Install the

The Moving Company 2 Jul 31, 2022
Fast KubeJS script manager. Includes version control and compatibility with KJSPKG packages.

CarbonJS A KubeJS script manager Features ?? Super fast ⚙️ Version control ?? Constantly new scripts being added ✅ Easy to use ?? Compatibility with K

Krzysztof Poręba 3 May 9, 2023
Packages for Typst.

Typst Packages An experimental package repository for Typst. A searchable list of all packages that were submitted here is available in the official d

Typst 91 Jul 4, 2023
Convert your .NET dependencies to the Directory.Packages.props format

directory-packages-props-converter Converts your projects to use Central Package Management. <PackageReference> dependencies have their Version remove

Jeroen Vannevel 18 Aug 7, 2023
Scan the symbols of all ELF binaries in all Arch Linux packages for usage of malloc_usable_size

Scan the symbols of all ELF binaries in all Arch Linux packages for usage of malloc_usable_size (-D_FORTIFY_SOURCE=3 compatibility)

null 3 Sep 9, 2023
Manage your dotfiles and packages with ease. Define your $HOME as Code 💻 🚀 ✨

EnvHub is a simple tool to manage dotfiles and packages accross multiple machines. Written in Rust, internally it uses nix/homebrew/pkgx/devbox to man

Tsiry Sandratraina 8 Oct 27, 2023
Dog command for *nix systems, Rust port of dog.

dog-rs Dog command for *nix systems, Rust port of dog. Because there is a cat command, should be a dog command too. It was written completely using VS

Juanjo Salvador 2 Sep 29, 2021
A flexible simple theme manager for *nix systems

tema A theme manager for *nix systems respecting the FHS spec configuration As of now all the configuration is done via $XDG_CONFIG_HOME/tema/config.y

lb06 2 Sep 23, 2022
rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and much more.

rpsc rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and mu

null 3 Dec 15, 2022