Git Product home page Git Product logo

nix-init's Introduction

nix-init

matrix release version 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, Go, 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] [OUTPUT]

Arguments:
  [OUTPUT]  The path or directory to output the generated file to

Options:
  -u, --url <URL>          Specify the URL
  -n, --nixpkgs <NIXPKGS>  Path to nixpkgs (in nix)
  -C, --commit[=<COMMIT>]  Commit the changes if the output path is name-based (RFC 140) [possible values: true, false]
  -c, --config <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"]

# path to nixpkgs (in nix), equivalent to `--nixpkgs`
nixpkgs = "<nixpkgs>" # use the nixpkgs from channels (default)
# nixpkgs = 'builtins.getFlake "nixpkgs"' # use the nixpkgs from the flake registry

# commit the changes if the output path is name-based (RFC 140)
# see https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name for more information
commit = true

# 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

nix-init's People

Contributors

dependabot[bot] avatar figsoda avatar ninja3047 avatar pschmitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nix-init's Issues

Incorrect package homepage when using SSH git URL

When using a SSH for the package, it is put verbantim into the metadata of the generated package definition.
E.g. using [email protected]:ekzhang/sshx.git for a package generates a working package but it has this metadata section:

 meta = with lib; {
    description = "Fast, collaborative live terminal sharing over the web";
    homepage = "[email protected]:ekzhang/sshx.git";
    license = licenses.mit;
    maintainers = with maintainers; [ pinpox ];
    mainProgram = "sshx";
    };

It would be nice, if this would be automatically filled with https://github.com/ekzhang/sshx instead.

edge case in pyproject parser

nix-init/src/python.rs

Lines 70 to 83 in 4c94dd2

pub fn get_dependencies(&mut self) -> Option<BTreeSet<String>> {
if let Some(deps) = self.project.dependencies.take() {
Some(deps.into_iter().filter_map(get_python_dependency).collect())
} else if let Some(mut deps) = self.tool.poetry.dependencies.take() {
deps.remove(&("python".into(), ()));
Some(
deps.into_iter()
.map(|(dep, _)| dep.to_lowercase().replace(['_', '.'], "-"))
.collect(),
)
} else {
None
}
}

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.

bitbucket support

This fails:

$ nix-init --url=https://bitbucket.org/dtrypogeorgos/pylion pkgs/development/python-modules/pylion/default.nix

Enter tag or revision
❯ unstable
Enter version
❯ unstable
Enter pname
❯ pylion
Error: command exited with exit status: 1
stdout:

stderr:
$ nix-prefetch-url --unpack https://bitbucket.org/dtrypogeorgos/pylion/get/unstable.tar.gz
error: unable to download 'https://bitbucket.org/dtrypogeorgos/pylion/get/unstable.tar.gz': HTTP error 404

       response body:

       Cannot resolve the cset
Error: command exited with exit status: 1

Identify CMake antipattern of putting CMakeLists.txt in src subfolder

Below are two examples of projects that are easy to package with nix-init, except the CMakeLists.txt are wrongly stored in the src/ subfolder of the project, which also confuses Nix's CMake hooks. All I had to do to compile these projects after running nix-init was

  1. add cmake to nativeBuildInputs
  2. add `preConfigure = "cd src";

It's possible that this case could be caught by nix-init

Support for kali-linux's gitlab

As part of the effort tracked at https://t4ccer.com/arewehackersyet/ to package most tools available in kali in nixpkgs to make it a viable choice for pentesting I noticed nix-init doesn't work on any of the gitlab urls.

I havn't been able to find out why, since the url seems correct and is reachable, so I must suspect a bug.

Example:
Trying with https://gitlab.com/kalilinux/packages/wifi-honey results in this error:

shell ❯ nix-init -u https://gitlab.com/kalilinux/packages/wifi-honey                                                                                                                                                              
Enter tag or revision (defaults to kali/1.0-1kali3)
❯ kali/1.0-1kali3
Enter version
❯ 1.0-1kali3
Enter pname
❯ wifi-honey
Error: command exited with exit status: 1
stdout:

stderr:
$ nix flake prefetch --extra-experimental-features 'nix-command flakes' --json gitlab:kalilinux%2Fpackages/wifi-honey/kali/1.0-1kali3
error:
       … while fetching the input 'gitlab:kalilinux/packages/wifi-honey/kali/1.0-1kali3'

       error: unable to download 'https://gitlab.com/api/v4/projects/kalilinux%2Fpackages/repository/commits?ref_name=wifi-honey/kali/1.0-1kali3': HTTP error 404

       response body:

       {"message":"404 Project Not Found"}
Error: command exited with exit status: 1

I've tried a few other packages and got the same error, let me know if there is a workaround or this can be fixed.

Why write out meta.platforms?

I find this behavior peculiar:

nix-init/src/main.rs

Lines 998 to 1004 in c6e51b1

if matches!(choice, BuildType::MkDerivation { .. }) {
if has_zig {
writeln!(out, " inherit (zig.meta) platforms;")?;
} else {
writeln!(out, " platforms = platforms.all;")?;
}
}

From my understanding, by default we want to support all platforms, unless upstream explicitly states that they don't intend to support other platforms, or when it is obvious from the functionality of the program (such as when it refers to the Linux kernel for example).

Inferring the later just by getting a package's URL is too much to ask from nix-init, and if all platforms should be supported, then there should be no need to write platforms = lib.platforms.all;. Also, the inheritance of (zig.meta) platforms seems unnecessary to me because that could be evaluated as so, simply because zig's build hooks should not evaluate on platforms not supported by zig. Hence in both cases stating meta.platforms seems something nix-init should not do by itself.

Selection does not work under zsh.

When attempting to select the method used with tab it only comes up with option 0 on zsh. When I try typing in another option it just says hit tab to see options. The only thing I can do is hit enter. Typing any number 0-5 does nothing but tell me to hit tab.

`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.

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)

