Installing wezterm from git

Im trying to install wezterm but there are a few feature i need which haven’t made it too release yet, I’ve been trying to figure out a way to install the package from git and this is the closest i’ve come so far

{ pkgs, ... }:
let
  version = "d6809533215e273ca23e52614c886929ad702715";
in
{
  nixpkgs.overlays = [ (final: prev: {
    wezterm = prev.wezterm.overrideAttrs (old: {
      inherit version;
      src = prev.fetchFromGitHub {
        owner = "wez";
        repo = "wezterm";
        rev = version;
        fetchSubmodules = true;
        hash = "sha256-ZnmBKBiaqKGKKrItTrPf/LGJvtu7BBvu1+QAk5PBi6g=";
      };

      cargoHash = "";
    });
  }) ];
  home.packages = [ pkgs.wezterm ];
}

But it tells me that cargoHash is out of date. it suggests setting it to an empty string and doing exactly the same as you do with the hash for fetchFromGitHub, but i set it to an empty string and it gives me the same error and no hash

any ideas as to what im missing for this final peice of the puzzle? that is, if i haven’t done it entirely wrong and should be doing a different method completely

2 Likes

There are some options listed here. I think the easiest is to use the lockfile option.

how do you suggest getting the lock file to do that? should I build the package manually first myself?

I don’t know if this is the best way but maybe you can fetch the lockfile from the github repo
https://raw.githubusercontent.com/wez/wezterm/d6809533215e273ca23e52614c886929ad702715/Cargo.lock

good point, I completely missed that, my bad

not at my nix system at the moment but I’ll give it a try when I have the chance

1 Like

this doesn’t seem to work, if I try to set cargoLock.lockfile to ./Cargo.toml (as it is set in the original nixpkgs derivation), it gives me an error because it cannot coerce a set into a string. I don’t understand why it expects cargoLock to be a string, and if i set it to an empty string similarly to what the original error message suggested, I still get the same first error message

You could try getting a hash using nurl

I get this when I run it on the latest commit:

fetchFromGitHub {
  owner = "wez";
  repo = "wezterm";
  rev = "f0e3eecba6faec0aa963a6f0067577afc99e11db";
  hash = "sha256-7+i+6zPEoQQ88x0g3ncf0UciRutYJtGKVLDxIDCg5G8=";
}

I’m trying to do this as well. I tried following this discussion: Is it possible to override cargoSha256 in buildRustPackage? - #5 by Sandro and came up with this:

{ pkgs, ...}:
let
  version = "6a58a5ce94f186884ec70a60b5afbd728521b1c5";
in
{
  nixpkgs.overlays = [ (final: prev: {
    wezterm = prev.wezterm.overrideAttrs (old: rec {
      inherit version;
      src = prev.fetchFromGitHub {
        owner = "wez";
        repo = "wezterm";
        rev = version;
        fetchSubmodules = true;
        hash = "sha256-QXZjGIw5LvK+frigdCYGVOjLHM3Fnnqqi5FEySaKExs=";
      };
      cargoDeps = old.cargoDeps.overrideAttrs (prev.lib.const {
        name = "wezterm-vendor.tar.gz";
        inherit src;
        outputHash = "sha256-b5OB42PDpw1uZ3agO/TOrWuRM2eCqC8/xWOAkivxTRg=";
        outputHashMode = "recursive";
      });
    });
  }) ];
  home.packages = [ pkgs.wezterm ];
} 

But it gets stuck here:

warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/in18x3ycwhz8lwn3hyg616gizv45i79x-wezterm-6a58a5ce94f186884ec70a60b5afbd728521b1c5.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/i4ys5r1l889szbpfkz2h5zhflhbpkv1r-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/z1hwbawwl579xalk0wck66pk7mginpxa-wezterm-vendor.tar.gz
tar: /nix/store/z1hwbawwl579xalk0wck66pk7mginpxa-wezterm-vendor.tar.gz: Cannot open: No such file or direc>
tar: Error is not recoverable: exiting now
do not know how to unpack source archive /nix/store/z1hwbawwl579xalk0wck66pk7mginpxa-wezterm-vendor.tar.gz

The referenced file /nix/store/z1hwbawwl579xalk0wck66pk7mginpxa-wezterm-vendor.tar.gz really does not exist.

So, did anyone figure out a way to do this? I followed all of the links posted here and got nowhere with it :frowning:

This is what I do:

It seems to work just fine for me. Hope this helps.

5 Likes

Worked perfectly! Thanks <3

I came across this issue as well and ended up with this solution before seeing this thread

The issue is overrideAttrrs overrides the attribute set passed to stdenv.mkDerivation, so you don’t have direct access to buildRustPackage from my understanding

But you can just call override instead. This has the advantage of also being able to override the rustc/cargo versions for when the latest version in nixpkgs isn’t up to date

My own flake is a bit complex because of my use of std/hive. So my snippet below is outside of the overlay context, and nixpkgs is an unaltered nixpkgs whereas pkgs is nixpkgs + overlays

And you do still need to have a local copy of the Cargo.toml like in the nixpkgs drv

et voila:

  wezterm = nixpkgs.wezterm.override (
    let
      rustPlatform = nixpkgs.makeRustPlatform {
        rustc = pkgs.rust-bin.stable.latest.minimal;
        cargo = pkgs.rust-bin.stable.latest.minimal;
      };
    in
    old: {
      rustPlatform = old.rustPlatform // {
        buildRustPackage =
          args:
          rustPlatform.buildRustPackage (
            args
            // rec {
              pname = "wezterm";
              version = "552bb1d66b6d0102961974c0da22dc7c69b0cd30";
              src = nixpkgs.fetchFromGitHub {
                owner = "wez";
                repo = pname;
                rev = version;
                fetchSubmodules = true;
                hash = "sha256-dr/f/zEqgzJ26s2KkiX6/68IU986jAYpeerRMSqejjM=";
              };

              cargoLock = {
                lockFile = ./wezterm/Cargo.lock;
                outputHashes = {
                  "sqlite-cache-0.1.3" = "sha256-sBAC8MsQZgH+dcWpoxzq9iw5078vwzCijgyQnMOWIkk=";
                  "xcb-imdkit-0.3.0" = "sha256-77KaJO+QJWy3tJ9AF1TXKaQHpoVOfGIRqteyqpQaSWo=";
                };
              };
            }
          );
      };
    }
  );

references:

1 Like

Hey! I have a custom tool chain for Rust, every time I try to run the build I get an error:

error: builder for '/nix/store/zi39rz1hgx0g5nqdllcgk18i5wwd74p3-wezterm-deps-20240624-135522-552bb1d6.drv' failed with exit code 101;
       last 10 log lines:
       > cargo build $cargo_release -j "$NIX_BUILD_CORES" --message-format=$cargo_message_format --features distro-defaults
       > warning: both `/build/dummy-src/.cargo-home/config` and `/build/dummy-src/.cargo-home/config.toml` exist. Using `/build/dummy-src/.cargo-home/config`
       > error: rustc 1.78.0 is not supported by the following packages:
       >   bitstream-io@2.4.2 requires rustc 1.79
       >   ravif@0.11.7 requires rustc 1.79
       > Either upgrade rustc or select compatible dependency versions with
       > `cargo update <name>@<current-ver> --precise <compatible-ver>`
       > where `<compatible-ver>` is the latest version supporting rustc 1.78.0
       >
       > [naersk] cargo returned with exit code 101, exiting

Are you familiar on how I can build with Naersk using a custom tool chain?

rustc --version
rustc 1.81.0-nightly

cargo --version
cargo 1.81.0-nightly