feat(nodejs-devshell): expose node_modules drv submodule

This commit is contained in:
DavHau 2023-07-10 17:41:51 +02:00
parent 299c087847
commit e34c4fb33e
2 changed files with 33 additions and 12 deletions

View File

@ -2,29 +2,27 @@
config,
lib,
dream2nix,
packageSets,
...
}: let
l = lib // builtins;
cfg = config.nodejs-devshell;
nodeModulesDrv = dream2nix.lib.evalModules {
inherit packageSets;
modules = [
dream2nix.modules.drv-parts.nodejs-node-modules
nodeModulesDir = "${cfg.nodeModules.public}/lib/node_modules/${config.name}/node_modules";
in {
imports = [
./interface.nix
dream2nix.modules.drv-parts.mkDerivation
dream2nix.modules.drv-parts.nodejs-package-lock
];
nodejs-devshell.nodeModules = {
imports = [
{inherit (config) nodejs-package-lock name version;}
{mkDerivation.src = l.mkForce null;}
];
};
nodeModulesDir = "${nodeModulesDrv}/lib/node_modules/${config.name}/node_modules";
in {
imports = [
dream2nix.modules.drv-parts.mkDerivation
dream2nix.modules.drv-parts.nodejs-package-lock
];
# rsync the node_modules folder
# - tracks node-modules store path via .dream2nix/.node_modules_id
# - omits copying if store path did not change

View File

@ -0,0 +1,23 @@
{
config,
lib,
dream2nix,
packageSets,
...
}: let
l = lib // builtins;
t = l.types;
in {
options.nodejs-devshell = {
nodeModules = l.mkOption {
description = "drv-parts module for the node_modules derivation";
type = t.submoduleWith {
specialArgs = {inherit packageSets dream2nix;};
modules = [
dream2nix.modules.drv-parts.core
dream2nix.modules.drv-parts.nodejs-node-modules
];
};
};
};
}