001-reference-board-viewer #1

Merged
jawz merged 43 commits from 001-reference-board-viewer into main 2025-11-02 15:58:57 -06:00
3 changed files with 241 additions and 181 deletions
Showing only changes of commit 07f4ea8277 - Show all commits

106
flake.nix
View File

@@ -6,37 +6,41 @@
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{ self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
# Core backend dependencies
fastapi
uvicorn
sqlalchemy
alembic
pydantic
pydantic-settings # Settings management
psycopg2 # PostgreSQL driver
# Auth & Security
python-jose
passlib
bcrypt # Password hashing backend for passlib
email-validator # Email validation for pydantic
# Image processing
pillow
# Storage
boto3
# HTTP & uploads
httpx
python-multipart
# Testing
pytest
pytest-cov
pytest-asyncio
]);
pythonEnv = pkgs.python3.withPackages (
ps: with ps; [
# Core backend dependencies
fastapi
uvicorn
sqlalchemy
alembic
pydantic
pydantic-settings # Settings management
psycopg2 # PostgreSQL driver
# Auth & Security
python-jose
passlib
bcrypt # Password hashing backend for passlib
email-validator # Email validation for pydantic
# Image processing
pillow
# Storage
boto3
# HTTP & uploads
httpx
python-multipart
# Testing
pytest
pytest-cov
pytest-asyncio
]
);
in
{
devShells.default = pkgs.mkShell {
@@ -98,6 +102,18 @@
# Apps - Scripts that can be run with `nix run`
apps = {
default = {
type = "app";
program = "${pkgs.writeShellScript "help" ''
echo "Available commands:"
echo " nix run .#lint - Run linting checks"
echo " nix run .#lint-fix - Auto-fix linting issues"
''}";
meta = {
description = "Show available commands";
};
};
# Unified linting for all code
lint = {
type = "app";
@@ -132,6 +148,9 @@
echo ""
echo " All linting checks passed!"
''}";
meta = {
description = "Run linting checks on backend and frontend code";
};
};
# Auto-fix linting issues
@@ -162,29 +181,48 @@
echo ""
echo " Auto-fix complete!"
''}";
meta = {
description = "Auto-fix linting issues in backend and frontend code";
};
};
};
# Package definitions (for production deployment)
packages = {
packages = rec {
# Backend package
backend = pkgs.python3Packages.buildPythonApplication {
pname = "webref-backend";
version = "1.0.0";
pyproject = true;
src = ./backend;
build-system = with pkgs.python3Packages; [
setuptools
];
propagatedBuildInputs = with pkgs.python3Packages; [
fastapi
uvicorn
sqlalchemy
alembic
pydantic
pydantic-settings
psycopg2
python-jose
passlib
pillow
boto3
httpx
python-multipart
email-validator
bcrypt
];
meta = {
description = "Reference Board Viewer - Backend API";
homepage = "https://github.com/yourusername/webref";
license = pkgs.lib.licenses.mit;
};
};
# Frontend package
@@ -192,7 +230,7 @@
pname = "webref-frontend";
version = "1.0.0";
src = ./frontend;
npmDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # Update after first build
npmDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # Update after first build
buildPhase = ''
npm run build
'';
@@ -200,7 +238,14 @@
mkdir -p $out
cp -r build/* $out/
'';
meta = {
description = "Reference Board Viewer - Frontend SPA";
homepage = "https://github.com/yourusername/webref";
license = pkgs.lib.licenses.mit;
};
};
default = backend;
};
# NixOS VM tests
@@ -208,4 +253,3 @@
}
);
}

View File

@@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }:
{ pkgs, ... }:
{
# Gitea Actions Runner Configuration
@@ -75,7 +75,7 @@
extraGroups = [ "docker" ];
};
users.groups.gitea-runner = {};
users.groups.gitea-runner = { };
# Allow runner to use Nix
nix.settings = {
@@ -83,7 +83,10 @@
trusted-users = [ "gitea-runner" ];
# Enable flakes for the runner
experimental-features = [ "nix-command" "flakes" ];
experimental-features = [
"nix-command"
"flakes"
];
# Optimize for CI performance
max-jobs = "auto";
@@ -109,4 +112,3 @@
};
};
}

View File

@@ -6,43 +6,47 @@
name = "webref-backend-integration";
nodes = {
machine = { config, pkgs, ... }: {
# PostgreSQL service
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [{
name = "webref";
ensureDBOwnership = true;
}];
authentication = ''
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
machine =
{ pkgs, ... }:
{
# PostgreSQL service
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [
{
name = "webref";
ensureDBOwnership = true;
}
];
authentication = ''
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
};
# MinIO service
services.minio = {
enable = true;
rootCredentialsFile = pkgs.writeText "minio-credentials" ''
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
'';
};
# Install required packages
environment.systemPackages = with pkgs; [
python3
python3Packages.pytest
python3Packages.fastapi
postgresql
curl
];
# Network configuration
networking.firewall.enable = false;
};
# MinIO service
services.minio = {
enable = true;
rootCredentialsFile = pkgs.writeText "minio-credentials" ''
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
'';
};
# Install required packages
environment.systemPackages = with pkgs; [
python3
python3Packages.pytest
python3Packages.fastapi
postgresql
curl
];
# Network configuration
networking.firewall.enable = false;
};
};
testScript = ''
@@ -71,34 +75,38 @@
name = "webref-full-stack";
nodes = {
machine = { config, pkgs, ... }: {
# PostgreSQL
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [{
name = "webref";
ensureDBOwnership = true;
}];
machine =
{ pkgs, ... }:
{
# PostgreSQL
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [
{
name = "webref";
ensureDBOwnership = true;
}
];
};
# MinIO
services.minio = {
enable = true;
rootCredentialsFile = pkgs.writeText "minio-credentials" ''
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
'';
};
environment.systemPackages = with pkgs; [
python3
curl
jq
];
networking.firewall.enable = false;
};
# MinIO
services.minio = {
enable = true;
rootCredentialsFile = pkgs.writeText "minio-credentials" ''
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
'';
};
environment.systemPackages = with pkgs; [
python3
curl
jq
];
networking.firewall.enable = false;
};
};
testScript = ''
@@ -125,14 +133,16 @@
name = "webref-performance";
nodes = {
machine = { config, pkgs, ... }: {
services.postgresql.enable = true;
services.minio.enable = true;
machine =
{ pkgs, ... }:
{
services.postgresql.enable = true;
services.minio.enable = true;
environment.systemPackages = with pkgs; [
python3
];
};
environment.systemPackages = with pkgs; [
python3
];
};
};
testScript = ''
@@ -148,28 +158,32 @@
name = "webref-security";
nodes = {
machine = { config, pkgs, ... }: {
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [{
name = "webref";
ensureDBOwnership = true;
}];
};
machine =
{ pkgs, ... }:
{
services.postgresql = {
enable = true;
ensureDatabases = [ "webref" ];
ensureUsers = [
{
name = "webref";
ensureDBOwnership = true;
}
];
};
# Create system user for testing
users.users.webref = {
isSystemUser = true;
group = "webref";
};
users.groups.webref = {};
# Create system user for testing
users.users.webref = {
isSystemUser = true;
group = "webref";
};
users.groups.webref = { };
environment.systemPackages = with pkgs; [
python3
nmap
];
};
environment.systemPackages = with pkgs; [
python3
nmap
];
};
};
testScript = ''