Re-use dependencies of a package

can someone aid my failing memory?
there was some function I could use to get the dependencies of a package and use them in other buildInputs-like contexts.
but I don’t remember what it was called.

concrete example of what I’m after:

  # File: flake.nix
  outputs = inputs:
    {
      packages.${system} = {
        somepackage = pkgs.writeShellApplication {  # not necessarily a shell application!
          name = "somepackage";
          runtimeInputs = with pkgs; [ qemu-utils curl coreutils gnused ];
          text = builtins.readFile ./somescript.sh;
        };
      };

      devShells.${system}.default = pkgs.mkShell {
        packages =
          [ some stuff ]
          ++ (getDependenciesOf self.packages.${system}.somepackage) # <--- this is what I'm after
        ;
      };
    };

So basically I’m looking for the actual name of the function that I named getDependenciesOf, and then qemu-utils and curl etc. would be available in the shell so I don’t repeat myself.

Are you maybe searching for the inputsFrom attribute that mkShell specifically knows about?

1 Like

Thanks NobbZ. That solves my immediate problem, yes. However, I seem to remember there was something more general.

I am not aware of something more general, only the special casing in mkShell.

Well you can see how mkShell itself implements inputsFrom:

They’re not doing anything particularly brilliant here though.

1 Like