dream2nix/modules/drv-parts/nodejs-package-lock/default.nix
2023-08-28 22:20:28 +00:00

53 lines
1.3 KiB
Nix

{
config,
lib,
...
}: let
l = lib // builtins;
cfg = config.nodejs-package-lock;
nodejsUtils = import ../../../lib/internal/nodejsUtils.nix {inherit lib parseSpdxId;};
parseSpdxId = import ../../../lib/internal/parseSpdxId.nix {inherit lib;};
prepareSourceTree = import ../../../lib/internal/prepareSourceTree.nix {inherit lib;};
simpleTranslate = import ../../../lib/internal/simpleTranslate.nix {inherit lib;};
translate = import ./translate.nix {
inherit lib nodejsUtils parseSpdxId simpleTranslate;
};
dreamLock = translate {
projectName = config.name;
projectRelPath = "";
workspaces = [];
workspaceParent = "";
source = cfg.src;
tree = prepareSourceTree {source = cfg.source;};
noDev = ! cfg.withDevDependencies;
nodejs = "unknown";
inherit (cfg) packageJson packageLock;
};
in {
imports = [
./interface.nix
];
# declare external dependencies
deps = {nixpkgs, ...}: {
inherit
(nixpkgs)
fetchgit
fetchurl
nix
runCommandLocal
;
};
nodejs-package-lock = {
inherit dreamLock;
packageJson = l.fromJSON (l.readFile cfg.packageJsonFile);
packageLock =
if cfg.packageLockFile != null
then l.fromJSON (l.readFile cfg.packageLockFile)
else lib.mkDefault {};
};
}