Packaging rust program with external dependencies

I wanto to build a rust package which depends on lubudev-sys,itself depending on libudev.
Based on the manual I’ve got

with(
  import <nixpkgs> {
    overlays = [ (import ./overlay.nix) ];
  }
);asusctl.override (
  o: {
    crateOverrides = defaultCrateOverrides // {
      libudev-sys = a: {
        buildInputs = [ pkg-config libudev ];
      };
    };
  }
)


final: prev: {
  asusctl = final.callPackage ./pkg.nix {};
}


{ lib, rustPlatform, fetchFromGitLab, pkg-config, libudev, defaultCrateOverrides }:


  rustPlatform.buildRustPackage rec {
    pname = "asusctl";
    version = "3.7.2";

    src = fetchFromGitLab {
      owner = "asus-linux";
      repo = pname;
      rev = version;
      sha256 = "1486hbs1lnnw9yvj7n7l4lpwsmi0darh94hbw2fwwbsahalkbsr2";
    };

    cargoSha256 = "0xd66p3v50g22cqqa56k2g2xakmbg3zfwd9fikh7xwkyj9l0n6ry";


    meta = with lib; {
      description = "A fast line-oriented regex search tool, similar to ag and ack";
      homepage = "https://github.com/BurntSushi/ripgrep";
      license = licenses.unlicense;
      maintainers = [ maintainers.tailhook ];
    };
  }

but nix-build fails with

error: anonymous function at ~/src/nixos/dev/asus/pkg.nix:1:1 called with unexpected argument 'crateOverrides'

       at /nix/store/02kpag0vgfj1qi7bfwkipp74f1svzag0-source/lib/customisation.nix:69:16:

           68|     let
           69|       result = f origArgs;
             |                ^
           70|

What am I doing wrong?

What am I doing wrong?

override will override what’s passed to the nix expression as inputs. E.g. { lib, rustPlatform, fetchFromGitLab, pkg-config, libudev, defaultCrateOverrides }: in your example.

There is no crateOverrides item, so this fails with the message you are shown.

For your package, all that is needed is:

{ lib, rustPlatform, fetchFromGitLab, pkg-config, libudev}:


  rustPlatform.buildRustPackage rec {
    pname = "asusctl";
    version = "3.7.2";

    src = fetchFromGitLab {
      owner = "asus-linux";
      repo = pname;
      rev = version;
      sha256 = "1486hbs1lnnw9yvj7n7l4lpwsmi0darh94hbw2fwwbsahalkbsr2";
    };

    nativeBuildInputs = [ pkg-config ];
    buildInputs = [ libudev ];

    cargoSha256 = "0xd66p3v50g22cqqa56k2g2xakmbg3zfwd9fikh7xwkyj9l0n6ry";

    # doc tests fail
    doCheck = false;

    meta = with lib; {
      description = "A fast line-oriented regex search tool, similar to ag and ack";
      homepage = "https://github.com/BurntSushi/ripgrep";
      license = licenses.unlicense;
      maintainers = [ maintainers.tailhook ];
    };
  }
$ nix-build -E 'with import <nixpkgs> { }; callPackage ./example.nix {}'
/nix/store/flan2gqlc39f845ixc2b5300bq5kq3ch-asusctl-3.7.2