mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 09:46:04 +03:00
nodejs: move outputs in seperate module files
This commit is contained in:
parent
367e7fcc98
commit
10b523238c
@ -144,14 +144,10 @@
|
||||
# plent :: The lock entry. Includes meta information about the package.
|
||||
parseEntry = lock: path: plent: let
|
||||
info = utils.getInfo path plent;
|
||||
makeNodeModules = ./build-node-modules.mjs;
|
||||
installTrusted = ./install-trusted-modules.mjs;
|
||||
in
|
||||
if path == ""
|
||||
then let
|
||||
rinfo = info // {inherit fileSystem;};
|
||||
name = plent.name or lock.name;
|
||||
|
||||
## ----------- Metainformations ----------
|
||||
fileSystem = graphUtils.getFileSystem pdefs (utils.getSanitizedGraph {
|
||||
inherit plent pdefs;
|
||||
});
|
||||
@ -162,58 +158,51 @@
|
||||
};
|
||||
});
|
||||
|
||||
rinfo = info // {inherit fileSystem;};
|
||||
name = plent.name or lock.name;
|
||||
|
||||
self = config.groups.all.packages.${name}.${plent.version}.evaluated;
|
||||
|
||||
prepared-dev = let
|
||||
module = {
|
||||
imports = [
|
||||
# config.groups.all.packages.${name}.${plent.version}
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
config = {
|
||||
inherit (plent) version;
|
||||
name = name + "-node_modules-dev";
|
||||
env = {
|
||||
FILESYSTEM = builtins.toJSON fileSystem;
|
||||
};
|
||||
|
||||
mkDerivation = {
|
||||
dontUnpack = true;
|
||||
buildInputs = with config.deps; [nodejs];
|
||||
buildPhase = ''
|
||||
node ${makeNodeModules}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
module;
|
||||
|
||||
prepared-prod = let
|
||||
module = {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
config = {
|
||||
inherit (plent) version;
|
||||
name = name + "-node_modules-prod";
|
||||
env = {
|
||||
FILESYSTEM = builtins.toJSON fileSystemProd;
|
||||
};
|
||||
mkDerivation = {
|
||||
dontUnpack = true;
|
||||
buildInputs = with config.deps; [nodejs];
|
||||
buildPhase = ''
|
||||
node ${makeNodeModules}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
module;
|
||||
|
||||
bins = getBins path plent;
|
||||
|
||||
## ----------- Output derviations ----------
|
||||
|
||||
prepared-dev = {
|
||||
imports = [
|
||||
./modules/prepared-dev.nix
|
||||
];
|
||||
_module.args = {
|
||||
packageName = name;
|
||||
inherit plent fileSystem;
|
||||
inherit (config.deps) nodejs;
|
||||
};
|
||||
};
|
||||
|
||||
dist = {
|
||||
imports = [
|
||||
./modules/dist.nix
|
||||
];
|
||||
_module.args = {
|
||||
packageName = name;
|
||||
inherit plent;
|
||||
inherit (cfg) packageLockFile trustedDeps;
|
||||
inherit (self) prepared-dev;
|
||||
inherit (config.deps) nodejs jq;
|
||||
};
|
||||
};
|
||||
|
||||
prepared-prod = {
|
||||
imports = [
|
||||
./modules/prepared-prod.nix
|
||||
];
|
||||
_module.args = {
|
||||
packageName = name;
|
||||
fileSystem = fileSystemProd;
|
||||
inherit plent;
|
||||
inherit (config.deps) nodejs;
|
||||
};
|
||||
};
|
||||
|
||||
installed = config.deps.mkDerivation {
|
||||
inherit (plent) version;
|
||||
name = name + "-installed";
|
||||
@ -234,45 +223,6 @@
|
||||
echo $BINS | jq 'to_entries | map("ln -s $out/lib/node_modules/${name}/\(.value) $out/bin/\(.key); ") | .[]' -r | bash
|
||||
'';
|
||||
};
|
||||
dist = {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
config = {
|
||||
inherit (plent) version;
|
||||
name = name + "-dist";
|
||||
env = {
|
||||
TRUSTED = builtins.toJSON cfg.trustedDeps;
|
||||
};
|
||||
mkDerivation = {
|
||||
# inherit (entry) version;
|
||||
src = builtins.dirOf cfg.packageLockFile;
|
||||
buildInputs = with config.deps; [nodejs jq];
|
||||
configurePhase = ''
|
||||
cp -r ${self.prepared-dev}/node_modules node_modules
|
||||
chmod -R +w node_modules
|
||||
node ${installTrusted}
|
||||
'';
|
||||
buildPhase = ''
|
||||
echo "BUILDING... $name"
|
||||
|
||||
if [ "$(jq -e '.scripts.build' ./package.json)" != "null" ]; then
|
||||
echo "BUILDING... $name"
|
||||
export HOME=.virt
|
||||
npm run build
|
||||
else
|
||||
echo "$(jq -e '.scripts.build' ./package.json)"
|
||||
echo "No build script";
|
||||
fi;
|
||||
'';
|
||||
installPhase = ''
|
||||
# TODO: filter files
|
||||
rm -rf node_modules
|
||||
cp -r . $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
# Root level package
|
||||
name = name;
|
||||
|
54
modules/dream2nix/WIP-nodejs-builder-v3/modules/dist.nix
Normal file
54
modules/dream2nix/WIP-nodejs-builder-v3/modules/dist.nix
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
# default args
|
||||
# lib
|
||||
dream2nix,
|
||||
# _module.args
|
||||
packageName,
|
||||
plent,
|
||||
prepared-dev,
|
||||
packageLockFile,
|
||||
trustedDeps,
|
||||
nodejs,
|
||||
jq,
|
||||
...
|
||||
}: let
|
||||
installTrusted = ../scripts/install-trusted-modules.mjs;
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
|
||||
inherit (plent) version;
|
||||
name = packageName + "-dist";
|
||||
env = {
|
||||
TRUSTED = builtins.toJSON trustedDeps;
|
||||
};
|
||||
mkDerivation = {
|
||||
# inherit (entry) version;
|
||||
src = builtins.dirOf packageLockFile;
|
||||
buildInputs = [nodejs jq];
|
||||
configurePhase = ''
|
||||
cp -r ${prepared-dev}/node_modules node_modules
|
||||
chmod -R +w node_modules
|
||||
node ${installTrusted}
|
||||
'';
|
||||
buildPhase = ''
|
||||
echo "BUILDING... $name"
|
||||
|
||||
if [ "$(jq -e '.scripts.build' ./package.json)" != "null" ]; then
|
||||
echo "BUILDING... $name"
|
||||
export HOME=.virt
|
||||
npm run build
|
||||
else
|
||||
echo "$(jq -e '.scripts.build' ./package.json)"
|
||||
echo "No build script";
|
||||
fi;
|
||||
'';
|
||||
installPhase = ''
|
||||
echo "Removing (dev)node_modules from dist output."
|
||||
rm -rf node_modules
|
||||
# TODO: filter files
|
||||
cp -r . $out
|
||||
'';
|
||||
};
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
dream2nix,
|
||||
# _module.args
|
||||
plent,
|
||||
packageName,
|
||||
fileSystem,
|
||||
nodejs,
|
||||
...
|
||||
}: let
|
||||
makeNodeModules = ../scripts/build-node-modules.mjs;
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
|
||||
inherit (plent) version;
|
||||
name = packageName + "-node_modules-dev";
|
||||
env = {
|
||||
FILESYSTEM = builtins.toJSON fileSystem;
|
||||
};
|
||||
|
||||
mkDerivation = {
|
||||
dontUnpack = true;
|
||||
buildInputs = [nodejs];
|
||||
buildPhase = ''
|
||||
node ${makeNodeModules}
|
||||
'';
|
||||
};
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
dream2nix,
|
||||
# _module.args
|
||||
plent,
|
||||
packageName,
|
||||
fileSystem,
|
||||
nodejs,
|
||||
...
|
||||
}: let
|
||||
makeNodeModules = ../scripts/build-node-modules.mjs;
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
];
|
||||
|
||||
inherit (plent) version;
|
||||
name = packageName + "-node_modules-prod";
|
||||
env = {
|
||||
FILESYSTEM = builtins.toJSON fileSystem;
|
||||
};
|
||||
mkDerivation = {
|
||||
dontUnpack = true;
|
||||
buildInputs = [nodejs];
|
||||
buildPhase = ''
|
||||
node ${makeNodeModules}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user