Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/group pkgs versions #751

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/dream2nix-repo-flake-pdm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
specialArgs.packageSets.nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
};
in {
packages.${system} = evaled.config.groups.default.public.packages;
packages.${system}.requests = evaled.config.groups.default.public.packages.requests."2.31.0";
};
}
52 changes: 27 additions & 25 deletions modules/dream2nix/WIP-python-pdm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,34 @@ in {
};

packages = lib.flip lib.mapAttrs deps' (name: pkg: {
inherit name;
version = pkg.version;
imports = [
dream2nix.modules.dream2nix.buildPythonPackage
dream2nix.modules.dream2nix.mkDerivation
dream2nix.modules.dream2nix.package-func
];
buildPythonPackage = {
format =
if lib.hasSuffix ".whl" pkg.source.file
then "wheel"
else "pyproject";
};
mkDerivation = {
# required: { pname, file, version, hash, kind, curlOpts ? "" }:
src = fetchFromPypi {
pname = name;
file = pkg.source.file;
version = pkg.version;
hash = pkg.source.hash;
kind = "";
${pkg.version} = {
inherit name;
version = pkg.version;
imports = [
dream2nix.modules.dream2nix.buildPythonPackage
dream2nix.modules.dream2nix.mkDerivation
dream2nix.modules.dream2nix.package-func
];
buildPythonPackage = {
format =
if lib.hasSuffix ".whl" pkg.source.file
then "wheel"
else "pyproject";
};
mkDerivation = {
# required: { pname, file, version, hash, kind, curlOpts ? "" }:
src = fetchFromPypi {
pname = name;
file = pkg.source.file;
version = pkg.version;
hash = pkg.source.hash;
kind = "";
};
propagatedBuildInputs =
lib.forEach
parsed_lock_data.${name}.dependencies
(depName: lib.head (lib.attrValues (config.groups.${groupname}.public.packages.${depName})));
};
propagatedBuildInputs =
lib.forEach
parsed_lock_data.${name}.dependencies
(depName: config.groups.${groupname}.public.packages.${depName});
};
});
in {inherit packages;};
Expand Down
11 changes: 7 additions & 4 deletions modules/dream2nix/groups/group.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ in {
'';
};
packages = lib.mkOption {
type = t.lazyAttrsOf packageType;
type = t.lazyAttrsOf (t.lazyAttrsOf packageType);
description = ''
The package configurations to evaluate
'';
};
packagesEval = lib.mkOption {
type = t.lazyAttrsOf (t.submoduleWith {modules = [];});
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submoduleWith {modules = [];}));
description = ''
The evaluated dream2nix package modules
'';
internal = true;
};
public.packages = lib.mkOption {
type = t.lazyAttrsOf t.package;
type = t.lazyAttrsOf (t.lazyAttrsOf t.package);
description = ''
The evaluated packages ready to consume
'';
Expand All @@ -44,6 +44,9 @@ in {
};
config = {
packagesEval = config.packages;
public.packages = lib.mapAttrs (name: pkg: pkg.public) config.packagesEval;
public.packages =
lib.mapAttrs
(name: versions: lib.mapAttrs (version: pkg: pkg.public) versions)
config.packagesEval;
};
}
8 changes: 4 additions & 4 deletions tests/nix-unit/test_groups/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
in {
test_groups_simple = let
config = eval {
groups.my-group.packages.hello = {...}: fixtures.basic-derivation;
groups.my-group.packages.hello."1.0.0" = {...}: fixtures.basic-derivation;
};
in {
expr = config.groups.my-group.public.packages.hello ? drvPath;
expr = config.groups.my-group.public.packages.hello."1.0.0" ? drvPath;
expected = true;
};

test_groups_commonModule = let
config = eval {
groups.my-group.packages.hello = {...}: fixtures.basic-derivation;
groups.my-group.packages.hello."1.0.0" = {...}: fixtures.basic-derivation;
commonModule = {name = lib.mkForce "hello-mod";};
};
in {
expr = "${config.groups.my-group.public.packages.hello.name}";
expr = "${config.groups.my-group.public.packages.hello."1.0.0".name}";
expected = "hello-mod";
};
}
2 changes: 1 addition & 1 deletion tests/nix-unit/test_python-pdm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ in {
pdm.pyproject = ./../../../examples/dream2nix-repo-flake-pdm/pyproject.toml;
};
in {
expr = config.groups.default.public.packages.certifi ? drvPath;
expr = lib.head (lib.attrValues config.groups.default.public.packages.certifi) ? drvPath;
expected = true;
};
}