mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-08-17 02:10:31 +03:00
nodejs-granular: allow overrides for specific and all nodejsDeps
This commit is contained in:
parent
69ce9f24c0
commit
89feb64c5c
@ -71,18 +71,23 @@
|
||||
|
||||
nodejsDeps =
|
||||
lib.mapAttrs
|
||||
(name: versions:
|
||||
lib.genAttrs
|
||||
versions
|
||||
(version:
|
||||
makeDependencyModule name version))
|
||||
(
|
||||
name: versions:
|
||||
lib.genAttrs
|
||||
versions
|
||||
(version: {...}: {
|
||||
imports = [
|
||||
(commonModule name version)
|
||||
(makeDependencyModule name version)
|
||||
cfg.overrideAll
|
||||
(cfg.overrides.${name} or {})
|
||||
];
|
||||
})
|
||||
)
|
||||
packageVersions;
|
||||
|
||||
# Generates a derivation for a specific package name + version
|
||||
makeDependencyModule = name: version: {config, ...}: {
|
||||
imports = [
|
||||
(commonModule name version)
|
||||
];
|
||||
name = lib.replaceStrings ["@" "/"] ["__at__" "__slash__"] name;
|
||||
inherit version;
|
||||
env = {
|
||||
|
@ -7,40 +7,53 @@
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
t = l.types;
|
||||
cfg = config.nodejs-granular;
|
||||
mkSubmodule = import ../../../lib/internal/mkSubmodule.nix {inherit lib specialArgs;};
|
||||
in {
|
||||
options.nodejs-granular = l.mapAttrs (_: l.mkOption) {
|
||||
buildScript = {
|
||||
type = t.nullOr (t.oneOf [t.str t.path t.package]);
|
||||
description = ''
|
||||
A command or script to execute instead of `npm run build`.
|
||||
Is only executed if `runBuild = true`.
|
||||
'';
|
||||
};
|
||||
installMethod = {
|
||||
type = t.enum [
|
||||
"symlink"
|
||||
"copy"
|
||||
options.nodejs-granular = mkSubmodule {
|
||||
imports = [
|
||||
../overrides
|
||||
];
|
||||
config.overrideType = {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
dream2nix.modules.dream2nix.core
|
||||
];
|
||||
description = ''
|
||||
Strategy to use for populating ./node_modules.
|
||||
Symlinking is quicker, but often introduces compatibility issues with bundlers like webpack and other build tools.
|
||||
Copying is slow, but more reliable;
|
||||
'';
|
||||
};
|
||||
runBuild = {
|
||||
type = t.bool;
|
||||
description = ''
|
||||
Whether to run a package's build script (aka. `npm run build`)
|
||||
'';
|
||||
};
|
||||
deps = {
|
||||
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submoduleWith {
|
||||
modules = [
|
||||
dream2nix.modules.dream2nix.core
|
||||
dream2nix.modules.dream2nix.mkDerivation
|
||||
|
||||
options = l.mapAttrs (_: l.mkOption) {
|
||||
buildScript = {
|
||||
type = t.nullOr (t.oneOf [t.str t.path t.package]);
|
||||
description = ''
|
||||
A command or script to execute instead of `npm run build`.
|
||||
Is only executed if `runBuild = true`.
|
||||
'';
|
||||
};
|
||||
installMethod = {
|
||||
type = t.enum [
|
||||
"symlink"
|
||||
"copy"
|
||||
];
|
||||
inherit specialArgs;
|
||||
}));
|
||||
description = ''
|
||||
Strategy to use for populating ./node_modules.
|
||||
Symlinking is quicker, but often introduces compatibility issues with bundlers like webpack and other build tools.
|
||||
Copying is slow, but more reliable;
|
||||
'';
|
||||
};
|
||||
runBuild = {
|
||||
type = t.bool;
|
||||
description = ''
|
||||
Whether to run a package's build script (aka. `npm run build`)
|
||||
'';
|
||||
};
|
||||
deps = {
|
||||
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submoduleWith {
|
||||
modules = [
|
||||
cfg.overrideType
|
||||
];
|
||||
inherit specialArgs;
|
||||
}));
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user