How to install version of a package that is newer then in nixpkgs

Hello,

I would like to know the general approach on how to install a newer version of a package than the version in nixpkgs. The Nix(os) documentation seems to suggest overlays for that but I couldn’t get it to work.

Specifically I would like to use latest version of tilt (https://tilt.dev/). I found the version in nixpkgs to be 0.22.15 (https://github.com/NixOS/nixpkgs/blob/2c7ebb55243348df8646fcbb6a85eccef886fd7e/pkgs/applications/networking/cluster/tilt/default.nix). So I added an overlay for it in my configuration.nix like so:

 nixpkgs.overlays = [ (self: super: {
        tilt = super.tilt.overrideAttrs (old: {
            version = "0.23.1";
            src = super.fetchFromGitHub {
              owner = "tilt-dev";
              repo = "tilt";
              rev = "v0.23.1";
              #    sha256 = lib.fakeSha256;
              sha256 = "sha256:1wvq6slgcqmjz379wkxzk13m02g423hnzlwvv5zz1wg1mzfy1522";
            };
          });
    }) ];

It seems to build without errors but when I try to run

tilt version

all I get is the suggestion to install tilt with nix-env -i tilt.

What am I missing?

You have upgraded tilt in the overlay but how did you install tilt?

My approach is to have a local checkout of the git repository and build on top of that. This makes it easy for me to open PRs each time I update a package I need.

1 Like

Hi Damien,

at first in addition to the overlay I had tilt added in environment.systemPackages but the overlay didn’t seem to have any effect. Running

tilt version

would just give: 0.22.15. So I don’t know how to install it in case you have an overlay.

I also experimented with a local git clone of nixpkgs and adding my changes to tilt there but I don’t know how to install from that local repository either.

Thanks for your help

It won’t work from nix-shell -p, if you test it like this. You need to add it in config, otherwise overlays won’t be used.

nixpkgs.overlays = [ (self: super: {
        tilt = super.tilt.overrideAttrs (old: {
            version = "0.23.1";
            src = [ ./tilt-0.23.1.tar.gz ];# or src = [ ./tilt-0.23.1 ];
          });
    }) ];

If you have a local tarball file or directory,you can just add the path of the newer tilt package or directory into the src attribute. And the name or version attribute also needs to be modified
.

2 Likes

Hi @cab, thanks but what do you mean by “add it in config”?

@hrx okay got it. Here I prefer to fetch it from github and keep the overlay close to the code in nixpkgs to create a PR once I can confirm tilt is working correctly.

In configuration.nix:

environment.defaultPackages = [
  pkgs.tilt
];

If you already have environment.defaultPackages option set somewhere, just add pkgs.tilt to the list.

1 Like

Fantastic it works now, thanks!!

1 Like

What I do is have a directory (called nix-system) in which I clone nixpkgs and other nix repositories I need (i.e., home-manager, emacs-overlay and nixos-hardware). Then, I make my NIX_PATH point to this directory:

$ echo $NIX_PATH
/home/cassou/nix-system

When asked for <XXX>, nix will take the XXX directory of /home/cassou/nix-system. As a result, <nixpkgs> resolves to /home/cassou/nix-system/nixpkgs which is exactly where the git clone of the nixpkgs project is.

1 Like

Thanks for the hint. I tried it and also that approach now works for me with

export NIX_PATH=~/nix-system
nix-env -f '<nixpkgs>' -i tilt

where nixpkgs repo is cloned to ~/nix-system/nixpkgs. I had to use the -f option otherwise it still installed the version of tilt from upstream. I am not completely sure what the -f option does but it seems to stand for path and will search for a folder nixpkgs in the NIX_PATH.