Skip to content

Commit 751831f

Browse files
committed
DEV: add cross-compiled nix devshells for multiple architectures
- Define `arch_pkgs` mapping for native, aarch64, s390x, ppc64le, and armhf - Allow selection via `NPSR_ARCH` env var (defaults to native) - Configure per-arch virtualenv under `.direnv/py/<arch>` - Bootstrap Python venv with `spin==0.13`
1 parent 300b6bc commit 751831f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@ Thumbs.db
118118
# pytest generated files #
119119
##########################
120120
/.pytest_cache
121+
122+
# NIXOS generated files #
123+
.direnv/

default.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let
2+
pkgs = import <nixpkgs> { };
3+
arch_pkgs = {
4+
native = pkgs;
5+
aarch64 = pkgs.pkgsCross.aarch64-multiplatform;
6+
s390x = pkgs.pkgsCross.s390x;
7+
ppc64le = pkgs.pkgsCross.powernv;
8+
armhf = pkgs.pkgsCross.armv7l-hf-multiplatform;
9+
};
10+
arch = if builtins.getEnv "NPSR_ARCH" == "" then "native" else builtins.getEnv "NPSR_ARCH";
11+
venv_path = ".direnv/py/" + arch;
12+
pkgsCross = arch_pkgs.${arch};
13+
in
14+
pkgsCross.mkShell {
15+
name = "Numpy SIMD Routines ${arch}";
16+
packages = with pkgsCross; [
17+
sollya
18+
python312
19+
python312Packages.virtualenv
20+
];
21+
shellHook = ''
22+
if test ! -d "${venv_path}"; then
23+
python -m venv ${venv_path}
24+
source ${venv_path}/bin/activate
25+
python -m pip install --upgrade pip
26+
python -m pip install "spin==0.13"
27+
else
28+
source ${venv_path}/bin/activate
29+
fi
30+
'';
31+
}

0 commit comments

Comments
 (0)