Open nightkr opened 5 years ago
arent this already possible
e.g. here is an example from my project (on this branch https://github.com/moretea/yarn2nix/pull/92)
workspace = yarn2nix.mkYarnWorkspace {
src = ./.;
packageOverrides = {
myproject-test-lib = {
src = gitignore.gitignoreSource [./packages/test-lib/.gitignore] ./packages/test-lib;
preInstall = ''
(
cd ./deps/@myproject/test-lib &&
HOME=/homeless-shelter npm run build
)
'';
};
};
};
Yes, @srghma, but that breaks the main advantage of mkYarnWorkspace
: not having to hard-code the contents of the workspace in the Nix code. That is critical (IMO) for usage in teams that are not particularly experienced with Nix. You could work around it like this (untested):
yarn2nix.mkYarnWorkspace rec {
src = ./.;
packageOverrides = lib.mapAttrs (name: pkg: {
src = lib.cleanSource pkg.src;
}) (yarn2nix.mkYarnWorkspace { inherit src; });
}
But that's not exactly making a great case for how simple and easy Nix is.. :P
This allows you to pass a
sourceCleaner
when building a workspace:This is better than the old approach (
src = pkgs.lib.cleanSource ./.;
) because it is applied per package rather than for the whole workspace at once, so unchanged packages aren't rebuilt just because another package in the workspace was changed.The default
sourceCleaner
is just a passthrough, so the behaviour should be unchanged if the user doesn't specify one.