mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-29 23:35: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)
|
||||
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:
|
||||
config = json.load(f)
|
||||
config["isRepo"] = False
|
||||
if config['repoName'] and config ['packagesDir']:
|
||||
config['packagesDir'] = f"{find_repo_root()}/{config['packagesDir']}"
|
||||
config["isRepo"] = True
|
||||
|
||||
def checkLockJSON(lock):
|
||||
lock_schema_raw=open(dream2nix_src+"/specifications/dream-lock-schema.json").read()
|
||||
|
@ -48,11 +48,6 @@ let
|
||||
|
||||
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;
|
||||
|
||||
nodejs =
|
||||
@ -72,23 +67,8 @@ let
|
||||
lib.genAttrs
|
||||
versions
|
||||
(version:
|
||||
if isCyclic name version
|
||||
|| b.elem name standalonePackageNames then
|
||||
makeCombinedPackage name version
|
||||
else
|
||||
makePackage name version))
|
||||
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
|
||||
makePackage = name: version:
|
||||
|
@ -49,6 +49,12 @@ if 'dependencies' in package_json:
|
||||
if 'bundledDependencies' in package_json\
|
||||
and pname in package_json['bundledDependencies']:
|
||||
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]:
|
||||
package_json['dependencies'][pname] = available_deps[pname]
|
||||
changed = True
|
||||
@ -59,7 +65,7 @@ if 'dependencies' in 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']
|
||||
|
||||
if isinstance(bin, str):
|
||||
|
@ -14,6 +14,7 @@
|
||||
inputDirectories,
|
||||
inputFiles,
|
||||
|
||||
name,
|
||||
noDev,
|
||||
nodejs,
|
||||
...
|
||||
@ -73,8 +74,17 @@
|
||||
utils.simpleTranslate translatorName {
|
||||
# values
|
||||
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 =
|
||||
lib.mapAttrsToList
|
||||
(pname: pdata:
|
||||
@ -82,7 +92,9 @@
|
||||
(lib.filterAttrs
|
||||
(pname: pdata: ! (pdata.dev or false) || dev)
|
||||
parsedDependencies);
|
||||
|
||||
subsystemName = "nodejs";
|
||||
|
||||
subsystemAttrs = { nodejsVersion = args.nodejs; };
|
||||
|
||||
# functions
|
||||
@ -156,6 +168,16 @@
|
||||
|
||||
extraArgs = {
|
||||
|
||||
name = {
|
||||
description = "The name of the main package";
|
||||
examples = [
|
||||
"react"
|
||||
"@babel/code-frame"
|
||||
];
|
||||
default = "{automatic}";
|
||||
type = "argument";
|
||||
};
|
||||
|
||||
noDev = {
|
||||
description = "Exclude development dependencies";
|
||||
type = "flag";
|
||||
|
Loading…
Reference in New Issue
Block a user