nixos/templates/python/flake.nix

58 lines
1.2 KiB
Nix
Raw Normal View History

2025-05-25 23:28:27 +08:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
};
};
2025-07-13 06:04:55 +08:00
outputs =
{
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
inherit (pkgs) lib;
pkgs = import nixpkgs {
localSystem = { inherit system; };
2025-07-13 06:04:55 +08:00
config = {
cudaSupport = true;
allowUnfree = true;
};
2025-05-25 23:28:27 +08:00
};
2025-07-13 06:04:55 +08:00
defaultPython = pkgs.python3;
in
{
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
packages =
(with pkgs; [
ruff
pyright
2025-05-25 23:28:27 +08:00
2025-07-13 06:04:55 +08:00
uv
defaultPython
])
++ (with pkgs.python3Packages; [
pydantic
torchWithCuda
]);
shellHook = ''
uv sync
. ./.venv/bin/activate
'';
env = {
UV_PYTHON_DOWNLOADS = "never";
UV_PYTHON = "${lib.getExe' defaultPython "python"}";
UV_TORCH_BACKEND = "auto";
};
2025-05-25 23:28:27 +08:00
};
2025-07-13 06:04:55 +08:00
}
);
2025-05-25 23:28:27 +08:00
nixConfig = {
keepOutputs = true;
};
}