Generate `pytestCheckHook` input and usage in `nativeCheckInputs` if you detect a `pytest` dependency.

I recently used nix-init to package someone else's Python package and it was so, so nice. The only thing that it didn't really generate for me was the need to use pytestCheckHook to run the package's test suite. It seems like it would be possible to parse a requirements.txt or pyproject.toml to look for a pytest dependency and then generate the necessary code to automatically run the package's test suite.

UI Redesign

The current tui is far from perfect, file path completions have some unconventional behavior, and we are simulating selection with completions

Error during building

When I install nix-init by flakes, I get the following error:

error: builder for '/nix/store/yx8ljarp4iw09s6dg8y5r9nh9v88bq0q-nix-init-deps-0.2.4.drv' failed with exit code 101;
       last 10 log lines:
       >    Compiling xdg v2.5.2
       >    Compiling shlex v1.2.0
       >    Compiling rustc-hash v1.1.0
       >    Compiling heck v0.4.1
       >    Compiling owo-colors v3.5.0
       > error: could not compile `cargo` (lib)
       >
       > Caused by:
       >   process didn't exit successfully: `rustc --crate-name cargo --edition=2021 /nix/store/r33by1m36ah84w1aag5m4370dn6aki4k-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/cargo-0.73.1/src/cargo/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C panic=abort -C linker-plugin-lto -C codegen-units=1 -C metadata=0eeb0971c2a3b0e8 -C extra-filename=-0eeb0971c2a3b0e8 --out-dir /build/source/target/release/deps -L dependency=/build/source/target/release/deps --extern anyhow=/build/source/target/release/deps/libanyhow-b7f562864cbd737d.rmeta --extern base64=/build/source/target/release/deps/libbase64-67f90d356d583dc4.rmeta --extern bytesize=/build/source/target/release/deps/libbytesize-443a6df8bcdfb531.rmeta --extern cargo_platform=/build/source/target/release/deps/libcargo_platform-e0a5fb414db3e113.rmeta --extern cargo_util=/build/source/target/release/deps/libcargo_util-9bc7b849d9eff6f2.rmeta --extern clap=/build/source/target/release/deps/libclap-77a4ec510d0f6568.rmeta --extern crates_io=/build/source/target/release/deps/libcrates_io-90bd9d695690bf29.rmeta --extern curl=/build/source/target/release/deps/libcurl-0e17ad1e6a619ae5.rmeta --extern curl_sys=/build/source/target/release/deps/libcurl_sys-dd5fa7f722fa70ef.rmeta --extern env_logger=/build/source/target/release/deps/libenv_logger-55ed8d255756a493.rmeta --extern filetime=/build/source/target/release/deps/libfiletime-86e197816bb3a898.rmeta --extern flate2=/build/source/target/release/deps/libflate2-b846726ea77a6034.rmeta --extern git2=/build/source/target/release/deps/libgit2-2d0f81eea1e9bf48.rmeta --extern git2_curl=/build/source/target/release/deps/libgit2_curl-99b085d427e8daa6.rmeta --extern gix=/build/source/target/release/deps/libgix-c4d9eba5a763b5fb.rmeta --extern gix_features_for_configuration_only=/build/source/target/release/deps/libgix_features-bc5a8a203a5d6c59.rmeta --extern glob=/build/source/target/release/deps/libglob-bb0260906f02b540.rmeta --extern hex=/build/source/target/release/deps/libhex-2af30eb7653445a1.rmeta --extern hmac=/build/source/target/release/deps/libhmac-b6b98d3f0c8f52b1.rmeta --extern home=/build/source/target/release/deps/libhome-90dd22b0af13068a.rmeta --extern http_auth=/build/source/target/release/deps/libhttp_auth-20909025cd5b34e4.rmeta --extern humantime=/build/source/target/release/deps/libhumantime-9292ff0624d72fe6.rmeta --extern ignore=/build/source/target/release/deps/libignore-0d9406aa1f711435.rmeta --extern im_rc=/build/source/target/release/deps/libim_rc-5d9b2f821862b10e.rmeta --extern indexmap=/build/source/target/release/deps/libindexmap-98fe13a2b3142fbd.rmeta --extern itertools=/build/source/target/release/deps/libitertools-9a52a111f58e76cf.rmeta --extern jobserver=/build/source/target/release/deps/libjobserver-4b50b03740a2d116.rmeta --extern lazycell=/build/source/target/release/deps/liblazycell-f53683c711f1c3d3.rmeta --extern libc=/build/source/target/release/deps/liblibc-2aa49cd6a89e8499.rmeta --extern libgit2_sys=/build/source/target/release/deps/liblibgit2_sys-b2bc8d5bfdf26cad.rmeta --extern log=/build/source/target/release/deps/liblog-8cdb29a11108e6a3.rmeta --extern memchr=/build/source/target/release/deps/libmemchr-70cec2643a126710.rmeta --extern opener=/build/source/target/release/deps/libopener-b8b5efdc7ebd486f.rmeta --extern os_info=/build/source/target/release/deps/libos_info-f4ec8f7f06248f6a.rmeta --extern pasetors=/build/source/target/release/deps/libpasetors-02bd7052de9ec7bb.rmeta --extern pathdiff=/build/source/target/release/deps/libpathdiff-a7742c83bda6ed73.rmeta --extern pulldown_cmark=/build/source/target/release/deps/libpulldown_cmark-5c4e207d180181c3.rmeta --extern rand=/build/source/target/release/deps/librand-71a9d5abcb5bcd52.rmeta --extern rustfix=/build/source/target/release/deps/librustfix-c7c4fa29055be5f1.rmeta --extern semver=/build/source/target/release/deps/libsemver-bbae05039fb1cf5b.rmeta --extern serde=/build/source/target/release/deps/libserde-81fbe35bf4e7e680.rmeta --extern serde_value=/build/source/target/release/deps/libserde_value-f58e5f5d2bf7499d.rmeta --extern serde_ignored=/build/source/target/release/deps/libserde_ignored-e8c9468d2c3f5bbf.rmeta --extern serde_json=/build/source/target/release/deps/libserde_json-8bac1f4b899feed8.rmeta --extern sha1=/build/source/target/release/deps/libsha1-8cf56105336824e0.rmeta --extern shell_escape=/build/source/target/release/deps/libshell_escape-6684ff6a98f16c0b.rmeta --extern strip_ansi_escapes=/build/source/target/release/deps/libstrip_ansi_escapes-5204e53917c19d8d.rmeta --extern syn=/build/source/target/release/deps/libsyn-e99593ac6c306204.rmeta --extern tar=/build/source/target/release/deps/libtar-28f7ec4df6d1c7d4.rmeta --extern tempfile=/build/source/target/release/deps/libtempfile-50cc80795debf787.rmeta --extern termcolor=/build/source/target/release/deps/libtermcolor-d1b3da5ac0202d85.rmeta --extern time=/build/source/target/release/deps/libtime-ff5c7c1e3c49e40d.rmeta --extern toml=/build/source/target/release/deps/libtoml-fd813f6f49e98950.rmeta --extern toml_edit=/build/source/target/release/deps/libtoml_edit-b502f7226cdfc259.rmeta --extern unicode_width=/build/source/target/release/deps/libunicode_width-a5276187e8789c22.rmeta --extern unicode_xid=/build/source/target/release/deps/libunicode_xid-18756c01d016b0cb.rmeta --extern url=/build/source/target/release/deps/liburl-5bf09a2b220bf21c.rmeta --extern walkdir=/build/source/target/release/deps/libwalkdir-0a7eb81b4dd7fd78.rmeta --cap-lints allow -L native=/nix/store/q7m83mxscdx0jcwq55avdlcf0izqghx2-curl-8.1.1/lib -L native=/build/source/target/release/build/libnghttp2-sys-e4f8c42ad8becc7a/out/i/lib -L native=/nix/store/wmi7ifah7ggl9bah85zpmsgxv6lk04a7-zlib-1.2.13/lib -L native=/nix/store/73dswnrd48wncy29ij3b4i71554ap74s-openssl-3.0.9/lib -L native=/nix/store/fgmd2qwfjchwwbl23j12px0q98myl423-libgit2-1.6.4/lib -L native=/build/source/target/release/build/libssh2-sys-f5cb35f8c5db2d9c/out/build` (signal: 15, SIGTERM: termination signal)
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix-store -l /nix/store/yx8ljarp4iw09s6dg8y5r9nh9v88bq0q-nix-init-deps-0.2.4.drv'.
error: 1 dependencies of derivation '/nix/store/l8ls8kn17jfvh0sa3vs588815r4dmvmm-nix-init-0.2.4.drv' failed to build

