Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post processors support #4

Closed
gytis-ivaskevicius opened this issue May 30, 2021 · 6 comments
Closed

Post processors support #4

gytis-ivaskevicius opened this issue May 30, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@gytis-ivaskevicius
Copy link

It would be cool to add a few post processors for impure operations and for "nice to have" information. This is just a proper issue in response to #3

Postprocessors that I already have in mind: (Feel free to add other ideas in the comments below)

@berberman berberman added the enhancement New feature or request label May 30, 2021
@berberman
Copy link
Owner

berberman commented May 30, 2021

The post process of cargoSha256 is work in progress, which is considered to be legacy though.

Generating meta attributes doesn't seem to be related with this project. It shouldn't be subject to change imo, and processing it may require to involve various APIs, so I'm not interested in that.

What will "Meson options parsing" be like? Could you elaborate it?

@gytis-ivaskevicius
Copy link
Author

Yeah, for rust there is not much else that can be done. From what I saw in PR above - it might be nice to autogenerate outputHashes - this way you would not need to touch dependencies manually but it already seems great :)

As for meta - The whole idea of mines is to autogenerate as much of derivation definition as possible. This would allow keeping the homepage/description/licensing in sync and overall forget about these kind of copy/paste options.

meson options are basically compile-time feature flags. Here is a massive example https://github.com/systemd/systemd/blob/main/meson_options.txt
Currently, nixpkgs derivations specify these flags as strings, use cases that would be nice to have:

  • Straight up type validation
  • Visibility - when updating the derivation its options would update as well and would provide extra visibility. This would encourage users to tweak their derivations to account for certain changes (Add a feature flag or disable something that is unnecessary or fix up some certain path)
  • In the case of something like systemd one could easily loop over all options and enable only a select few features. This would simplify building of only a select few components of systemd. (For example, tmpfiles are great, it might as well be converted to derivation builder or used partially by home-manager)

@gytis-ivaskevicius
Copy link
Author

Would "post processor" in the shape of an executable that returns some JSON would be fine?
I'd imagine something along the lines of specifying a script path in toml file.

This way any kind of post-processor could be implemented without touching this repo

@berberman
Copy link
Owner

I see, thank you for your detailed explanation. But unfortunately, I think this kind of post-process is totally beyond the scope of this project: please keep in mind that the project name is nvfetcher, which is designed to automatically tracking and updating sources of packages, rahter than to convert arbitrary projects to nix. So I'm going to close this issue.

@berberman
Copy link
Owner

berberman commented May 31, 2021

Now nvfetcher supports extract arbitrary text file from fetched source to generated nix expr, for example:

Given the following configuration,

[fd]
src.github = "sharkdp/fd"
fetch.github = "sharkdp/fd"
extract = ["Cargo.lock"]

nvfetcher produces sources.nix which includes the contents of Cargo.lock

# This file was generated by nvfetcher, please do not modify it manually.
{ fetchgit, fetchurl }:
{
  fd = {
    pname = "fd";
    version = "v8.2.1";
    src = fetchgit {
      url = "https://github.com/sharkdp/fd";
      rev = "v8.2.1";
      fetchSubmodules = false;
      deepClone = false;
      leaveDotGit = false;
      sha256 = "00vlifbri021z8nf7xvbaay8mqvnq58h19va9bqr5lhsqj1f82wq";
    };
    "Cargo.lock" = ''
    # This file is automatically @generated by Cargo.
    # It is not intended for manual editing.
    [[package]]
    name = "aho-corasick"
    version = "0.7.15"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
    dependencies = [
     "memchr",
    ]
    # ...
    '';
  };
}

so you can do any post-process after running nvfetcher.

@blaggacao
Copy link
Contributor

@berberman that's a very elegant offering! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants