Passing non default arguments to `default.nix` for Sage

I’m trying to build a Nix flake that’ll install Sage, along with a few python libraries that I want available with the Sage environment. It appears that the Sage derivation does take in an optional argument that specifies any extra python packages that should be available. Here’s the head of the default.nix for Sage.

{ pkgs
, withDoc ? false
, requireSageTests ? true
, extraPythonPackages ? ps: []
}:

To replace the default extraPythonPackages argument, I’m overriding the attribute, like so.

sage.override { extraPythonPackages = {ps = [tensorflow];}; }

However, this makes nix complain that the dependency has the wrong type.

Dependency is not of a valid type: element 1 of buildInputs for nix-shell

What am I missing here exactly? Thanks!

Looking at the default value, extraPythonPackages expects to be given a function returning a list. You are giving it an attribute set. Try the following:

sage.override { extraPythonPackages = ps: [ps.tensorflow]; }
1 Like