Skip to content

Commit

Permalink
Fix licenses and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Jan 5, 2024
1 parent 4b76cf0 commit 8b40ef1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nixtract/describe-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ in
version = (builtins.tryEval (targetValue.version or "")).value;
broken = (builtins.tryEval (targetValue.meta.broken or false)).value;
homepage = (builtins.tryEval (targetValue.meta.homepage or "")).value;
license = (builtins.tryEval (
licenses = (builtins.tryEval (
if builtins.isAttrs (targetValue.meta.license or null)
# In case the license attribute is not a list, we produce a singleton list to be consistent
then [{
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/flake-direct-buildInput/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
mkdir -p $out/bin
cp $src/* $out/bin
'';
meta.license = pkgs.lib.licenses.gpl2Plus;
};

pkg2 = pkgs.stdenv.mkDerivation {
Expand All @@ -28,6 +29,7 @@
mkdir -p $out/bin
cp $src/* $out/bin
'';
meta.license = with pkgs.lib; [ licenses.mit licenses.asl20 ];
};

in
Expand Down
3 changes: 3 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def test_direct_buildinput():
assert pkg2_node.get("output_path") is not None
assert pkg2_node.get("name") == "pkg2"
assert pkg2_node.get("parsed_name", {}).get("name") == "pkg2"
assert pkg2_node.get("nixpkgs_metadata", {}).get("licenses")[0].get("spdxId") == "MIT"
assert pkg2_node.get("nixpkgs_metadata", {}).get("licenses")[1].get("spdxId") == "Apache-2.0"
assert len(pkg2_node.get("build_inputs")) >= 1
pkg2_buildinput_pkg1 = next(
(
Expand All @@ -133,6 +135,7 @@ def test_direct_buildinput():
assert pkg1_node is not None
assert pkg1_node.get("output_path") == pkg2_buildinput_pkg1["output_path"]
assert pkg1_node.get("output_path") == pkg2_buildinput_pkg1["output_path"]
assert pkg1_node.get("nixpkgs_metadata", {}).get("licenses")[0].get("spdxId") == "GPL-2.0-or-later"

# test behavior through logs
# quite unstable, will do for now
Expand Down

0 comments on commit 8b40ef1

Please sign in to comment.