mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-02 14:55:25 +03:00
rename dream.lock -> dream-lock.json
This commit is contained in:
parent
a1d0ed99a8
commit
a936cf44a5
@ -29,7 +29,7 @@ class PackageCommand(Command):
|
||||
multiple=False
|
||||
),
|
||||
option("translator", None, "which translator to use", flag=False),
|
||||
option("output", None, "output file/directory for the dream.lock", flag=False),
|
||||
option("output", None, "output file/directory for the dream-lock.json", flag=False),
|
||||
option(
|
||||
"combined",
|
||||
None,
|
||||
@ -66,7 +66,7 @@ class PackageCommand(Command):
|
||||
output = './.'
|
||||
if not os.path.isdir(output):
|
||||
os.mkdir(output)
|
||||
filesToCreate = ['dream.lock']
|
||||
filesToCreate = ['dream-lock.json']
|
||||
if self.option('default-nix'):
|
||||
filesToCreate.append('default.nix')
|
||||
if self.option('force'):
|
||||
@ -78,12 +78,12 @@ class PackageCommand(Command):
|
||||
if any(f in existingFiles for f in filesToCreate):
|
||||
print(
|
||||
f"output directory {output} already contains a 'default.nix' "
|
||||
"or 'dream.lock'. Delete first, or user '--force'.",
|
||||
"or 'dream-lock.json'. Delete first, or user '--force'.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
exit(1)
|
||||
output = os.path.realpath(output)
|
||||
outputDreamLock = f"{output}/dream.lock"
|
||||
outputDreamLock = f"{output}/dream-lock.json"
|
||||
outputDefaultNix = f"{output}/default.nix"
|
||||
|
||||
# verify source
|
||||
@ -111,9 +111,9 @@ class PackageCommand(Command):
|
||||
print(f"Input source '{source}' does not exist", file=sys.stdout)
|
||||
exit(1)
|
||||
source = os.path.realpath(source)
|
||||
# handle source from dream.lock
|
||||
if source.endswith('dream.lock'):
|
||||
print(f"fetching source defined via existing dream.lock")
|
||||
# handle source from dream-lock.json
|
||||
if source.endswith('dream-lock.json'):
|
||||
print(f"fetching source defined via existing dream-lock.json")
|
||||
with open(source) as f:
|
||||
sourceDreamLock = json.load(f)
|
||||
sourceMainPackageName = sourceDreamLock['_generic']['mainPackageName']
|
||||
@ -255,7 +255,7 @@ class PackageCommand(Command):
|
||||
|
||||
# raise error if output wasn't produced
|
||||
if not os.path.isfile(outputDreamLock):
|
||||
raise Exception(f"Translator failed to create dream.lock")
|
||||
raise Exception(f"Translator failed to create dream-lock.json")
|
||||
|
||||
# read produced lock file
|
||||
with open(outputDreamLock) as f:
|
||||
@ -366,13 +366,13 @@ class PackageCommand(Command):
|
||||
# store the hash in the lock
|
||||
lock['_generic']['sourcesCombinedHash'] = hash
|
||||
|
||||
# re-write dream.lock
|
||||
# re-write dream-lock.json
|
||||
checkLockJSON(lock)
|
||||
lockStr = json.dumps(lock, indent=2, sort_keys = True)
|
||||
lockStr = lockStr\
|
||||
.replace("[\n ", "[ ")\
|
||||
.replace("\"\n ]", "\" ]")\
|
||||
.replace(",\n ", ", ")
|
||||
.replace("[\n ", "[ ")\
|
||||
.replace("\"\n ]", "\" ]")\
|
||||
.replace(",\n ", ", ")
|
||||
with open(outputDreamLock, 'w') as f:
|
||||
f.write(lockStr)
|
||||
|
||||
@ -389,4 +389,4 @@ class PackageCommand(Command):
|
||||
defaultNix.write(template)
|
||||
print(f"Created {output}/default.nix")
|
||||
|
||||
print(f"Created {output}/dream.lock")
|
||||
print(f"Created {output}/dream-lock.json")
|
@ -17,7 +17,7 @@ class UpdateCommand(Command):
|
||||
name = "update"
|
||||
|
||||
options = [
|
||||
option("dream-lock", None, "dream.lock file or its parent directory", flag=False, value_required=True),
|
||||
option("dream-lock", None, "dream-lock.json file or its parent directory", flag=False, value_required=True),
|
||||
option("updater", None, "name of the updater module to use", flag=False),
|
||||
option("new-version", None, "new package version", flag=False),
|
||||
]
|
||||
@ -27,8 +27,8 @@ class UpdateCommand(Command):
|
||||
self.line(f"\n{self.description}\n")
|
||||
|
||||
dreamLockFile = os.path.abspath(self.option("dream-lock"))
|
||||
if not dreamLockFile.endswith('dream.lock'):
|
||||
dreamLockFile = os.path.abspath(dreamLockFile + "/dream.lock")
|
||||
if not dreamLockFile.endswith('dream-lock.json'):
|
||||
dreamLockFile = os.path.abspath(dreamLockFile + "/dream-lock.json")
|
||||
|
||||
# parse dream lock
|
||||
with open(dreamLockFile) as f:
|
||||
@ -68,7 +68,7 @@ class UpdateCommand(Command):
|
||||
newVersion=version,
|
||||
)
|
||||
lock['sources'][mainPackageName][mainPackageVersion] = updatedSourceSpec
|
||||
with tempfile.NamedTemporaryFile("w", suffix="dream.lock") as tmpDreamLock:
|
||||
with tempfile.NamedTemporaryFile("w", suffix="dream-lock.json") as tmpDreamLock:
|
||||
json.dump(lock, tmpDreamLock, indent=2)
|
||||
tmpDreamLock.seek(0) # flushes write cache
|
||||
sp.run(
|
||||
|
@ -48,7 +48,7 @@ in
|
||||
}:
|
||||
|
||||
dream2nix.riseAndShine {
|
||||
dreamLock = ./dream.lock;
|
||||
dreamLock = ./dream-lock.json;
|
||||
${lib.optionalString (dreamLock.sources."${mainPackageName}"."${mainPackageVersion}".type == "unknown") ''
|
||||
sourceOverrides = oldSources: {
|
||||
"${mainPackageName}#${mainPackageVersion}" = ./${sourcePathRelative};
|
||||
|
@ -271,7 +271,7 @@ let
|
||||
outputs;
|
||||
|
||||
|
||||
# produce outputs for a dream.lock or a source
|
||||
# produce outputs for a dream-lock or a source
|
||||
riseAndShine =
|
||||
{
|
||||
dreamLock ? null,
|
||||
|
@ -9,6 +9,6 @@
|
||||
],
|
||||
|
||||
"outputFile": [
|
||||
"./a/b/c/dream.lock"
|
||||
"./a/b/c/dream-lock.json"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user