try get groups working

This commit is contained in:
Johannes Kirschbauer 2024-01-18 12:08:28 +01:00
parent 8924111bc1
commit 2506205d9a
No known key found for this signature in database
3 changed files with 56 additions and 65 deletions

View File

@ -68,7 +68,7 @@ A collection of tools needed to interact with graphs (i.e. A dependencyTree)
}; };
} }
) )
graph.${parentName}.${parentVersion}.dependencies; (builtins.trace (lib.attrNames graph.${parentName}.${parentVersion}) graph.${parentName}.${parentVersion}.dependencies);
in in
l.filter ( l.filter (
entry: entry:

View File

@ -97,6 +97,7 @@
############################################################ ############################################################
# pdefs = parse cfg.packageLock; # pdefs = parse cfg.packageLock;
# {name}.{version}.{...}
groups.all.packages = parse cfg.packageLock; groups.all.packages = parse cfg.packageLock;
############################################################ ############################################################
@ -139,7 +140,6 @@
if path == "" if path == ""
then let then let
rinfo = info // {inherit fileSystem;}; rinfo = info // {inherit fileSystem;};
source = builtins.dirOf cfg.packageLockFile;
name = plent.name or lock.name; name = plent.name or lock.name;
fileSystem = graphUtils.getFileSystem groups.all.packages (info.pdefs' { fileSystem = graphUtils.getFileSystem groups.all.packages (info.pdefs' {
@ -149,7 +149,7 @@
inherit (plent) version; inherit (plent) version;
}; };
}); });
self = config.groups.all.packagesEval.${name}.${plent.version}; self = config.groups.all.packages.${name}.${plent.version}.evaluated;
prepared-dev = let prepared-dev = let
module = { module = {
@ -218,12 +218,12 @@
name = name + "-installed"; name = name + "-installed";
nativeBuildInputs = with config.deps; [jq]; nativeBuildInputs = with config.deps; [jq];
buildInputs = with config.deps; [nodejs]; buildInputs = with config.deps; [nodejs];
src = self.dist; src = null;
# src = self.dist;
env = { env = {
BINS = builtins.toJSON bins; BINS = builtins.toJSON bins;
}; };
configurePhase = '' configurePhase = ''
cp -r ${self.prepared-prod}/node_modules node_modules
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/lib/node_modules/${name} mkdir -p $out/lib/node_modules/${name}
@ -233,46 +233,47 @@
echo $BINS | jq 'to_entries | map("ln -s $out/lib/node_modules/${name}/\(.value) $out/bin/\(.key); ") | .[]' -r | bash echo $BINS | jq 'to_entries | map("ln -s $out/lib/node_modules/${name}/\(.value) $out/bin/\(.key); ") | .[]' -r | bash
''; '';
}; };
dist = let dist = {
module = { imports = [
imports = [ # config.groups.all.packages.${name}.${plent.version}
# config.groups.all.packages.${name}.${plent.version} dream2nix.modules.dream2nix.mkDerivation
dream2nix.modules.dream2nix.mkDerivation ];
]; config = {
config = { inherit (plent) version;
inherit (plent) version; name = name + "-dist";
name = name + "-dist"; env = {
mkDerivation = { TRUSTED = builtins.toJSON cfg.trustedDeps;
# inherit (entry) version; };
src = self.source; mkDerivation = {
buildInputs = with config.deps; [nodejs jq]; # inherit (entry) version;
configurePhase = '' src = builtins.dirOf cfg.packageLockFile;
cp -r ${self.prepared-dev}/node_modules node_modules # src = null;
chmod -R +w node_modules buildInputs = with config.deps; [nodejs jq];
# TODO: run installScripts of trusted dependencies configurePhase = ''
''; cp -r ${self.prepared-dev}/node_modules node_modules
buildPhase = '' chmod -R +w node_modules
echo "BUILDING... $name" node ${installTrusted}
'';
buildPhase = ''
echo "BUILDING... $name"
if [ "$(jq -e '.scripts.build' ./package.json)" != "null" ]; then if [ "$(jq -e '.scripts.build' ./package.json)" != "null" ]; then
echo "BUILDING... $name" echo "BUILDING... $name"
export HOME=.virt export HOME=.virt
npm run build npm run build
else else
echo "$(jq -e '.scripts.build' ./package.json)" echo "$(jq -e '.scripts.build' ./package.json)"
echo "No build script"; echo "No build script";
fi; fi;
''; '';
installPhase = '' installPhase = ''
# TODO: filter files # TODO: filter files
rm -rf node_modules rm -rf node_modules
cp -r . $out cp -r . $out
''; '';
};
}; };
}; };
in };
module;
# dist = config.deps.mkDerivation # dist = config.deps.mkDerivation
in { in {
# Root level package # Root level package
@ -280,14 +281,10 @@
value = { value = {
${plent.version} = { ${plent.version} = {
dependencies = getDependencies lock path plent; dependencies = getDependencies lock path plent;
dev = plent.dev or false; dev = plent.dev or false;
info = rinfo; info = rinfo;
inherit bins prepared-dev source dist prepared-prod installed; inherit bins prepared-dev dist prepared-prod installed;
public = { public = self.dist;
out = dist;
inherit dist;
};
}; };
}; };
} }
@ -316,13 +313,8 @@
dependencies = getDependencies lock path plent; dependencies = getDependencies lock path plent;
# We need to determine the initial state of every package and # We need to determine the initial state of every package and
# TODO: define dist and installed if they are in source form. We currently only do this for the root package. # TODO: define dist and installed if they are in source form. We currently only do this for the root package.
"dist" = source;
${info.initialState} = source; public = source;
public = {
out = source;
# TODO: I think this is a hack.
inherit (source) drvPath name;
};
}; };
}; };
}; };
@ -332,11 +324,16 @@ in {
imports = [ imports = [
./interface.nix ./interface.nix
dream2nix.modules.dream2nix.mkDerivation dream2nix.modules.dream2nix.mkDerivation
dream2nix.modules.dream2nix.groups dream2nix.modules.dream2nix.WIP-groups
]; ];
commonModule = overrideAll =
(import ./types.nix { {
imports = [
dream2nix.modules.dream2nix.core
];
}
// (import ./types.nix {
inherit inherit
lib lib
dream2nix dream2nix
@ -360,7 +357,7 @@ in {
; ;
}; };
package-func.result = l.mkForce (config.groups.all.public.packages.${config.name}.${config.version}); package-func.result = l.mkForce (config.groups.all.packages.${config.name}.${config.version}.public);
# OUTPUTS # OUTPUTS
WIP-nodejs-builder-v3 = { WIP-nodejs-builder-v3 = {

View File

@ -14,12 +14,6 @@
inherit dream2nix lib specialArgs; inherit dream2nix lib specialArgs;
}; };
# optPackage = l.mkOption {
# # type = t.raw;
# type = drvPartOrPackage;
# apply = drv: drv.public or drv;
# # default = null;
# };
optOptionalPackage = l.mkOption { optOptionalPackage = l.mkOption {
type = t.nullOr dreamTypes.drvPartOrPackage; type = t.nullOr dreamTypes.drvPartOrPackage;
apply = drv: drv.public or drv; apply = drv: drv.public or drv;