NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.11k forks source link

Xonsh extraPacakges doesn't work #326339

Closed charmoniumQ closed 3 months ago

charmoniumQ commented 3 months ago

Describe the bug

The wrapper introduced in #240246 is supposed to accept code like: xonsh.override { extraPackages = ps: [ ps.psutil ] }, and then psutil should be importable in the resulting Xonsh package. However, when building this package, I am met with:


error: function 'anonymous lambda' called with unexpected argument 'extraPackages'
at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/pkgs/by-name/xo/xonsh/package.nix:1:1:

error:
       … while calling a functor (an attribute set with a '__functor' attribute)
         at /nix/store/81ai25ifhr0l8rryf83h4pj8k0q2pjaj-source/flake.nix:4:37:
            3|   outputs = { self, nixpkgs }: {
            4|     packages.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.xonsh.override {
             |                                     ^
            5|       extraPackages = ps: [ ps.psutil ];

       … from call site
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/trivial.nix:955:7:
          954|     { # TODO: Should we add call-time "type" checking like built in?
          955|       __functor = self: f;
             |       ^
          956|       __functionArgs = args;

       … while calling anonymous lambda
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:144:34:
          143|       # Re-call the function but with different arguments
          144|       overrideArgs = mirrorArgs (newArgs: makeOverridable f (overrideWith newArgs));
             |                                  ^
          145|       # Change the result of the function call by applying g to it

       … while calling a functor (an attribute set with a '__functor' attribute)
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:144:43:
          143|       # Re-call the function but with different arguments
          144|       overrideArgs = mirrorArgs (newArgs: makeOverridable f (overrideWith newArgs));
             |                                           ^
          145|       # Change the result of the function call by applying g to it

       … from call site
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/trivial.nix:955:7:
          954|     { # TODO: Should we add call-time "type" checking like built in?
          955|       __functor = self: f;
             |       ^
          956|       __functionArgs = args;

       … while calling anonymous lambda
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:136:17:
          135|     in
          136|     mirrorArgs (origArgs:
             |                 ^
          137|     let

       … while evaluating a branch condition
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:148:7:
          147|     in
          148|       if isAttrs result then
             |       ^
          149|         result // {

       … while calling the 'isAttrs' builtin
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:148:10:
          147|     in
          148|       if isAttrs result then
             |          ^
          149|         result // {

       … from call site
         at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/lib/customisation.nix:138:16:
          137|     let
          138|       result = f origArgs;
             |                ^
          139|

       error: function 'anonymous lambda' called with unexpected argument 'extraPackages'
       at /nix/store/nm7g9fgcffl6nar6vpib220b51dyv0fl-source/pkgs/by-name/xo/xonsh/package.nix:1:1:
            1| {
             | ^
            2|   lib,

Is there a different way of getting to the wrapped Xonsh?

Steps To Reproduce

To reproduce:

$ cat <<EOF > flake.lockb
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1720712503,
        "narHash": "sha256-1u2FWxVZfuoMe8mfRvXBuZq6+DrEqeBT8A4uFOV+my8=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "69214562aeca0d6b28f8a233748bbd6f32a52a3f",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}
EOF

$ cat <<EOF > flake.nix
{
  inputs.nixpkgs.url = "github:nixos/nixpkgs/";
  outputs = { self, nixpkgs }: {
    packages.x86_64-linux.default = self.packages.x86_64-linux.xonsh.override {
      extraPackages = ps: [ ps.psutil ];
    };
  };
}
EOF

$ nix build

Expected behavior

Xonsh should build.

Additional context

Possibly relevant issues:

Notify maintainers

@samlukeyes123

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.37, NixOS, 24.11 (Vicuna), 24.11.20240709.feb2849`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.0pre20240627_b44909ac`
 - nixpkgs: `/home/sam/.nix-defexpr/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 3 months ago

use xonsh.wrapper instead of xonsh

This is documented in the option search: https://search.nixos.org/options?channel=unstable&show=programs.xonsh.package&from=0&size=50&sort=relevance&type=packages&query=xonsh

SamLukeYes commented 3 months ago

This behavior was changed in https://github.com/NixOS/nixpkgs/pull/314728, which includes a refactor, and the top-level xonsh package is not the wrapper now. I'm restoring the original behavior in https://github.com/NixOS/nixpkgs/pull/325813.