I maintain an overlay of private packages (internal tools we use at my workplace), and keep it in a git repo so my coworkers can access it as well.
On my non-NixOS (Ubuntu) machine, I configured Nix to use this overlay by creating ~/.config/nixpkgs/overlays/nixpkgs-work.nix
let
url = https://example.com/path/to/archive/master.tar.gz;
in
import (builtins.fetchTarball url)
I’ve done something similar on my NixOS machine, setting nixpkgs.overlays in /etc/nixos/configuration.nix.
When one of the packages in that overlay has been updated on the remote, I’d like to upgrade my local installation of it, but nix-env --upgrade doesn’t work, since Nix isn’t using the latest version of the overlay. If I was using a channel for my private packages, I’d update the channel, but I’m not sure how to perform the equivalent with an overlay.
My workaround has been to uninstall any packages from the overlay, run nix-collect-garbage, then reinstall, which forces Nix to pull an updated version of the overlay. Is there a better way?
On my non-NixOS (Ubuntu) machine, I configured Nix to use this overlay
by creating ~/.config/nixpkgs/overlays/nixpkgs-work.nix
let
url = https://example.com/path/to/archive/master.tar.gz;
in
import (builtins.fetchTarball url)
My workaround has been to uninstall any packages from the overlay, run nix-collect-garbage, then reinstall, which forces Nix to pull an
updated version of the overlay. Is there a better way?
See the builtins.fetchTarball entry in the Nix manual
The fetched tarball is cached for a certain amount of time (1 hour by
default) in ~/.cache/nix/tarballs/. You can change the cache timeout
either on the command line with --option tarball-ttl number of seconds
or in the Nix configuration file with this option: tarball-ttl number
of seconds to cache.
Alternatively you could specify an explicit hash, e.g.
let
url = https://example.com/path/to/archive/master.tar.gz;
in
import (builtins.fetchTarball {
inherit url;
sha256 = "...";
})
Although this hash would need to be bumped after each change (we can
think of it as a “cache buster”).