initial commit
All checks were successful
Deploy docs / build-and-deploy (push) Successful in 3s

This commit is contained in:
sid 2026-02-23 20:34:35 +01:00
commit 95a533c876
451 changed files with 18255 additions and 0 deletions

View file

@ -0,0 +1,23 @@
name: Python Nix Pipeline
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Nix
uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run nix flake check
run: nix flake check

29
templates/dev/py-hello/.gitignore vendored Normal file
View file

@ -0,0 +1,29 @@
# Byte-compiled Python files
*.py[cod]
__pycache__/
# Distribution / packaging
.Python
*.egg
*.egg-info/
.coverage
.htmlcov/
.pytest_cache/
.tox/
.venv/
ENV/
build/
dist/
env.bak/
env/
venv.bak/
venv/
# IDE/editor files
*.sublime-project
*.sublime-workspace
.idea/
.vscode/
# Nix-related files
result

View file

@ -0,0 +1,131 @@
{
description = "A hello world template in Python";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
...
}:
let
pname = "hello-world";
version = "0.1.0";
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (
system:
import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
}
);
in
{
overlays.default =
final: prev:
let
python = final.python312;
in
{
"${pname}" = python.pkgs.buildPythonApplication {
inherit pname version;
pyproject = true;
src = ./.;
build-system = [
python.pkgs.setuptools
python.pkgs.wheel
];
dependencies = with python.pkgs; [
];
pythonImportsCheck = [
"hello_world"
];
};
};
packages = forAllSystems (system: {
default = nixpkgsFor.${system}."${pname}";
"${pname}" = nixpkgsFor.${system}."${pname}";
});
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
python = pkgs.python312;
in
{
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
(python.withPackages (
p: with p; [
]
))
];
};
venv = pkgs.mkShell {
buildInputs = [
python
]
++ [
(python.withPackages (
p: with p; [
pip
]
))
];
shellHook = ''
python -m venv .venv
source .venv/bin/activate
pip install .
'';
};
}
);
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
config = self.checks.${system}.pre-commit-check.config;
inherit (config) package configFile;
script = ''
${pkgs.lib.getExe package} run --all-files --config ${configFile}
'';
in
pkgs.writeShellScriptBin "pre-commit-run" script
);
checks = forAllSystems (system: {
# TODO: Add integration test
pre-commit-check = self.inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt = {
enable = true;
};
# TODO: Add Python format check
};
};
});
};
}

View file

@ -0,0 +1,14 @@
[build-system]
requires = ["setuptools>=75", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "hello-world"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
]
[project.scripts]
hello-world = "hello_world.__main__:main"

View file

@ -0,0 +1 @@
# This file is intentionally empty.

View file

@ -0,0 +1,5 @@
def main():
print("Hello, world!")
if __name__ == "__main__":
main()