Nix-template v0.2.0 released!

Release a new version of nix-template, major changes:

- Add nixos module template
- Add nixos test template
- Add flake template
- Add -u,--from-url option
  - Github supported

Biggest improvement is the --from-url with github:

$ ./result/bin/nix-template stdenv -u example.nix
Determining latest release for zfs
Determining sha256 for zfs
Generated a stdenv nix expression at /home/jon/projects/nixpkgs/example.nix
[15:56:12] jon@jon-desktop /home/jon/projects/nixpkgs (bump-nix-template)
$ cat /home/jon/projects/nixpkgs/example.nix
{ lib, stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
  pname = "zfs";
  version = "2.1.0";

  src = fetchFromGitHub {
    owner = "openzfs";
    repo = pname;
    rev = "zfs-${version}";
    sha256 = "16l7kva4i3xvzls7n8vi7gpjhxxsgxs37p81fi0n0r2p5d4kimk1";

  buildInputs = [ ];

  meta = with lib; {
    description = "OpenZFS on Linux and FreeBSD";
    homepage = "";
    license = licenses.CHANGE;
    maintainers = with maintainers; [ jonringer ];

Old thread:


Pypi support was added in 0.1.2:

nix-template python --stdout -u
Determining latest release for requests
{ lib, buildPythonPackage, fetchPypi }:

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

  src = fetchPypi {
    inherit pname version;
    sha256 = "b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7";

  propagatedBuildInputs = [ ];

  pythonImportsCheck = [ "requests" ];

  meta = with lib; {
    description = "Python HTTP for Humans";
    homepage = "";
    license = licenses.asl20;
    maintainers = with maintainers; [  ];

Can this tool be used to update version/sha256 to the latest version in an existing file for a python package? Or are there other tools for that?

You’re looking for nix-update. And for common expressions, it can.

I tried nix-update attribute with a working default.nix file containing a python package and it failed ("error: anonymous function at... called without required argument 'lib'", the derivation does have lib as the fist argument), so I assumed that it only works within nixpkgs infrastructure.

most likely you using stdenv.lib somewhere in your nix code. And somehow nix-update is referencing a newer version of nixpkgs.

But I’ve only used it with nixpkgs’ in-tree code. So it might not be the case. cc @Mic92

nix-update expected a package set (an attribute set of nix packages) rather than a single package.
So if you want to update a single package do the following:

# stored as default.nix
{ pkgs ? with import <nixpkgs> {} }:
  mypackage = pkgs.callPackage ./my-package {};

Than you can run nix-update mypackage in the same directory:


Thanks, I have about a hundred python packages which are either not in nixpkgs or are outdated there. Unfortunately they are not up to nixpkgs standards (disabled tests, never tested on many platforms, etc.) so it would not be easy for me to create PRs for them. They are loaded from overlays so I would need to create that file to list all of them. My current solution is to use this quick and dirty bash/curl/jq/sed script Update default.nix for a python package by querying Pypi · GitHub.

Are there plans to make nix-template also fetch the license? It seems trivial as you’d expect, at least GitHub’s API, to expose that information. And if not to read the file and match it against your own database

The --from-url already implements this. It’s just limited to what github is also able to recognize.


Mostly a bug fix release, but 0.2.0 is now released.


- Breaking Changes / Behaviors:
  - Flake template now requires -p,--pname
  - Nix expresions now have input attrs in comma-leading style (one input per line)

- Fixes:
  - --from-url no longer errors with --nixpkgs when a pname is not supplied
  - Fix differences of writing to stdout vs file
  - Update flake template (overlay usage)
  - Failures from already existing file locations occur sooner
    - Particularly irritating with `--from-url`, which would compute release and sha256 info
Hosted by Flying Circus.