From b768ad0ca4208e8b3588b881067c43d85246e967 Mon Sep 17 00:00:00 2001
From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com>
Date: Fri, 2 Oct 2026 11:23:45 -0500
Subject: experiment with modular services; more unix domain sockets, clean up
old code
---
modules/services/nixos/jta/assignments.html | 148 ------------------------
modules/services/nixos/jta/default.nix | 48 --------
modules/services/nixos/jta/go.mod | 5 -
modules/services/nixos/jta/go.sum | 2 -
modules/services/nixos/jta/index.html | 134 ----------------------
modules/services/nixos/jta/main.go | 142 -----------------------
modules/services/nixos/jta/md_template.html | 11 --
modules/services/nixos/jta/pkg.nix | 6 -
modules/services/nixos/jta/style.css | 172 ----------------------------
9 files changed, 668 deletions(-)
delete mode 100644 modules/services/nixos/jta/assignments.html
delete mode 100644 modules/services/nixos/jta/default.nix
delete mode 100644 modules/services/nixos/jta/go.mod
delete mode 100644 modules/services/nixos/jta/go.sum
delete mode 100644 modules/services/nixos/jta/index.html
delete mode 100644 modules/services/nixos/jta/main.go
delete mode 100644 modules/services/nixos/jta/md_template.html
delete mode 100644 modules/services/nixos/jta/pkg.nix
delete mode 100644 modules/services/nixos/jta/style.css
(limited to 'modules/services/nixos/jta')
diff --git a/modules/services/nixos/jta/assignments.html b/modules/services/nixos/jta/assignments.html
deleted file mode 100644
index 3031a29..0000000
--- a/modules/services/nixos/jta/assignments.html
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
- jta@ganymede
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/services/nixos/jta/default.nix b/modules/services/nixos/jta/default.nix
deleted file mode 100644
index 31f5bbd..0000000
--- a/modules/services/nixos/jta/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- pkgs,
- config,
- lib,
- ...
-}: let
- cfg = config.collinux.services.jta;
- package = pkgs.callPackage ./pkg.nix {};
-in {
- config = lib.mkIf cfg.enable {
- users.groups."jta" = {};
- users.users."jta" = {
- isSystemUser = true;
- group = "jta";
- extraGroups = ["fileserver"];
-
- home = "/var/lib/jta";
- createHome = true;
- homeMode = "755";
- };
-
- systemd.services."jta" = {
- restartIfChanged = true;
- wants = ["network-online.target" "caddy.service"];
- after = ["network-online.target" "caddy.service"];
-
- environment = {
- PORT = toString cfg.port;
- ROOT_DIR = "/media/jta";
- AUTH_PASSWORD_HASH = "550b6785c4bce2ab41a5e2eaa1eb43172d5abbd58237f1c78cd32cb190edc2c5"; # alfreddabuttlerwithtwots
- };
-
- serviceConfig = {
- User = "jta";
- Type = "simple";
-
- WorkingDirectory = "/var/lib/jta";
- ExecStart = "${package}/bin/jta";
- };
-
- wantedBy = ["multi-user.target"];
- };
-
- services.caddy.virtualHosts."jta.williamsfam.us.com".extraConfig = ''
- reverse_proxy 127.0.0.1:${toString cfg.port}
- '';
- };
-}
diff --git a/modules/services/nixos/jta/go.mod b/modules/services/nixos/jta/go.mod
deleted file mode 100644
index 8f27af1..0000000
--- a/modules/services/nixos/jta/go.mod
+++ /dev/null
@@ -1,5 +0,0 @@
-module git.ganymede/jta
-
-go 1.25.5
-
-require github.com/yuin/goldmark v1.8.2
diff --git a/modules/services/nixos/jta/go.sum b/modules/services/nixos/jta/go.sum
deleted file mode 100644
index 6a37955..0000000
--- a/modules/services/nixos/jta/go.sum
+++ /dev/null
@@ -1,2 +0,0 @@
-github.com/yuin/goldmark v1.8.2 h1:kEGpgqJXdgbkhcOgBxkC0X0PmoPG1ZyoZ117rDVp4zE=
-github.com/yuin/goldmark v1.8.2/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
diff --git a/modules/services/nixos/jta/index.html b/modules/services/nixos/jta/index.html
deleted file mode 100644
index 96b6f5f..0000000
--- a/modules/services/nixos/jta/index.html
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
- JTA Login
-
-
-
-
-
-
JTA Portal
-
Public landing page. Login is required to view assignments and all other pages.
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/services/nixos/jta/main.go b/modules/services/nixos/jta/main.go
deleted file mode 100644
index e7b5a0f..0000000
--- a/modules/services/nixos/jta/main.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package main
-
-import (
- "bytes"
- _ "embed"
- "html/template"
- "net/http"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/yuin/goldmark"
- "github.com/yuin/goldmark/extension"
-)
-
-// Configure Goldmark with GitHub Flavored Markdown
-var mdParser = goldmark.New(
- goldmark.WithExtensions(
- extension.GFM,
- ),
-)
-
-//go:embed md_template.html
-var mdTemplate string
-
-//go:embed style.css
-var styleCSS string
-
-//go:embed index.html
-var indexHTML string
-
-//go:embed assignments.html
-var assignmentsHTML string
-
-var pageTmpl = template.Must(template.New("md_template.html").Parse(mdTemplate))
-
-const authCookieName = "jta_auth"
-
-func isAuthenticated(w http.ResponseWriter, r *http.Request) bool {
- expectedHash := strings.TrimSpace(os.Getenv("AUTH_PASSWORD_HASH"))
- if expectedHash == "" {
- return false
- }
-
- // Try cookie first
- if cookie, err := r.Cookie(authCookieName); err == nil {
- providedHash := strings.TrimSpace(cookie.Value)
- if providedHash != "" && strings.EqualFold(providedHash, expectedHash) {
- return true
- }
- }
-
- // Fallback to URL parameter
- paramHash := strings.TrimSpace(r.URL.Query().Get(authCookieName))
- if paramHash != "" && strings.EqualFold(paramHash, expectedHash) {
- http.SetCookie(w, &http.Cookie{
- Name: authCookieName,
- Value: paramHash,
- Path: "/",
- HttpOnly: true, // Security: Protects against XSS cookie theft
- Secure: false, // Set to true if you are hosting over HTTPS
- SameSite: http.SameSiteLaxMode, // Prevents CSRF vulnerabilities
- })
- return true
- }
-
- return false
-}
-
-func serveMarkdown(w http.ResponseWriter, r *http.Request) {
- // Prevent path traversal
- clean := filepath.Clean(r.URL.Path)
- path := filepath.Join(rootDir, strings.TrimPrefix(clean, "/"))
-
- mdBytes, err := os.ReadFile(path)
- if err != nil {
- http.NotFound(w, r)
- return
- }
-
- var buf bytes.Buffer
- if err := mdParser.Convert(mdBytes, &buf); err != nil {
- http.Error(w, "failed to render markdown", 500)
- return
- }
-
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
-
- pageTmpl.Execute(w, map[string]template.HTML{
- "Content": template.HTML(buf.String()),
- })
-}
-
-var rootDir = "."
-
-func main() {
- if envRootDir := os.Getenv("ROOT_DIR"); envRootDir != "" {
- rootDir = envRootDir
- }
-
- fs := http.FileServer(http.Dir(rootDir))
- port := os.Getenv("PORT")
- if port == "" {
- port = "8080"
- }
-
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path == "/" || r.URL.Path == "/index.html" {
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- w.Write([]byte(indexHTML))
- return
- }
-
- if r.URL.Path == "/style.css" {
- w.Header().Set("Content-Type", "text/css; charset=utf-8")
- w.Write([]byte(styleCSS))
- return
- }
-
- if !isAuthenticated(w, r) {
- http.Error(w, "unauthorized", http.StatusUnauthorized)
- return
- }
-
- if r.URL.Path == "/assignments" || r.URL.Path == "/assignments.html" {
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- w.Write([]byte(assignmentsHTML))
- return
- }
-
- // Intercept markdown files
- if strings.HasSuffix(r.URL.Path, ".md") {
- serveMarkdown(w, r)
- return
- }
-
- // Otherwise serve normally
- fs.ServeHTTP(w, r)
- })
-
- http.ListenAndServe(":"+port, nil)
-}
diff --git a/modules/services/nixos/jta/md_template.html b/modules/services/nixos/jta/md_template.html
deleted file mode 100644
index daa57b7..0000000
--- a/modules/services/nixos/jta/md_template.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- JTA
-
-
-
- {{.Content}}
-
-
diff --git a/modules/services/nixos/jta/pkg.nix b/modules/services/nixos/jta/pkg.nix
deleted file mode 100644
index c8f7d77..0000000
--- a/modules/services/nixos/jta/pkg.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{pkgs ? import {system = "x86_64-linux";}, ...}:
-pkgs.buildGoModule {
- name = "jta";
- src = ./.;
- vendorHash = "sha256-aeJYO52ALbGxyTFPw6eGCmPlmuCvbXEoX9gcXatN29E=";
-}
diff --git a/modules/services/nixos/jta/style.css b/modules/services/nixos/jta/style.css
deleted file mode 100644
index ec09ca9..0000000
--- a/modules/services/nixos/jta/style.css
+++ /dev/null
@@ -1,172 +0,0 @@
-:root {
- --bg: #0f172a;
- --card: #1e293b;
- --accent: #22c55e;
- --text: #e2e8f0;
- --text-soft: #cbd5e1;
- --muted: #94a3b8;
- --border: #334155;
-
- --font-body: "Avenir Next", "Segoe UI", "Noto Sans", "Helvetica Neue", sans-serif;
- --font-heading: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
- --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
-
- --step--1: clamp(0.88rem, 0.86rem + 0.12vw, 0.96rem);
- --step-0: clamp(1rem, 0.98rem + 0.16vw, 1.08rem);
- --step-1: clamp(1.14rem, 1.08rem + 0.26vw, 1.28rem);
- --step-2: clamp(1.3rem, 1.2rem + 0.45vw, 1.56rem);
- --step-3: clamp(1.7rem, 1.45rem + 1.1vw, 2.25rem);
-}
-
-/* Base layout */
-body {
- font-family: var(--font-body);
- font-size: var(--step-0);
- background: var(--bg);
- color: var(--text);
- max-width: 850px;
- margin: 2rem auto;
- padding: 1.5rem;
- line-height: 1.7;
- text-rendering: optimizeLegibility;
-}
-
-/* Headings */
-h1 {
- font-family: var(--font-heading);
- font-size: var(--step-3);
- line-height: 1.15;
- font-weight: 700;
- letter-spacing: -0.02em;
- text-align: center;
- margin: 0 0 1.25rem;
-}
-
-h2 {
- font-family: var(--font-heading);
- margin-top: 2.25rem;
- margin-bottom: 0.75rem;
- font-size: var(--step-2);
- line-height: 1.25;
- letter-spacing: -0.01em;
-}
-
-h3 {
- font-family: var(--font-heading);
- margin-top: 1.5rem;
- margin-bottom: 0.6rem;
- font-size: var(--step-1);
- line-height: 1.3;
- color: var(--text-soft);
-}
-
-/* Text */
-p {
- color: var(--text);
- margin-bottom: 1rem;
- max-width: 65ch;
-}
-
-/* Ordered list (questions) */
-ol {
- padding-left: 1.2rem;
- max-width: 65ch;
-}
-
-/* Answer list */
-ul {
- list-style: none;
- padding-left: 1.2rem;
- max-width: 65ch;
-}
-
-ul li {
- display: flex;
- align-items: flex-start;
- gap: 0.6rem;
- padding: 0.35rem 0.4rem;
- border-radius: 8px;
- transition: background 0.15s ease;
-}
-
-/* Checkbox styling */
-input[type="checkbox"] {
- accent-color: var(--accent);
- transform: scale(1.2);
- margin-top: 0.2rem;
- pointer-events: none;
-}
-
-/* Correct answers */
-li:has(input[type="checkbox"]:checked) {
- color: #86efac;
- font-weight: 500;
-}
-
-/* Code blocks */
-pre {
- font-family: var(--font-mono);
- font-size: var(--step--1);
- line-height: 1.6;
- background: #020617;
- padding: 1rem;
- border-radius: 10px;
- overflow-x: auto;
- margin: 1rem 0;
- max-width: 65ch;
-}
-
-code {
- font-family: var(--font-mono);
- font-size: 0.95em;
- background: #020617;
- padding: 2px 6px;
- border-radius: 6px;
-}
-
-img {
- display: block;
- max-width: 100%;
- height: auto;
- margin: 1rem 0;
- border-radius: 10px;
-}
-
-p > img,
-li > img {
- margin: 0.75rem 0;
-}
-
-a > img {
- transition: transform 0.15s ease, box-shadow 0.15s ease;
-}
-
-a:hover > img {
- transform: translateY(-1px);
- box-shadow: 0 8px 20px rgba(2, 6, 23, 0.45);
-}
-
-img[width],
-img[height] {
- width: auto;
- height: auto;
- max-width: 100%;
-}
-
-/* Links */
-a {
- color: #93c5fd;
- text-decoration-line: underline;
- text-decoration-thickness: 2px;
- text-underline-offset: 0.14em;
- text-decoration-color: rgba(147, 197, 253, 0.45);
-}
-
-a:hover {
- text-decoration-color: currentColor;
-}
-
-/* Optional: make everything feel tighter and nicer */
-* {
- box-sizing: border-box;
-}
--
cgit v1.3.1