feat(python): manage python with uv via nix-ld
This commit is contained in:
@@ -89,6 +89,10 @@ in
|
|||||||
PYTHONIOENCODING = "UTF-8";
|
PYTHONIOENCODING = "UTF-8";
|
||||||
PYTHONSTARTUP = "${config.xdg.configHome}/python/startup";
|
PYTHONSTARTUP = "${config.xdg.configHome}/python/startup";
|
||||||
PYTHON_HISTFILE = "${config.xdg.cacheHome}/python/history";
|
PYTHON_HISTFILE = "${config.xdg.cacheHome}/python/history";
|
||||||
|
# Default interpreter uv picks for `uv run`/`uv venv` without an explicit
|
||||||
|
# -p. Pins throwaway REPLs and new projects to one version across machines
|
||||||
|
# (further steered by uv.toml below). Fetched on demand by uv, not Nix.
|
||||||
|
UV_PYTHON = "3.14";
|
||||||
# psql / wget / readline configs, XDG-routed (the rc files are declared
|
# psql / wget / readline configs, XDG-routed (the rc files are declared
|
||||||
# via xdg.configFile below).
|
# via xdg.configFile below).
|
||||||
PSQLRC = "${config.xdg.configHome}/psql/rc";
|
PSQLRC = "${config.xdg.configHome}/psql/rc";
|
||||||
@@ -123,6 +127,8 @@ in
|
|||||||
# finalPackage) — do NOT also list it here, or buildEnv conflicts on the
|
# finalPackage) — do NOT also list it here, or buildEnv conflicts on the
|
||||||
# wrapper binary.
|
# wrapper binary.
|
||||||
nodejs
|
nodejs
|
||||||
|
uv # Python: versions, venvs, deps, lockfile. Runs uv-managed
|
||||||
|
# standalone CPython via nix-ld (see modules/nixos.nix).
|
||||||
highlight # `ccat` alias: syntax-highlighted cat
|
highlight # `ccat` alias: syntax-highlighted cat
|
||||||
jq # JSON on the command line (scripts, ad-hoc inspection)
|
jq # JSON on the command line (scripts, ad-hoc inspection)
|
||||||
libreoffice
|
libreoffice
|
||||||
@@ -144,6 +150,13 @@ in
|
|||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"python/startup".source = ./assets/python-startup.py;
|
"python/startup".source = ./assets/python-startup.py;
|
||||||
|
|
||||||
|
# uv global config. "managed" = always use uv's own CPython, never a
|
||||||
|
# system/Nix python — keeps behaviour reproducible regardless of what else
|
||||||
|
# is on PATH. Default version comes from UV_PYTHON above.
|
||||||
|
"uv/uv.toml".text = ''
|
||||||
|
python-preference = "managed"
|
||||||
|
'';
|
||||||
|
|
||||||
# psql: unlimited, per-database history file (kept out of $HOME).
|
# psql: unlimited, per-database history file (kept out of $HOME).
|
||||||
"psql/rc".text = ''
|
"psql/rc".text = ''
|
||||||
\set HISTFILE ${config.xdg.cacheHome}/psql/history-:DBNAME
|
\set HISTFILE ${config.xdg.cacheHome}/psql/history-:DBNAME
|
||||||
@@ -325,6 +338,8 @@ in
|
|||||||
g = "git";
|
g = "git";
|
||||||
e = editor;
|
e = editor;
|
||||||
v = editor;
|
v = editor;
|
||||||
|
# Throwaway REPL/scripts as if `python` were global; resolves to UV_PYTHON.
|
||||||
|
python = "uv run python";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Interactive bits with no first-class HM option: prompt, autocd,
|
# Interactive bits with no first-class HM option: prompt, autocd,
|
||||||
|
|||||||
@@ -54,6 +54,23 @@
|
|||||||
programs.hyprland.enable = true;
|
programs.hyprland.enable = true;
|
||||||
programs.dconf.enable = true;
|
programs.dconf.enable = true;
|
||||||
|
|
||||||
|
# nix-ld: install a stub dynamic linker at the standard FHS path
|
||||||
|
# (/lib64/ld-linux-*.so), which NixOS otherwise lacks. Lets unpatched
|
||||||
|
# prebuilt binaries run — notably the standalone CPython builds uv downloads
|
||||||
|
# and pip wheels with compiled extensions (numpy, pydantic-core, ...). The
|
||||||
|
# libraries list is exposed as NIX_LD_LIBRARY_PATH so those binaries find
|
||||||
|
# common shared libs; extend it when an import fails with "libFOO.so.N: cannot
|
||||||
|
# open shared object file".
|
||||||
|
programs.nix-ld = {
|
||||||
|
enable = true;
|
||||||
|
libraries = with pkgs; [
|
||||||
|
stdenv.cc.cc.lib # libstdc++, libgcc_s, libgomp
|
||||||
|
zlib # libz
|
||||||
|
zstd # libzstd (pyarrow, polars)
|
||||||
|
openssl # libssl, libcrypto
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Packages installed in system profile.
|
# Packages installed in system profile.
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
curl
|
curl
|
||||||
|
|||||||
Reference in New Issue
Block a user