templates/python-uv: init
This commit is contained in:
parent
7e5f71e494
commit
461e999a08
4
flake/outputs/templates.nix
Normal file
4
flake/outputs/templates.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
flake.templates = import ../../templates;
|
||||||
|
}
|
6
templates/default.nix
Normal file
6
templates/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"python-uv" = {
|
||||||
|
path = ./python-uv;
|
||||||
|
description = "a python project using uv";
|
||||||
|
};
|
||||||
|
}
|
6
templates/python-uv/.envrc
Normal file
6
templates/python-uv/.envrc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
files=(
|
||||||
|
"uv.lock"
|
||||||
|
"pyproject.toml"
|
||||||
|
)
|
||||||
|
watch_file "${files[@]}"
|
||||||
|
use flake
|
14
templates/python-uv/.gitignore
vendored
Normal file
14
templates/python-uv/.gitignore
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
result*
|
||||||
|
.direnv
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
|
||||||
|
# Python-generated files
|
||||||
|
__pycache__/
|
||||||
|
*.py[oc]
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
wheels/
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
.venv
|
0
templates/python-uv/README.md
Normal file
0
templates/python-uv/README.md
Normal file
108
templates/python-uv/flake.nix
Normal file
108
templates/python-uv/flake.nix
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
{
|
||||||
|
outputs =
|
||||||
|
inputs@{ flake-parts, ... }:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
imports = [
|
||||||
|
inputs.devshell.flakeModule
|
||||||
|
inputs.git-hooks-nix.flakeModule
|
||||||
|
inputs.treefmt-nix.flakeModule
|
||||||
|
];
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
workspace = inputs.uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
|
||||||
|
overlay = workspace.mkPyprojectOverlay { sourcePreference = "wheel"; };
|
||||||
|
pyprojectOverrides = _final: _prev: { };
|
||||||
|
pythonSet =
|
||||||
|
(pkgs.callPackage inputs.pyproject-nix.build.packages {
|
||||||
|
python = pkgs.python311;
|
||||||
|
}).overrideScope
|
||||||
|
(lib.composeExtensions overlay pyprojectOverrides);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devshells.default = {
|
||||||
|
packages = [
|
||||||
|
(pythonSet.mkVirtualEnv "python-uv-env" workspace.deps.all)
|
||||||
|
pkgs.python311Packages.uv
|
||||||
|
config.treefmt.build.wrapper
|
||||||
|
];
|
||||||
|
env = [
|
||||||
|
(lib.nameValuePair "UV_PYTHON" "${lib.getExe pkgs.python311}")
|
||||||
|
(lib.nameValuePair "DEVSHELL_NO_MOTD" 1)
|
||||||
|
{
|
||||||
|
name = "PYTHONPATH";
|
||||||
|
unset = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
devshell.startup.pre-commit-hook.text = config.pre-commit.installationScript;
|
||||||
|
};
|
||||||
|
|
||||||
|
treefmt = {
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
programs = {
|
||||||
|
nixfmt.enable = true;
|
||||||
|
ruff-check.enable = true;
|
||||||
|
ruff-format.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
pre-commit.settings.hooks.treefmt = {
|
||||||
|
enable = true;
|
||||||
|
name = "treefmt";
|
||||||
|
entry = lib.getExe config.treefmt.build.wrapper;
|
||||||
|
pass_filenames = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
# flake-parts
|
||||||
|
|
||||||
|
flake-parts = {
|
||||||
|
url = "github:hercules-ci/flake-parts";
|
||||||
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
# nixpkgs
|
||||||
|
|
||||||
|
nixpkgs.follows = "nixpkgs-unstable";
|
||||||
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
# flake modules
|
||||||
|
|
||||||
|
devshell = {
|
||||||
|
url = "github:numtide/devshell";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
git-hooks-nix = {
|
||||||
|
url = "github:cachix/git-hooks.nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.nixpkgs-stable.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
# libraries
|
||||||
|
|
||||||
|
pyproject-nix = {
|
||||||
|
url = "github:nix-community/pyproject.nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
uv2nix = {
|
||||||
|
url = "github:adisbladis/uv2nix";
|
||||||
|
inputs.pyproject-nix.follows = "pyproject-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
7
templates/python-uv/pyproject.toml
Normal file
7
templates/python-uv/pyproject.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[project]
|
||||||
|
name = "python-uv"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
7
templates/python-uv/uv.lock
Normal file
7
templates/python-uv/uv.lock
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
version = 1
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-uv"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = { editable = "." }
|
Loading…
Reference in a new issue