Nix-template at v0.1.0

Nix-template v0.1.0

I wrote a small cli utility to help facilitate the addition of new packages into nixpkgs or into local repositories.

It’s still rough around the edges, but might be useful for some. Currently I’m thinking of making --nixpkgs,-n the default to be true. And add another --local switch to not assume nixpkgs.

PR to add to nixpkgs: nix-template: init at 0.1.0 by jonringer · Pull Request #96713 · NixOS/nixpkgs · GitHub
Repo: GitHub - jonringer/nix-template: Make creating nix expressions easy

Copied from README.md:

# only need to config once per user
$ nix-template config name jonringer
$ nix-template config nixpkgs-root /home/jon/projects/nixpkgs

# add a package
$ nix-template python --nixpkgs -pname requests -f pypi -l asl20
Creating directory: /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/
Generating python expression at /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/default.nix
Please add the following line to the approriate file in top-level:

  requests = callPackage ../development/python-modules/requests { };
# pkgs/development/python-modules/requests/default.nix
{ lib, buildPythonPackage, fetchPypi }:

buildPythonPackage rec {
  pname = "requests";
  version = "0.0.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0000000000000000000000000000000000000000000000000000";
  };

  propagatedBuildInputs = [ ];

  pythonImportsCheck = [ "requests" ];

  meta = with lib; {
    description = "CHANGEME";
    homepage = "https://github.com/CHANGEME/requests/";
    license = licenses.asl20;
    maintainer = with maintainers; [ jonringer ];
  };
}

EDIT: Also wanted to mention @Pamplemousse who made the first PR against my project :slight_smile:

16 Likes

You could use stdenv.lib.fakeSha256, but it is equivalent anyway.

What about something more in line with overlays?

1 Like

I originally did, but I was thinking about using nix-update to auto-retrieve the latest version, and it will look for the previous hash to replace it. And did not work with lib.fakeSha256 as it was just looking for a string replacement.

EDIT:

Also, I plan later to have better fetcher integration and attempt to determine the sha + version before hand. It’s do-able for github and pypi, not sure about the others.

1 Like