From e34c4fb33e327b9484f8150f5843709888f90b06 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 10 Jul 2023 17:41:51 +0200 Subject: [PATCH] feat(nodejs-devshell): expose node_modules drv submodule --- .../drv-parts/nodejs-devshell/default.nix | 22 ++++++++---------- .../drv-parts/nodejs-devshell/interface.nix | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 v1/nix/modules/drv-parts/nodejs-devshell/interface.nix diff --git a/v1/nix/modules/drv-parts/nodejs-devshell/default.nix b/v1/nix/modules/drv-parts/nodejs-devshell/default.nix index c8b93baa..54b568c3 100644 --- a/v1/nix/modules/drv-parts/nodejs-devshell/default.nix +++ b/v1/nix/modules/drv-parts/nodejs-devshell/default.nix @@ -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 diff --git a/v1/nix/modules/drv-parts/nodejs-devshell/interface.nix b/v1/nix/modules/drv-parts/nodejs-devshell/interface.nix new file mode 100644 index 00000000..99093187 --- /dev/null +++ b/v1/nix/modules/drv-parts/nodejs-devshell/interface.nix @@ -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 + ]; + }; + }; + }; +}