Video_52.md

Watch the video

Non-nix-way example flake

{
  description = "flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs, ... }: let
    pkgs = nixpkgs.legacyPackages."x86_64-linux";
  in {
    devShells.x86_64-linux.default = pkgs.mkShell {

      packages = [
        pkgs.python3
      ];

      env.LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
        pkgs.stdenv.cc.cc.lib
        pkgs.libz
      ];

    };
  };
}

Simple shell.nix

{ pkgs ? import <nixpkgs> {} }: 

pkgs.mkShell {

  packages = [
    (pkgs.python3.withPackages(p: with p; [
      numpy
      requests
      pandas
    ]))
  ];

}

Full flake.nix with pip2nix

# Generate a package from a pypi package
$ nix run github:nix-community/pip2nix -- generate requests
# Generate packages from requirements.txt
$ nix run github:nix-community/pip2nix -- ./requirements.txt
# A cool example with a shell
$ nix shell github:nix-community/pip2nix

$ pip2nix generate "requests==2.32" numpy
{
  description = "flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs, ... }: let

    pkgs = nixpkgs.legacyPackages."x86_64-linux";
    packageOverrides = pkgs.callPackage ./python-packages.nix {};
    python = pkgs.python3.override { inherit packageOverrides; };

  in {
    devShells.x86_64-linux.default = pkgs.mkShell {

      packages = [
        (python.withPackages(p: [ p.requests ]))
      ];

    };
  };
}