nixpkgs-python icon indicating copy to clipboard operation
nixpkgs-python copied to clipboard

Help with caching for flakes

Open brookst opened this issue 3 months ago • 0 comments

Hi,     I'm just trying to get a flake with a working devShell containing an old Python version. I can run nix shell ... to pull a specific version and that works from cache. However, no matter what I try to do in a flake, nix develop always tries to build Python from source. Here's my attempt to just get python-3.8 in a devShell from flake.nix:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixpkgs-python = {
      url="github:cachix/nixpkgs-python";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  
  nixConfig = {
      substituters = [ "https://nixpkgs-python.cachix.org" ];
      trusted-substituters = [ "https://nixpkgs-python.cachix.org" ];
      trusted-public-keys = [ "nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU=" ];
      extra-substituters = [ "https://nixpkgs-python.cachix.org" ];
      extra-trusted-substituters = [ "https://nixpkgs-python.cachix.org" ];
      extra-trusted-public-keys = [ "nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU=" ];
  };
 
  outputs = { self, nixpkgs, nixpkgs-python }: {
    devShells."x86_64-linux".default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
        packages = [
            nixpkgs-python.packages.x86_64-linux."3.8"
        ];
    };
  };
}

If I remove the nixpkgs.follows, Nix starts building a lot of foundational packages like perl, so I'm reasonably sure I need that. I'd appreciate a hand in getting this working. nixpkgs-python is the closest I've gotten to running old python version without resorting to containers.

Cheers,     Tim

brookst avatar Oct 13 '25 17:10 brookst