How to install github released binary?

Here is how a pure binary version would look like:

$ nix-prefetch-url https://github.com/kopeio/kexpand/releases/download/0.2/kexpand-linux-amd64
path is '/nix/store/znn9l9dzyiz1xd99p6a0hz0jir04phx5-kexpand-linux-amd64'
0ldh303r5063kd5y73hhkbd9v11c98aki8wjizmchzx2blwlipy7

kexpand.nix:

{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
  name = "kexpand";
  src = pkgs.fetchurl {
    url = "https://github.com/kopeio/kexpand/releases/download/0.2/kexpand-linux-amd64";
    sha256 = "0ldh303r5063kd5y73hhkbd9v11c98aki8wjizmchzx2blwlipy7";
  };
  phases = ["installPhase" "patchPhase"];
  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/kexpand
    chmod +x $out/bin/kexpand
  '';
}

Now you can call nix-env -f . -i to install it. Or use pkgs.callPackage ./kexpand.nix {}; in your shell.nix to load it.

There is currently a bug that not all the libraries are reachable so it will have to be fixed further.

7 Likes