Install a Nix Package from an Unmerged Pull Request

Sometimes, you need a package that has not yet been merged into the nixpkgs repository.

This guide demonstrates how to achieve that using Nix package overlays.

See the full article for more details.

# flake.nix
inputs = {
  nixpkgs-tabby.url = "github:geodic/nixpkgs/tabby"; # repo where the tabby package is already added
};
# flake.nix
outputs = {
  self,
  nixpkgs,
  ...
} @ inputs: let
  inherit (self) outputs;

  overlay-module = {
    nixpkgs.overlays = [
      (final: prev: {
        tabby = import inputs.nixpkgs-tabby {
          config.allowUnfree = true;
          localSystem = { inherit (prev) system; };
        };
      })
    ];
  };
in {
  # ...
};
# flake.nix - inside the outputs attribute set
in {
  homeConfigurations = {
    username = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages."${system}";
      modules = [ overlay-module ]; # overlay module
    };
  };
}
# home.nix
home.packages = [ pkgs.tabby.tabby-terminal ];

That’s usually how you don’t want to do it, as you’re creating an entirely new instance of nixpkgs for just one package. It’d be better to callPackage the expression that you need, even if that is a little clunkier up-front.

2 Likes

An MVP would be nice.

3 Likes

You can put something like this in your overlays:

        tabby = final.callPackage "${
          prev.fetchFromGitHub {
            owner = "geodic";
            repo = "nixpkgs";
            rev = "tabby";
            sha256 = "sha256-L5o0xligytgvvUtj48q51YCaxzTkpM16liokYsbneAI=";
          }
        }/pkgs/by-name/ta/tabby-terminal/package.nix" { };

And it will try to build that package. It seems it wants electron_32 though which maybe no longer exists in nixpkgs, but maybe it did in the copy of nixpkgs you had added as an input, so will still need some tweak to get around that. But I suspect this approach is roughly what waffle8946 was suggesting.

3 Likes