templates: add python-uv

This commit is contained in:
Bruno BELANYI 2025-04-05 18:18:06 +01:00
parent 62ddec5c23
commit ca98b8367c
7 changed files with 178 additions and 0 deletions

View file

@ -7,6 +7,10 @@
path = ./c++-meson;
description = "A C++ project using Meson";
};
"python-uv" = {
path = ./python-uv;
description = "A Python project using uv";
};
"rust-cargo" = {
path = ./rust-cargo;
description = "A Rust project using Cargo";

View file

@ -0,0 +1,6 @@
# shellcheck shell=bash
if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg="
fi
use flake

6
templates/python-uv/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
# Virtual environments
.venv
# Nix generated files
/.pre-commit-config.yaml
/result

View file

@ -0,0 +1,31 @@
labels:
backend: local
steps:
- name: pre-commit check
image: bash
commands:
- nix develop --command pre-commit run --all
- name: nix flake check
image: bash
commands:
- nix flake check
- name: notify
image: bash
environment:
ADDRESS:
from_secret: matrix_homeserver
ROOM:
from_secret: matrix_roomid
USER:
from_secret: matrix_username
PASS:
from_secret: matrix_password
commands:
- nix run github:ambroisie/matrix-notifier
when:
status:
- failure
- success

View file

@ -0,0 +1,112 @@
{
description = "A Python project";
inputs = {
futils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "main";
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
git-hooks = {
type = "github";
owner = "cachix";
repo = "git-hooks.nix";
ref = "master";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, futils, nixpkgs, git-hooks }:
{
overlays = {
default = final: _prev: {
project = with final; python3.pkgs.buildPythonApplication {
pname = "project";
version = (final.lib.importTOML ./pyproject.toml).project.version;
pyproject = true;
src = self;
build-system = with python3.pkgs; [ setuptools ];
pythonImportsCheck = [ "project" ];
meta = with lib; {
description = "A Python project";
homepage = "https://git.belanyi.fr/ambroisie/project";
license = licenses.mit;
maintainers = with maintainers; [ ambroisie ];
};
};
};
};
} // futils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
pre-commit = git-hooks.lib.${system}.run {
src = self;
hooks = {
mypy = {
enable = true;
};
nixpkgs-fmt = {
enable = true;
};
ruff = {
enable = true;
};
ruff-format = {
enable = true;
};
};
};
in
{
checks = {
inherit (self.packages.${system}) project;
inherit pre-commit;
};
devShells = {
default = pkgs.mkShell {
inputsFrom = [
self.packages.${system}.project
];
packages = with pkgs; [
uv
self.checks.${system}.pre-commit.enabledPackages
];
inherit (pre-commit) shellHook;
};
};
packages = futils.lib.flattenTree {
default = pkgs.project;
inherit (pkgs) project;
};
});
}

View file

@ -0,0 +1,17 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "project"
version = "0.0.0"
description = "project description"
requires-python = ">=3.12"
dependencies = []
[project.scripts]
project = "project:main"
[dependency-groups]
dev = []

View file

@ -0,0 +1,2 @@
def main() -> None:
print("Hello, world!")