Drowse is a thin wrapper around dynamic derivations to make it easier to use. It allows you to enjoy the fine-grained caching of lang2nix tools without needing IFD or keeping around generated files.
Here is what using drowse with crate2nix looks like
drowse.crate2nix {
pname = "hello";
version = "0.1.0";
src = ./.; # filter with lib.fileset to reduce rebuilds
# src = fetchFromGitHub <...> # this can also be fetched
# optional: enable the fancy feature
args.rootFeatures = [ "fancy" ];
# optional: another way to enable the fancy feature
select = ''
project: project.rootCrate.build.override { features = [ "fancy" ]; }
'';
};
Would love to see this in nixpkgs once dynamic-derivations is stabilized! All the API are made with extendMkDerivation, which should make drowse a good testing ground for an ergonomic API suitable for nixpkgs.
One current issue is that drowse depends on recursive-nix, which might take a very long time if it ever gets stabilized. I suggest keeping an eye on A very restricted recursive nix socket in the sandbox · Issue #8602 · NixOS/nix · GitHub, which is an alternative to recursive-nix that can hopefully be stabilized with dynamic-derivations in the near(er) future.
args is simply copied into the builder as plain text (or json if it’s structured) and gets nix-instantiateed only at build time. The NIX_PATH is built with pkgs.path, which should be basically free at evaluation time.