Handle pypi packages without source available

For example https://pypi.org/project/mediapipe/#files has no source available. nix-init should probably detect this and display a short error explaining the situation, rather than crashing.

 ➜ nix-init -u https://pypi.org/project/mediapipe/
Enter output path (defaults to current directory)
❯ tmp
Do you want to overwrite tmp? (Y/n)
❯ Y
Enter tag or revision (defaults to )
❯ v0.9.2.1
Enter version
❯ 0.9.2.1
Enter pname
❯ mediapipe
Error: command exited with exit status: 1
stdout:

stderr:
$ nix-prefetch-url https://pypi.org/packages/source/m/mediapipe/mediapipe-v0.9.2.1.tar.gz
error: unable to download 'https://pypi.org/packages/source/m/mediapipe/mediapipe-v0.9.2.1.tar.gz': HTTP error 404
Error: command exited with exit code exit status: 1

nixpkgs not found

I am trying to generate a first nix config from a go project.

What's the problem?

# nix run github:nix-community/nix-init -- -u https://github.com/tcurdt/release-go
Enter tag or revision (defaults to v1.0.3)
❯ v1.0.3
Enter version
❯ 1.0.3
Enter pname
❯ release-go
Error: command exited with exit status: 1
stdout:

stderr:
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error:
       … while calling the 'import' builtin

         at «string»:1:43:

            1| let pname="release-go";version="1.0.3";in(import(<nixpkgs>){}).fetchFromGitHub {
             |                                           ^
            2|     owner = "tcurdt";

       … while calling the 'findFile' builtin

         at «string»:1:50:

            1| let pname="release-go";version="1.0.3";in(import(<nixpkgs>){}).fetchFromGitHub {
             |                                                  ^
            2|     owner = "tcurdt";

       error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

pypi: make extras optional

All extras seem to be added by default. I don't think this is a good default. Just now my package had extra's with really old packages, from 2007, for a completely uninteresting feature.

github:yarnpkg/berry/@yarnpkg/cli/4.0.0-rc.41', '@yarnpkg/cli/4.0.0-rc.41' is not a branch/tag name Error: command exited with exit code exit status: 1

https://github.com/yarnpkg/berry/releases/tag/@yarnpkg/cli/4.0.0-rc.41

github:yarnpkg/berry/@yarnpkg/cli/4.0.0-rc.41', '@yarnpkg/cli/4.0.0-rc.41' is not a branch/tag name
Error: command exited with exit code exit status: 1

Reproduce

nix-init
Enter output path (defaults to current directory)
❯ .
Do you want to overwrite ./default.nix? (Y/n)
❯
Enter url
❯ https://github.com/yarnpkg/berry
Enter tag or revision (defaults to @yarnpkg/cli/3.5.0)
❯ @yarnpkg/cli/4.0.0-rc.41
Enter version
❯ 4.0.0-rc.41
Enter pname
❯ yarn-berry
Error: command exited with exit status: 1
stdout:

stderr:
$ nix flake prefetch --experimental-features 'nix-command flakes' --json github:yarnpkg/berry/@yarnpkg/cli/4.0.0-rc.41
error: in URL 'github:yarnpkg/berry/@yarnpkg/cli/4.0.0-rc.41', '@yarnpkg/cli/4.0.0-rc.41' is not a branch/tag name
Error: command exited with exit code exit status: 1

error fetching from pypi on nixos-unstable

Error: command exited with exit status: 1
stdout:

stderr:
error:
       … while evaluating the attribute 'python3.pkgs.fetchPypi'

         at /nix/store/dk53i5b3g3qrjd9g9gi7npv94zwylhxf-source/pkgs/development/interpreters/python/passthrufun.nix:87:5:

           86|     withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
           87|     pkgs = pythonPackages;
             |     ^
           88|     interpreter = "${self}/bin/${executable}";

       error: attribute 'fetchPypi' missing

       at «string»:1:39:

            1| let pname="f5-sdk";version="3.0.21";in(import(<nixpkgs>){}).python3.pkgs.fetchPypi {
             |                                       ^
            2|     inherit pname version;

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.

Generated nix-file does not build on macOS

I am trying to build an older version of vault (1.4.3) using nix-init. However, the nix file created does not build on macOS (13.3.1, aarch64):

vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go:13:5: error: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]

During my research I came across this issue:

This is because LLVM/Clang 11 automatically adds -Werror,-Wundef-prefix=TARGET_OS_ as default compiler arguments and apparently TARGET_OS_MAC isn't defined in this compilation environment.

[...]

I can work around this by adding #cgo CFLAGS: -Wno-undef-prefix or #include <TargetConditionals.h> to the failing import "C" comment. The latter is likely more robust and seemingly indicates that TargetConditions.h isn't being included by another #include in this block.

-- shirou/gopsutil#976

Is there a possibility that nix-init detects and fixes this problem itself? Or do I always have to adapt the files myself?

Abort when building subPackages

I am trying to build an older version of consul (1.6.1). nix-init runs without errors, but the generated nix-file cannot be built:

error: builder for '/nix/store/ahdvdiwv0l1z2ik5cylf9pqvfz8smrdd-consul-1.6.1.drv' failed with exit code 1;
last 10 log lines:
> go: finding module for package github.com/hashicorp/consul/api/watch
> go: finding module for package github.com/hashicorp/consul/api
> go: finding module for package github.com/hashicorp/consul/sdk/freeport
> go: finding module for package github.com/hashicorp/consul/sdk/testutil
> go: finding module for package github.com/hashicorp/consul/sdk/testutil/retry
> sentinel/scope.go:4:2: cannot query module due to -mod=vendor
> agent/agent.go:38:2: cannot query module due to -mod=vendor
> agent/testagent.go:26:2: cannot query module due to -mod=vendor
> agent/testagent.go:27:2: cannot query module due to -mod=vendor
> agent/testagent.go:28:2: cannot query module due to -mod=vendor

What can I do here? (I have no experience with go.)

Document how to use the -n attribute

Hey, first of all thanks a lot for this, this is absolutely amazing.

I am having trouble figuring out how to populate the -n attribute.
I use flakes, so I don't have anything in my nix-channels.
When I first started using the fetchPypi I got

Error: command exited with exit status: 1
stdout:

stderr:
error: attribute 'fetchPypi' missing

       at «string»:1:48:

            1| let pname="pyre-extensions";version="0.0.30";in(import(<nixpkgs>){}).fetchPypi {
             |                                                ^
            2|     inherit pname version;

so I was thinking that my nixpkgs is somehow old on my system.
I use flakes and nixpkgs-unstable, so I'm not sure where the nixpkgs is actually fetched from.
Then I tried to supply different values to that -n argument, and couldn't find anything that worked. I tried
.
<nixpkgs-unstable> (this probably doesn't work because I don't have channels
https://github.com/nixos/nixpkgs

not sure how to make this work properly.

Thanks again for the amazing software, this is a game changer!

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

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.

php.buildComposerProject integration

Recently @drupol 's buildComposerProject PR got merged which added a very capable abstraction for php composer projects.
Composer is the de facto php package manager and I tried packaging a few applications with the builder and they all worked great without extra work just setting the default attributes.

Unable to compile v0.2.4 on Arch

I'm trying to build nix-init from the AUR in a clean chroot. I have made available the nurl dependency. It fails to resolve hyper-rustls. It seems that since the last release, hundreds of PRs have been merged; especially from dependabot. Maybe it is time for a new release?

Happy to provide any more information. Here is a full build log: nix-init.log

==> Starting build()...
    Updating crates.io index
error: failed to get `hyper-rustls` as a dependency of package `reqwest v0.11.18`
    ... which satisfies dependency `reqwest = "^0.11.18"` (locked to 0.11.18) of package `nix-init v0.2.4 (/build/nix-init/src/nix-init-0.2.4)`

Caused by:
  failed to query replaced source registry `crates-io`

Caused by:
  attempting to make an HTTP request, but --frozen was specified
==> ERROR: A failure occurred in build().
    Aborting...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.