mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-30 10:07:33 +03:00
Merge pull request #50 from DavHau/dev
nodejs builder/translator and CLI improvements
This commit is contained in:
commit
e909fb1cb3
@ -448,4 +448,7 @@ class AddCommand(Command):
|
|||||||
defaultNix.write(template)
|
defaultNix.write(template)
|
||||||
print(f"Created {output}/default.nix")
|
print(f"Created {output}/default.nix")
|
||||||
|
|
||||||
print(f"Created {output}/dream-lock.json")
|
print(f"Created {output}/dream-lock.json")
|
||||||
|
|
||||||
|
if config['isRepo']:
|
||||||
|
sp.run(f"git add -N {output}".split())
|
@ -25,8 +25,10 @@ def find_repo_root():
|
|||||||
|
|
||||||
with open(os.environ.get("dream2nixConfig")) as f:
|
with open(os.environ.get("dream2nixConfig")) as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
config["isRepo"] = False
|
||||||
if config['repoName'] and config ['packagesDir']:
|
if config['repoName'] and config ['packagesDir']:
|
||||||
config['packagesDir'] = f"{find_repo_root()}/{config['packagesDir']}"
|
config['packagesDir'] = f"{find_repo_root()}/{config['packagesDir']}"
|
||||||
|
config["isRepo"] = True
|
||||||
|
|
||||||
def checkLockJSON(lock):
|
def checkLockJSON(lock):
|
||||||
lock_schema_raw=open(dream2nix_src+"/specifications/dream-lock-schema.json").read()
|
lock_schema_raw=open(dream2nix_src+"/specifications/dream-lock-schema.json").read()
|
||||||
|
@ -48,11 +48,6 @@ let
|
|||||||
|
|
||||||
b = builtins;
|
b = builtins;
|
||||||
|
|
||||||
# tells if a dependency introduces a cycle
|
|
||||||
# -> needs to be built in a combined derivation
|
|
||||||
isCyclic = name: version:
|
|
||||||
(getCyclicDependencies name version) != [];
|
|
||||||
|
|
||||||
nodejsVersion = subsystemAttrs.nodejsVersion;
|
nodejsVersion = subsystemAttrs.nodejsVersion;
|
||||||
|
|
||||||
nodejs =
|
nodejs =
|
||||||
@ -72,23 +67,8 @@ let
|
|||||||
lib.genAttrs
|
lib.genAttrs
|
||||||
versions
|
versions
|
||||||
(version:
|
(version:
|
||||||
if isCyclic name version
|
|
||||||
|| b.elem name standalonePackageNames then
|
|
||||||
makeCombinedPackage name version
|
|
||||||
else
|
|
||||||
makePackage name version))
|
makePackage name version))
|
||||||
packageVersions;
|
packageVersions;
|
||||||
|
|
||||||
makeCombinedPackage = name: version:
|
|
||||||
let
|
|
||||||
built =
|
|
||||||
buildPackageWithOtherBuilder {
|
|
||||||
inherit name version;
|
|
||||||
builder = builders.nodejs.node2nix;
|
|
||||||
inject = {};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
built.defaultPackage;
|
|
||||||
|
|
||||||
# Generates a derivation for a specific package name + version
|
# Generates a derivation for a specific package name + version
|
||||||
makePackage = name: version:
|
makePackage = name: version:
|
||||||
|
@ -49,6 +49,12 @@ if 'dependencies' in package_json:
|
|||||||
if 'bundledDependencies' in package_json\
|
if 'bundledDependencies' in package_json\
|
||||||
and pname in package_json['bundledDependencies']:
|
and pname in package_json['bundledDependencies']:
|
||||||
continue
|
continue
|
||||||
|
if pname not in available_deps:
|
||||||
|
print(
|
||||||
|
f"WARNING: Dependency {pname} wanted but not available. Ignoring.",
|
||||||
|
file=sys.stderr
|
||||||
|
)
|
||||||
|
continue
|
||||||
if available_deps[pname] != package_json['dependencies'][pname]:
|
if available_deps[pname] != package_json['dependencies'][pname]:
|
||||||
package_json['dependencies'][pname] = available_deps[pname]
|
package_json['dependencies'][pname] = available_deps[pname]
|
||||||
changed = True
|
changed = True
|
||||||
@ -59,7 +65,7 @@ if 'dependencies' in package_json:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# create symlinks for executables (bin entries from package.json)
|
# create symlinks for executables (bin entries from package.json)
|
||||||
if 'bin' in package_json:
|
if 'bin' in package_json and package_json['bin']:
|
||||||
bin = package_json['bin']
|
bin = package_json['bin']
|
||||||
|
|
||||||
if isinstance(bin, str):
|
if isinstance(bin, str):
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
inputDirectories,
|
inputDirectories,
|
||||||
inputFiles,
|
inputFiles,
|
||||||
|
|
||||||
|
name,
|
||||||
noDev,
|
noDev,
|
||||||
nodejs,
|
nodejs,
|
||||||
...
|
...
|
||||||
@ -73,8 +74,17 @@
|
|||||||
utils.simpleTranslate translatorName {
|
utils.simpleTranslate translatorName {
|
||||||
# values
|
# values
|
||||||
inputData = packageLockWithPinnedVersions;
|
inputData = packageLockWithPinnedVersions;
|
||||||
mainPackageName = parsed.name;
|
|
||||||
mainPackageVersion = parsed.version;
|
mainPackageName =
|
||||||
|
parsed.name or
|
||||||
|
(if name != "{automatic}" then name else
|
||||||
|
throw (
|
||||||
|
"Could not identify package name. "
|
||||||
|
+ "Please specify extra argument 'name'"
|
||||||
|
));
|
||||||
|
|
||||||
|
mainPackageVersion = parsed.version or "unknown";
|
||||||
|
|
||||||
mainPackageDependencies =
|
mainPackageDependencies =
|
||||||
lib.mapAttrsToList
|
lib.mapAttrsToList
|
||||||
(pname: pdata:
|
(pname: pdata:
|
||||||
@ -82,7 +92,9 @@
|
|||||||
(lib.filterAttrs
|
(lib.filterAttrs
|
||||||
(pname: pdata: ! (pdata.dev or false) || dev)
|
(pname: pdata: ! (pdata.dev or false) || dev)
|
||||||
parsedDependencies);
|
parsedDependencies);
|
||||||
|
|
||||||
subsystemName = "nodejs";
|
subsystemName = "nodejs";
|
||||||
|
|
||||||
subsystemAttrs = { nodejsVersion = args.nodejs; };
|
subsystemAttrs = { nodejsVersion = args.nodejs; };
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
@ -156,6 +168,16 @@
|
|||||||
|
|
||||||
extraArgs = {
|
extraArgs = {
|
||||||
|
|
||||||
|
name = {
|
||||||
|
description = "The name of the main package";
|
||||||
|
examples = [
|
||||||
|
"react"
|
||||||
|
"@babel/code-frame"
|
||||||
|
];
|
||||||
|
default = "{automatic}";
|
||||||
|
type = "argument";
|
||||||
|
};
|
||||||
|
|
||||||
noDev = {
|
noDev = {
|
||||||
description = "Exclude development dependencies";
|
description = "Exclude development dependencies";
|
||||||
type = "flag";
|
type = "flag";
|
||||||
|
Loading…
Reference in New Issue
Block a user