NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.9k stars 1.53k forks source link

license meta attribute gets incorrectly serialized when using XML output mode #4328

Open poscat0x04 opened 3 years ago

poscat0x04 commented 3 years ago

Describe the bug

When using nix-env, the license meta-attribute does no get generated correctly when using the XML output mode if the derivation has more than 1 license. For example, the derivation "dash" has 2 licenses defined:

❯ nix eval --json "nixpkgs#dash.meta.license" | jq .
[
  {
    "fullName": "BSD 3-clause \"New\" or \"Revised\" License",
    "shortName": "bsd3",
    "spdxId": "BSD-3-Clause",
    "url": "https://spdx.org/licenses/BSD-3-Clause.html"
  },
  {
    "fullName": "GNU General Public License v2.0 only",
    "shortName": "gpl2Only",
    "spdxId": "GPL-2.0-only",
    "url": "https://spdx.org/licenses/GPL-2.0-only.html"
  }
]

This is the XML element corresponding to dash, the element representing the license attribute does not have any child nodes.

  <item attrPath="dash" name="dash-0.5.11.2" pname="dash" system="x86_64-linux" version="0.5.11.2">
    <output name="out" path="/nix/store/3jkp7snfjb4gz1fvi29jybv1fzidgjlg-dash-0.5.11.2" />
    <meta name="available" type="bool" value="true" />
    <meta name="broken" type="bool" value="false" />
    <meta name="description" type="string" value="A POSIX-compliant implementation of /bin/sh that aims to be as small as possible" />
    <meta name="homepage" type="string" value="http://gondor.apana.org.au/~herbert/dash/" />
    <meta name="insecure" type="bool" value="false" />
    <meta name="license" type="strings">
    </meta>
    <meta name="name" type="string" value="dash-0.5.11.2" />
    <meta name="outputsToInstall" type="strings">
      <string value="out" />
    </meta>
    <meta name="platforms" type="strings">
      <string value="aarch64-linux" />
      <string value="armv5tel-linux" />
      <string value="armv6l-linux" />
      <string value="armv7a-linux" />
      <string value="armv7l-linux" />
      <string value="mipsel-linux" />
      <string value="i686-cygwin" />
      <string value="i686-freebsd" />
      <string value="i686-linux" />
      <string value="i686-netbsd" />
      <string value="i686-openbsd" />
      <string value="x86_64-cygwin" />
      <string value="x86_64-freebsd" />
      <string value="x86_64-linux" />
      <string value="x86_64-netbsd" />
      <string value="x86_64-openbsd" />
      <string value="x86_64-solaris" />
      <string value="x86_64-darwin" />
      <string value="i686-darwin" />
      <string value="aarch64-darwin" />
      <string value="armv7a-darwin" />
      <string value="x86_64-redox" />
      <string value="powerpc64le-linux" />
      <string value="riscv32-linux" />
      <string value="riscv64-linux" />
    </meta>
    <meta name="position" type="string" value="/nix/store/g1af87qqdqgcjbl4lc547d731vqf8lpf-source/pkgs/shells/dash/default.nix:28" />
    <meta name="unfree" type="bool" value="false" />
    <meta name="unsupported" type="bool" value="false" />
  </item>

Steps To Reproduce

  1. run nix-env -qaP -f "<nixpkgs>" --xml --meta
  2. search for any derivation with multiple licenses

Expected behavior

The license field should be serialized correctly.

nix-env --version output

nix-env (Nix) 2.4pre20201201_5a6ddb3

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

poscat0x04 commented 3 years ago

this issue still exists

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info