Skip to content

Instantly share code, notes, and snippets.

@akaihola
Forked from agoose77/flake.nix
Last active October 1, 2024 01:36
Show Gist options
  • Save akaihola/1332204faf10df7956ea6d1702bfae85 to your computer and use it in GitHub Desktop.
Save akaihola/1332204faf10df7956ea6d1702bfae85 to your computer and use it in GitHub Desktop.
Nix Flake for non-FHS Python virtualenv using uv. As an example, install Jupyter and Pandas.
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs @ {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
python3
python3Packages.jupyter
python3Packages.pandas
python3Packages.pip
python3Packages.virtualenv
pythonManylinuxPackages.manylinux2014Package
uv
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib.outPath}/lib:${pkgs.pythonManylinuxPackages.manylinux2014Package}/lib:$LD_LIBRARY_PATH";
test -d .nix-venv || uv venv --python=${pkgs.python3.interpreter} .nix-venv
source .nix-venv/bin/activate
'';
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment