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

View File

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

View File

@@ -6,43 +6,47 @@
name = "webref-backend-integration"; name = "webref-backend-integration";
nodes = { nodes = {
machine = { config, pkgs, ... }: { machine =
# PostgreSQL service { pkgs, ... }:
services.postgresql = { {
enable = true; # PostgreSQL service
ensureDatabases = [ "webref" ]; services.postgresql = {
ensureUsers = [{ enable = true;
name = "webref"; ensureDatabases = [ "webref" ];
ensureDBOwnership = true; ensureUsers = [
}]; {
authentication = '' name = "webref";
local all all trust ensureDBOwnership = true;
host all all 127.0.0.1/32 trust }
host all all ::1/128 trust ];
''; 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 = '' testScript = ''
@@ -71,34 +75,38 @@
name = "webref-full-stack"; name = "webref-full-stack";
nodes = { nodes = {
machine = { config, pkgs, ... }: { machine =
# PostgreSQL { pkgs, ... }:
services.postgresql = { {
enable = true; # PostgreSQL
ensureDatabases = [ "webref" ]; services.postgresql = {
ensureUsers = [{ enable = true;
name = "webref"; ensureDatabases = [ "webref" ];
ensureDBOwnership = true; 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 = '' testScript = ''
@@ -125,14 +133,16 @@
name = "webref-performance"; name = "webref-performance";
nodes = { nodes = {
machine = { config, pkgs, ... }: { machine =
services.postgresql.enable = true; { pkgs, ... }:
services.minio.enable = true; {
services.postgresql.enable = true;
services.minio.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
python3 python3
]; ];
}; };
}; };
testScript = '' testScript = ''
@@ -148,28 +158,32 @@
name = "webref-security"; name = "webref-security";
nodes = { nodes = {
machine = { config, pkgs, ... }: { machine =
services.postgresql = { { pkgs, ... }:
enable = true; {
ensureDatabases = [ "webref" ]; services.postgresql = {
ensureUsers = [{ enable = true;
name = "webref"; ensureDatabases = [ "webref" ];
ensureDBOwnership = true; ensureUsers = [
}]; {
}; name = "webref";
ensureDBOwnership = true;
}
];
};
# Create system user for testing # Create system user for testing
users.users.webref = { users.users.webref = {
isSystemUser = true; isSystemUser = true;
group = "webref"; group = "webref";
}; };
users.groups.webref = {}; users.groups.webref = { };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
python3 python3
nmap nmap
]; ];
}; };
}; };
testScript = '' testScript = ''