Created
December 27, 2024 21:56
-
-
Save gmodena/a24c7de1a543df154f4ab602e9430aed to your computer and use it in GitHub Desktop.
rust + python flake to replicate fann benchmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
# Based on https://ryantm.github.io/nixpkgs/languages-frameworks/python/#python | |
# (modified). | |
description = "Nix Development Flake for python legacy projects"; | |
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | |
outputs = | |
{ self, nixpkgs, flake-utils }: | |
flake-utils.lib.eachDefaultSystem | |
(system: | |
let | |
pkgs = import nixpkgs { inherit system; }; | |
python = pkgs.python310; | |
pythonPackages = python.pkgs; | |
requirementsFile = "requirements.txt"; | |
# A set of system dependencies for Python modules. | |
# They act as build inputs and are used to configure | |
# LD_LIBRARY_PATH in the shell. | |
systemPackages = with pkgs; [ | |
taglib | |
openssl | |
git | |
libxml2 | |
libxslt | |
libzip | |
zlib | |
stdenv.cc.cc.lib | |
busybox | |
rustc | |
cargo | |
]; | |
in | |
{ | |
devShells.default = pkgs.mkShell { | |
name = "impurePythonEnv"; | |
venvDir = ".venv"; | |
buildInputs = [ | |
pythonPackages.python | |
# This executes some shell code to initialize | |
# a venv in $venvDir before dropping into the shell | |
pythonPackages.venvShellHook | |
# Those are dependencies that we would like | |
# to use from nixpkgs, which will add | |
# them to PYTHONPATH and thus make them accessible | |
# from within the venv. | |
#pythonPackages.numpy | |
] | |
++ systemPackages; | |
postVenvCreation = '' | |
unset SOURCE_DATE_EPOCH | |
''; | |
postShellHook = '' | |
unset SOURCE_DATE_EPOCH | |
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath systemPackages} | |
pip install -r ${requirementsFile} | |
''; | |
}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment