berberman / nvfetcher

Generate nix sources expr for the latest version of packages
https://nvfetcher.torus.icu
MIT License
168 stars 14 forks source link

[feature] customization pname #101

Closed Freed-Wu closed 1 year ago

Freed-Wu commented 1 year ago

Can it allow users customize pname? That is:

[qq-nt-x86_64-linux]
pname = "qq-nt"
src.manual = "3.1.2_12912"
fetch.url = "https://dldir1.qq.com/qqfile/qq/QQNT/80d33f88/linuxqq_3.1.2-12912_amd64.deb"

[qq-nt-aarch64-linux]
pname = "qq-nt"
src.manual = "3.1.2_12912"
fetch.url = "https://dldir1.qq.com/qqfile/qq/QQNT/80d33f88/linuxqq_3.1.2-12912_arm64.deb"

will generate

# This file was generated by nvfetcher, please do not modify it manually.
{ fetchgit, fetchurl, fetchFromGitHub, dockerTools }:
{
  qq-nt-aarch64-linux = {
    pname = "qq-nt";
    version = "3.1.2_12912";
    src = fetchurl {
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/80d33f88/linuxqq_3.1.2-12912_arm64.deb";
      sha256 = "sha256-5n4T0mlfEh9/84wUYiH437R95Qz6/SKDq/AK6baiW24=";
    };
  };
  qq-nt-x86_64-linux = {
    pname = "qq-nt";
    version = "3.1.2_12912";
    src = fetchurl {
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/80d33f88/linuxqq_3.1.2-12912_amd64.deb";
      sha256 = "sha256-F+zIHqYWKiCHYNJZ5hRw0rzltizjuqhVxbpzQGagoZ0=";
    };
  };
}
berberman commented 1 year ago

pname is nothing more than an attribute that reflects the key of the defined package, and it's up to the user to use it or not. If you would like to generate something, you can use passthru = { ... }.

Freed-Wu commented 1 year ago

if user

passthru = { pname = "qq-nt" }

it will

  qq-nt-x86_64-linux = {
    pname = "qq-nt-x86_64-linux";
    version = "3.1.2_12912";
    src = fetchurl {
      url = "https://dldir1.qq.com/qqfile/qq/QQNT/80d33f88/linuxqq_3.1.2-12912_amd64.deb";
      sha256 = "sha256-F+zIHqYWKiCHYNJZ5hRw0rzltizjuqhVxbpzQGagoZ0=";
    };
    pname = "qq-nt";
  };

Why not let passthru override pname?