Is it possible to use a branch of a github project with home-manager?

I’m trying to use the hold-delay branch of libinput-gestures to test a feature that I requested, and I tried adding the following to install this branch:

flake.nix

inputs = {  
    libinput-gestures.url = "github:bulletmark/libinput-gestures/tree/hold-delay";  
};  

home.nix

{ inputs, lib, config, pkgs, ... }: {  
    imports = [  
    inputs.libinput-gestures.default  
];  
  
home.packages = with pkgs; [  
libinput-gestures.${system}.default  
];  

But I get the following error:

error:
       … while updating the lock file of flake 'git+file:///home/guttermonk/.dotfiles?ref=refs/heads/master&rev=2fa838554e068511edc0cca157cac14814aca450'

       … while updating the flake input 'libinput-gestures'

       … while fetching the input 'github:bulletmark/libinput-gestures/tree/hold-delay'

       error: unable to download 'https://api.github.com/repos/bulletmark/libinput-gestures/commits/tree/hold-delay': HTTP error 422

       response body:

       {
         "message": "No commit found for SHA: tree/hold-delay",
         "documentation_url": "https://docs.github.com/rest/commits/commits#get-a-commit",
         "status": "422"
       }

What am I doing wrong?

The branch is called hold-delay, not tree/hold-delay.
https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-flake#types

Thanks for the suggestion. That made some progress, but when I update nix and home manager I get:

error:
       … while updating the lock file of flake 'git+file:///home/guttermonk/.dotfiles?ref=refs/heads/master&rev=817dabb74544e64ba4ee65d458454bae35f5ed82'

       … while updating the flake input 'libinput-gestures'

       error: getting status of '/nix/store/0mdjd7f5ca8y9f9x9yqrczkasjdjfpq8-source/flake.nix': No such file or directory

Looking at the repo, it’s not a flake, so you wouldn’t use it as a flake input.
This also seems to have nothing to do with HM, probably you need an overlay in your NixOS config to point at the new src.
See the nixpkgs manual on how to use overrideAttrs and write overlays.

2 Likes

It looks like the NixOS source for libinput-gestures uses a wrapper over the original program. So is trying to use the hold-delay branch from the original program in Nix even possible? After some searching and reading the Nix pill section on Overrides, I’m not finding any examples where someone used a branch of the original program in Nix.

You can target a branch by putting it into the src’s rev attribute, which you can also do with tags or commit hash as is usually the case in nixpkgs.

  nixpkgs.overlays = [
    (final: prev: {
      libinput-gestures = prev.libinput-gestures.overrideAttrs {
        src = final.fetchFromGitHub {
          owner = "bulletmark";
          repo = "libinput-gestures";
          rev = "hold-delay";
          sha256 = "sha256-h2Uv0mOjVblCUqD+nJ7VFkf2ccRrAacoKjmYaV8FlgI=";
        };
      };
    })
  ];

Ideally a specific commit would be used here, but otherwise it’s ok.

@eljamm you’re a hero. This worked perfectly. Thank you!

1 Like