add field _generic.location to dream-lock

This commit is contained in:
DavHau 2022-02-27 19:06:38 +07:00
parent 6fb2ec0e6a
commit 7ff0d5d0e8
6 changed files with 32 additions and 8 deletions

View File

@ -204,6 +204,13 @@ class AddCommand(Command):
# add main package source
self.add_main_source(lock, defaultPackage, defaultPackageVersion, sourceSpec)
# add location
if 'location' not in lock['_generic']:
if 'dir' in sourceSpecSub:
lock['_generic']['location'] = sourceSpecSub['dir']
else:
lock['_generic']['location'] = ''
# clean up dependency graph
if 'dependencies' in lock['_generic']:
self.postprocess_dep_graph(lock)
@ -396,7 +403,7 @@ class AddCommand(Command):
existingFiles = set(os.listdir(output))
if not self.option('no-default-nix') \
and not 'default.nix' in existingFiles \
and not config['packagesDir']:
and not config['projectRoot']:
filesToCreate.append('default.nix')
# overwrite existing files only if --force is set
if self.option('force'):

View File

@ -575,7 +575,10 @@ let
defaultPackageVersion =
dreamLock._generic.packages."${defaultPackage}";
in
{ "${defaultPackage}"."${defaultPackageVersion}" = source; };
{
"${defaultPackage}"."${defaultPackageVersion}" =
"${source}/${dreamLock._generic.location}";
};
projectOutputs =

View File

@ -155,6 +155,7 @@
"properties": {
"defaultPackage": { "type": ["string", "null"] },
"invalidationHash": { "type": ["string", "null"] },
"location": { "type": "string" },
"packages": { "type": "object" },
"sourcesAggregatedHash": { "type": ["string", "null"] },
"subsystem": { "type": "string" },

View File

@ -30,11 +30,19 @@ let
translate = args:
l.map
(proj:
translator.translate
((cleanedArgs args) // {
source = "${args.source}/${proj.relPath}";
name = proj.name;
}))
let
dreamLock =
translator.translate
((cleanedArgs args) // {
source = "${args.source}/${proj.relPath}";
name = proj.name;
});
in
dreamLock // {
_generic = dreamLock._generic // {
location = proj.relPath;
};
})
args.projects;
};
in

View File

@ -88,6 +88,7 @@ let
tree = tree.getNodeFromPath proj.relPath;
packageLock = getPackageLock proj;
packageJson = getPackageJson proj;
relPath = proj.relPath;
workspaces = proj.subsystemInfo.workspaces or [];
})
filteredProjects;
@ -106,6 +107,7 @@ let
# subsystem specific
packageLock,
packageJson,
relPath,
workspaces,
# translator args
@ -222,6 +224,7 @@ let
rec {
inherit translatorName;
location = relPath;
# values
inputData = pinnedRootDeps;

View File

@ -47,8 +47,9 @@ let
magic =
{
# values
inputData,
defaultPackage,
inputData,
location ? "",
mainPackageDependencies,
packages,
subsystemName,
@ -239,6 +240,7 @@ let
{
inherit
defaultPackage
location
packages
;
subsystem = subsystemName;