1
0

nixpkgs-instances.nix 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. { inputs, ... }:
  2. {
  3. # The _module.args definitions are passed on to modules as arguments. E.g.
  4. # the module `{ pkgs ... }: { /* config */ }` implicitly uses
  5. # `_module.args.pkgs` (defined in this case by flake-parts).
  6. perSystem =
  7. { system, ... }:
  8. {
  9. _module.args = {
  10. # Note: bringing up https://zimbatm.com/notes/1000-instances-of-nixpkgs
  11. # again, the below creates several nixpkgs instances which the
  12. # flake-centric CLI will be forced to evaluate e.g. on `nix flake show`.
  13. #
  14. # This is currently "slow" and "expensive", on a certain scale.
  15. # This also isn't "right" in that this hinders dependency injection at
  16. # the level of flake inputs. This might get removed in the foreseeable
  17. # future.
  18. #
  19. # Note that you can use these expressions without Nix
  20. # (`pkgs.callPackage ./devops/nix/scope.nix { }` is the entry point).
  21. pkgsCuda = import inputs.nixpkgs {
  22. inherit system;
  23. # Ensure dependencies use CUDA consistently (e.g. that openmpi, ucc,
  24. # and ucx are built with CUDA support)
  25. config.cudaSupport = true;
  26. config.allowUnfreePredicate =
  27. p:
  28. builtins.all (
  29. license:
  30. license.free
  31. || builtins.elem license.shortName [
  32. "CUDA EULA"
  33. "cuDNN EULA"
  34. ]
  35. ) (p.meta.licenses or [ p.meta.license ]);
  36. };
  37. # Ensure dependencies use ROCm consistently
  38. pkgsRocm = import inputs.nixpkgs {
  39. inherit system;
  40. config.rocmSupport = true;
  41. };
  42. };
  43. };
  44. }