Help installing 'workstyle', please

Hey. I am wanting to install a waybar utility called workstyle.

There is a package available in nix pkgs, but it is quite old.

The github install instructions are:

cargo install workstyle

but, of course it’s not going to be that simple. :wink:

I added the cargo package and tried the above command, but it complained:

error: linker `cc` not found
  |
  = note: No such file of directory found (os error 2)

Could someone please provide some guidance. Am I going about this the right way?

Check if you can can update by bumping some commit IDs and shas in the nix expression and pr your changes.

Alternatively try an override, though those love to be a bit more complicated for rust packages due to the cargo deps hash updates required in a nested override.

I think I understand what you mean, and I was able to look at the nix expression:

workstyle.nix:

{ lib
, rustPlatform
, fetchFromGitHub
}:

rustPlatform.buildRustPackage rec {
  pname = "workstyle";
  version = "unstable-2021-05-09";

  src = fetchFromGitHub {
    owner = "pierrechevalier83";
    repo = pname;
    rev = "f2023750d802259ab3ee7d7d1762631ec157a0b1";
    sha256 = "04xds691sw4pi2nq8xvdhn0312wwia60gkd8b1bjqy11zrqbivbx";
  };

  cargoSha256 = "0xwv8spr96z4aimjlr15bhwl6i3zqp7jr45d9zr3sbi9d8dbdja2";

  doCheck = false; # No tests

  meta = with lib; {
    description = "Sway workspaces with style";
    homepage = "https://github.com/pierrechevalier83/workstyle";
    license = licenses.mit;
    maintainers = with maintainers; [ FlorianFranzen ];
  };
}

I can see the rev and sha256 parameters, and I would guess those need to be updated. There is also a cargoSha256. I guess that might need updating.

So, I have never done anything like this and have no clue how to start. I scoured the workstyle github, and couldn’t find those parameters.

If I found those three values above, and created an updated workstyle.nix, what would I do with that? Do I save it somewhere on my system and somehow include it in my nixos config?

OK. So I think I found out how to determine rev and sha256 required by fetchFromGitHub:

$ git clone --depth 1 https://github.com/owner/repo path/to/clone
$ git -C path/to/clone rev-parse HEAD
--> rev

$ rm -r path/to/clone/.git
$ nix hash-path path/to/clone
--> sha256

so, in this specific case:

    rev = "8bde72d9a9dd67e0fc7c0545faca53df23ed3753";
    sha256 = "sha256-yhnt7edhgVy/cZ6FpF6AZWPoeMeEKTXP+87no2KeIYU=";

I still don’t know:

  1. how to determine cargoSha256
  2. where to put the resulting workstyle.nix
  3. how to add workstyle.nix to my config

The rev can be a tag or git-sha1, in theory a branch is possible as well, though thats problematic.

The srchash and the cargoHash both can be determined by a technique often refered to as TOFU.

Just leave them empty ("") or set them to lib.fakeHash ("sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=").

Then build and replace them with the one from the error.

So the original question of this thread was to diagnose the error I was getting when trying to install the workstyle package using cargo.

It turns out that I needed to install gcc. That solved that problem,

Then the discussion turned to how to update the workstyle nix package, but that turned out to be beyond my abilities at this point.

Since then, I found an alternative to workstyle called hyprland-autoname-workspaces that seems to be getting more active developoment. I had to install it using cargo, but it would sure be nice to have it as a nix package. I am sure it is easy to do, but beyond me for now.