Skip to content

Instantly share code, notes, and snippets.

@agoose77
Last active August 31, 2024 09:38
Show Gist options
  • Save agoose77/55d04420384cafac9b09971d4870b1f6 to your computer and use it in GitHub Desktop.
Save agoose77/55d04420384cafac9b09971d4870b1f6 to your computer and use it in GitHub Desktop.
Nix Flake for non-FHS venv
{
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.pip
python3Packages.virtualenv
pythonManylinuxPackages.manylinux2014Package
cmake
ninja
imagemagick
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib.outPath}/lib:${pkgs.pythonManylinuxPackages.manylinux2014Package}/lib:$LD_LIBRARY_PATH";
test -d .nix-venv || ${pkgs.python3.interpreter} -m venv .nix-venv
source .nix-venv/bin/activate
'';
}; });
}
@akaihola
Copy link

And to clarify for newbies, you run this with:

nix develop

See also Jupyter and Python on NixOS on r/NixOS for more context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment