Skip to content
This repository was archived by the owner on May 20, 2021. It is now read-only.

Allow passing a source cleaner when building a workspace #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nightkr
Copy link
Contributor

@nightkr nightkr commented Jan 24, 2019

This allows you to pass a sourceCleaner when building a workspace:

mkYarnWorkspace {
  src = ./.;
  sourceCleaner = pkgs.lib.cleanSource;
}

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.

@srghma
Copy link
Contributor

srghma commented Feb 23, 2019

arent this already possible

e.g. here is an example from my project (on this branch #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
        )
      '';
    };
  };
};

@nightkr
Copy link
Contributor Author

nightkr commented Feb 24, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants