-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
69 lines (64 loc) · 2.62 KB
/
Copy pathflake.nix
File metadata and controls
69 lines (64 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
description = "flight-cli: ITA Matrix Alkali backend wrapper (uv-managed; Nix dev shell optional).";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pyproject-nix = {
url = "github:pyproject-nix/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, pyproject-nix }:
let
inherit (nixpkgs) lib;
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
forAllSystems = lib.genAttrs systems;
pkgsFor = system: nixpkgs.legacyPackages.${system};
# Python interpreter follows pyproject.toml's `requires-python`: the
# first PEP 440 spec is taken as the floor (handles `>=X.Y` and
# `>=X.Y,<Z.W` shapes). Bump pyproject.toml — shell follows.
project = pyproject-nix.lib.project.loadPyproject { projectRoot = ./.; };
lowerBound = lib.head project.requires-python;
pyAttr =
"python"
+ toString (builtins.elemAt lowerBound.version.release 0)
+ toString (builtins.elemAt lowerBound.version.release 1);
in
{
devShells = forAllSystems (system:
let
pkgs = pkgsFor system;
python = pkgs.${pyAttr};
in
{
default = pkgs.mkShell {
packages = [
python
pkgs.uv
pkgs.gnumake
];
# uv's bundled python-build-standalone won't link on NixOS;
# force the Nix-managed interpreter. No-op on Darwin.
shellHook = ''
export UV_PYTHON=${python}/bin/python3
export UV_PYTHON_PREFERENCE=only-system
${lib.optionalString pkgs.stdenv.isLinux ''
# Binary Python wheels with compiled C++ extensions
# (curl_cffi via httpx-curl-cffi, used for TLS
# fingerprinting) link against libstdc++.so.6 at
# runtime. The Nix devShell doesn't expose the host's
# library paths; surface it from the Nix store.
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ]}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
''}
echo "🐍 python: $(python3 --version)"
echo "📦 uv: $(uv --version)"
'';
};
});
# To `nix build` this project (for nixpkgs PRs, NixOS modules,
# home-manager), enable uv2nix: https://pyproject-nix.github.io/uv2nix/
# Then also add `nix build .#default` to ci.yml.
#
# packages = forAllSystems (system: { default = ...; });
# apps = forAllSystems (system: { default = ...; });
};
}