tweag / nix-hour

Questions for the weekly Nix Hour
MIT License
78 stars 3 forks source link

How to update python package in home-manager config? #33

Closed ianliu closed 9 months ago

ianliu commented 1 year ago

I want pandas 2.0 available in my home-manager config. How can I do it? This is my attempt:

{ config, pkgs, ... }:

{
  nixpkgs.overlays = [
    (final: prev: {
      python = prev.python311.override {
        packageOverrides = pyfinal: pyprev: {
          pandas = pyprev.pandas.overridePythonAttrs (old: rec {
            version = "2.0.3";
            src = pyfinal.fetchPypi {
              pname = "pandas";
              inherit version;
              hash = "";
            };
          });
        };
      };
    })
  ];
  home.username = "il";
  home.homeDirectory = "/home/il";
  home.stateVersion = "23.05"; # Dont change this

  home.packages = [
    pkgs.awscli2
    (pkgs.python311.withPackages (ps: [
      ps.ipython
      ps.pyarrow
      ps.pandas
    ]))
  ];

  programs.bash.enable = true;
  programs.home-manager.enable = true;
}

# vim: sw=2 et sta

Running home-manager switch just installed the original pandas 1.5.3.

infinisil commented 9 months ago

This is probably not the best place to ask such specific questions, Discourse seems better!

In this case though, you just need to make sure to override python311 instead of python:

  nixpkgs.overlays = [
    (final: prev: {
      python311 = prev.python311.override {