Pick up changes in repo - Nix

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Magnus Therning

At work we have a few repos on GitHub with utility scripts. I made a naive attempt at packaging them by sticking a default.nix in the root. Something like

{pkgs ? import <nixpkgs> {}}:

with pkgs;

{
  work-helpers = stdenv.mkDerivation {
    name = "work-helpers";
    src = lib.cleanSource ./.;
    buildPhase = ''
      true
    '';
    installPhase = ''
      install -D -m 755 ./tool-1 "$out/bin/tool-1"
      install -D -m 755 ./tool-2 "$out/bin/tool-2"
      install -D -m 755 ./tool-3 "$out/bin/tool-3"
    '';
  };
}

Then I added the repo as a channel using nix-channel. That works as expected.

Then I realised that this doesn't pick up changes pushed to the repo, nix-channel --update works of course, but a subsequent nix-env --upgrade won't build a new version incorporating the pushed changes to the scripts.

If I want to remedy this, i.e. to make nix-env --upgrade pick up that the scripts have been modified and build a new package, what are my options?

Torsten Schmits

I think you will have to put a version in your derivation. maybe by reading .git/refs/heads/master

Torsten Schmits

oops no, that won't register correctly, since the versions are compared

Torsten Schmits

also there is the --always flag for nix-env --upgrade

Magnus Therning

Yes, it works well enough to use --always :smile: