Casual Nixpkgs contributions

Referring to the discussion here How many people are paid to work on Nix/Nixpkgs? I open this topic to be able do to casual nixpkgs contributions. The idea is to lower the threshold to contribute to Nixpkgs for people like me who are not a dev, do not have a Github account, do not check out nixpkgs via git locally, are merely users, etc. etc etc but still want to share something so now and then.

Here is my first casual contribution. A sponsored PR (=someone who wants to shape it into an actual PR) would be appreciated.

{ stdenv, fetchFromGitHub, python3 }:

stdenv.mkDerivation rec {
  pname = "ff2mpv-host";
  version = "3.6";

  src = fetchFromGitHub {
    owner = "woodruffw";
    repo = "ff2mpv";
    rev = "v${version}";
    sha256 = "0dpqd4vis4c0pvdfpkgflc6ccdm98jils3jp0ncz1nvam4swsr1x";
  };

  buildInputs = [ python3 ];

  installPhase = ''
     runHook preInstall
     install -D ff2mpv.py $out/share/ff2mpv.py
     substitute ff2mpv.json $out/share/ff2mpv.json \
       --replace /home/william/scripts/ff2mpv $out/share/ff2mpv.py

     nativeMessagingPaths=(
       /lib/mozilla/native-messaging-hosts
    #   /etc/opt/chrome/native-messaging-hosts
    #   /etc/chromium/native-messaging-hosts
    #   /etc/vivaldi/native-messaging-hosts
     )

     for manifestDir in "''${nativeMessagingPaths[@]}"; do
       install -d $out$manifestDir
       ln -s $out/share/ff2mpv.json $out$manifestDir/
     done

    runHook postInstall
  '';

  meta = with stdenv.lib; {
    description = "Host app for the WebExtension ff2mpv";
    homepage = "https://github.com/woodruffw/ff2mpv";
    license = licenses.mit;
  };
}

2 Likes

You don’t have to set the maintainers field, considering the circumstances. Though I wonder: what you mean by “sponsor”?

Do not override phases, without runHook before and after it. Read: https://github.com/jtojnar/nixpkgs-hammering/blob/193d2108495b6c53c591f2f99de981153f218003/explanations/explicit-phases.md

Usually web extension’s json files are installed in several locations, Consider for instance:

You can use only the Firefox path if you wish.

Use pname = "ff2mpv and the name attribute will be derived automatically.

Does the executable eventually gets wrapped appropriately? For this simple derivation, you can use dontBuild = true and patchShebangs.

Though I wonder: what you mean by “sponsor”?

Presumably https://en.wikipedia.org/wiki/Sponsor_(legislative)

Thanks for the feedback, I will process it and update the original message.
With sponsor I mean something similar as ‘non maintainer upload’ in Debian world. Someone who shapes it into a merge-able PR on behalf of the casual contributor (and can take credit if that matters)

Updated:

  • changed name+$version -> pname
  • runHooks added
  • kept buildInputs python3 otherwise patchshebangs doesn’t do anything
  • kept it Firefox only, because the author only markets the extension for Firefox, and I did not test it in other browsers
  • made it look like the passff-host derivation
1 Like

thanks both of you @kvtb and @doronbehar but wow, this looks awfully close to a Pull Request against nixpkgs minus the actual diff and all the goodies github brings.

Especially with hacktoberfest currently going on, these kind of additions make good first contributions.
@kvtb you should really think of filing a PR for this!

Apart from that, you can always start your own Nix User Repository ( NUR ) if you just want to give access to the derivations you’ve wrote. there is even a search for this at nur.nix-community.org which contains contributions of packages which may not fulfill the quality standards of nixpkgs.

2 Likes

Looking closer, the license for this software is not the MIT license, but the MIT license with additional restrictions (https://github.com/woodruffw/ff2mpv/blob/ef1ad015871fc2b876e8c89b7a31ccb62c583cd6/LICENSE).

I know I offered to sponsor (in the sense of: convert to a PR on your behalf) your contributions earlier, but I’m not sure I find this particular one suitable, so I think I’ll pass in this particular case. Sorry!

1 Like

sadness, the license was updated after I wrote the first version of the derivation a few months a go.

Anyway, here’s another one, for SeaweedFS a distributed file system
Ideally this also comes with NixOS service definitions and options and such but I’ll leave that to those who know what they are doing.

So for nixpkgs, if someone sees the added value of SeaweedFS as new package:

 { lib, fetchFromGitHub, buildGoModule }:

 buildGoModule rec {
   pname = "seaweedfs";
   version = "2.07";

   src = fetchFromGitHub {
     owner = "chrislusf";
     repo = "seaweedfs";
     rev = "${version}";
     sha256 = "0yrfpj4ph9f321vqfn1zadv44pqa3ivjq9rx6gsz9hlv50gfaqn1";
   };

   vendorSha256 = "1ysqagi4y25bi84h5fhkdimnsigy43klf6hrcqn7q75382fb4bzn";

   subPackages = [ "weed" ];

   meta = with lib; {
     description = "Simple and highly scalable distributed file system";
     homepage = "https://github.com/chrislusf/seaweedfs";
     license = licenses.asl20;
     #   maintainers = with maintainers; [ sponsor-name-here ];
     platforms = platforms.linux ++ platforms.darwin;
   };
 }

Looks interesting - though if you see the added value that is good enough for me :wink: . Converted to PR at:

2 Likes

I notice it has been merged today, thanks for making this sponsor-based PR approach work, @raboof !

1 Like