From 7640fd995aca24e7e72975b52a4e233d2e9c75c5 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:12:39 +1000 Subject: [PATCH 1/6] add nix compatible build environment --- README.md | 12 +++++++++ flake.lock | 43 ++++++++++++++++++++++++++++++ flake.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++++ nixos/default.nix | 25 +++++++++++++++++ scripts/serve | 35 ++++++++++++++++++++++++ www/css/style.css | 0 www/index.html | 36 +++++++++++++++++++++++++ 7 files changed, 219 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nixos/default.nix create mode 100755 scripts/serve create mode 100644 www/css/style.css create mode 100644 www/index.html diff --git a/README.md b/README.md index e69de29..c3778ad 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,12 @@ +# Wowzers what a cool website! +Source code for da website o_O + +### Local Development +>[!WARNING] +> My computers run NixOS so deployment relies on this fact +> If you don't have Nix see the [[#Without Nix|non-nix section]]. + +```bash +$ nix develop +nix-shell$ ./serve & +``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b7e4a36 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1754292888, + "narHash": "sha256-1ziydHSiDuSnaiPzCQh1mRFBsM2d2yRX9I+5OPGEmIE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce01daebf8489ba97bd1609d185ea276efdeb121", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ccc70c2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,68 @@ +{ + description = "ooni's cool website ohmahhhgawwww"; + + inputs = { + systems.url = "github:nix-systems/default"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + }; + + outputs = { + self, + nixpkgs, + ... + } @ inputs: let + systems = import inputs.systems; + + mkPkgs = pkgs: system: + import pkgs { + inherit system; + allowUnfree = false; + allowBroken = false; + overlays = builtins.attrValues self.overlays or {}; + }; + + forAllSystems = f: + nixpkgs.lib.genAttrs systems (system: + f rec { + inherit system; + inherit (pkgs) lib; + pkgs = mkPkgs nixpkgs system; + }); + in { + overlays.default = self: super: { + wa2k-website = super.stdenv.mkDerivation { + name = "wa2k.com"; + src = ./.; + + installPhase = '' + mkdir -p $out + cp -r www $out/ + ''; + }; + }; + + nixosModules = rec { + default = wa2k; + wa2k = import ./nixos; + }; + + checks = self.packages; + packages = forAllSystems ({pkgs, ...}: rec { + inherit (pkgs) wa2k-website; + default = wa2k-website; + }); + + devShells = forAllSystems ({pkgs, ...}: let + devPackages = with pkgs; [ + # dev local server + simple-http-server + ]; + in { + default = pkgs.mkShell { + name = "wa2k.com"; + shell = "${pkgs.bash}/bin/bash"; + packages = devPackages; + }; + }); + }; +} diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..f4ebff3 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,25 @@ +{ + config, + pkgs, + lib, + ... +}: let + cfg = config.services.wa2k; +in { + imports = [./wa2k]; + + networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall [cfg.port]; + + # REF: https://nixos.wiki/wiki/Static_Web_Server + services.static-web-server = { + enable = true; + listen = "[::]:${cfg.port}"; + root = "${pkgs.wa2k-website}/www"; + + configuration = { + general = { + directory-listing = false; + }; + }; + }; +} diff --git a/scripts/serve b/scripts/serve new file mode 100755 index 0000000..0677a39 --- /dev/null +++ b/scripts/serve @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Required Binaries: +# | simple-http-server +# | sass + +# ===== Configuration ===== # +ADDR="127.0.0.1" # bind address +PORT="8000" # bind port +WEBROOT="www" # root web directory +USE_INDEX=true +NO_CACHE=true +declare -a SRV_ARGS=() + +function host { + local args=( "$@" ) + # Apply Flags + if [[ "$NO_CACHE" == true ]]; then + args+=("--nocache") + fi + if [[ "$USE_INDEX" == true ]]; then + args+=("--index") + fi + + # Apply Options + args+=(--ip "$ADDR" --port "$PORT") + + simple-http-server "${args[@]}" "$@" -- "$WEBROOT" +} + +# trap cleanup EXIT +set -ueo pipefail +set -x + +# host dev server +host "${SRV_ARGS[@]}" diff --git a/www/css/style.css b/www/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..ea981ba --- /dev/null +++ b/www/index.html @@ -0,0 +1,36 @@ + + + + + idk chat + + + + + + + + + +
+ <--                `         '                -->
+<-- ;,,,             `       '             ,,,; -->
+<-- `CRY6666bo.       :     :       .od8888CRY' -->
+  <-- 888IO8DO88b.     :   :     .d8888I8DO88 -->
+  <-- 8LOVET'  `Y8b.   `   '   .d8Y'  `TLOVE8 -->
+ <-- jYOUM!  .db.  Yb. '   ' .dY  .db.  !MYOUk -->
+   <-- `888  Y88Y    `q ( ) p'    Y88Y  888' -->
+    <-- 8SOb  '"        ,',        "'  dSO8 -->
+   <-- j8plEASEYgr"'    ':'   `"?gpYplEASESk -->
+     <-- 'Y'   .8'     d' 'b     '8.   'Y' -->
+      <-- !   .8' db  d'; ;`b  db '8.   ! -->
+         <-- d88  `'  8 ; ; 8  `'  88b -->
+        <-- d88Ib   .g8 ',' 8g.   dI88b -->
+       <-- :888LOVE88Y'     'Y88LOVE888: -->
+       <-- '! YpME888'       `888MEpY !' -->
+          <-- '8Y  `Y         Y'  Y8' -->
+           <-- Y                   Y -->
+           <-- !                   ! -->
+    
+ + From 4d8b6860943c9b146ee202bfdb43784b44c37bb6 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:14:53 +1000 Subject: [PATCH 2/6] nix is scary!! --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c3778ad..6bbdfa4 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ Source code for da website o_O ### Local Development >[!WARNING] -> My computers run NixOS so deployment relies on this fact -> If you don't have Nix see the [[#Without Nix|non-nix section]]. +> This project is packaged using Nix, it's easier to work it this way :3 ```bash $ nix develop From 6be517516cad6d6f155e78a7f48bece0eceeceb8 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:25:55 +1000 Subject: [PATCH 3/6] add options.services.wa2k --- nixos/default.nix | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/nixos/default.nix b/nixos/default.nix index f4ebff3..bcc507a 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -4,21 +4,45 @@ lib, ... }: let + inherit (lib) mkEnableOption mkOption types; + cfg = config.services.wa2k; in { - imports = [./wa2k]; + options.services.wa2k = { + enable = mkEnableOption "webserver for wa2k.com"; - networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall [cfg.port]; + port = mkOption { + types = types.port; + default = 80; + example = 8080; + description = '' + The listening port on localhost to bind the wa2k.com server to. + ''; + }; - # REF: https://nixos.wiki/wiki/Static_Web_Server - services.static-web-server = { - enable = true; - listen = "[::]:${cfg.port}"; - root = "${pkgs.wa2k-website}/www"; + openFirewall = mkOption { + types = types.bool; + default = false; + example = true; + description = '' + Whether the wa2k listening port should be automatically opened in the system's firewall. + ''; + }; + }; - configuration = { - general = { - directory-listing = false; + config = lib.mkIf cfg.enable { + networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall [cfg.port]; + + # REF: https://nixos.wiki/wiki/Static_Web_Server + services.static-web-server = { + enable = true; + listen = "[::]:${cfg.port}"; + root = "${pkgs.wa2k-website}/www"; + + configuration = { + general = { + directory-listing = false; + }; }; }; }; From 49f2a8b48d62ff8ac05987e5b1db063d62224383 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:49:15 +1000 Subject: [PATCH 4/6] fix my oopid mistakes --- nixos/default.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nixos/default.nix b/nixos/default.nix index bcc507a..045307a 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -12,8 +12,8 @@ in { enable = mkEnableOption "webserver for wa2k.com"; port = mkOption { - types = types.port; - default = 80; + type = types.port; + default = 8080; example = 8080; description = '' The listening port on localhost to bind the wa2k.com server to. @@ -21,7 +21,7 @@ in { }; openFirewall = mkOption { - types = types.bool; + type = types.bool; default = false; example = true; description = '' @@ -30,13 +30,13 @@ in { }; }; - config = lib.mkIf cfg.enable { - networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall [cfg.port]; + config = { + networking.firewall.allowedTCPPorts = lib.optional (cfg.enable && cfg.openFirewall) cfg.port; # REF: https://nixos.wiki/wiki/Static_Web_Server services.static-web-server = { - enable = true; - listen = "[::]:${cfg.port}"; + enable = cfg.enable; + listen = "[::]:${builtins.toString cfg.port}"; root = "${pkgs.wa2k-website}/www"; configuration = { From ad9ca4118ceb2990fa9a9324d1638314729fae0c Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:49:20 +1000 Subject: [PATCH 5/6] add usage guide --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 6bbdfa4..03e2492 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,40 @@ # Wowzers what a cool website! Source code for da website o_O +### Using +First add a the wa2k flake as an input: +```nix +# in flake.nix +inputs = { + wa2k = { + # url = "git+https://tearforge.net/cry/wa2k.com"; + url = "/home/me/test/wa2k"; + inputs = { + systems.follows = "systems"; + nixpkgs.follows = "nixpkgs"; + }; + }; +}; +``` + +Then ensure `wa2k.nixosModules.default` is imported and `wa2k.overlays.default` is used: +```nix +# in configuration.nix +imports = [ + inputs.wa2k.nixosModules.default +]; + +nixpkgs.overlays = [ + inputs.wa2k.overlays.default +]; + +services.wa2k = { + enable = true; + port = 8080; + openFirewall = true; +}; +``` + ### Local Development >[!WARNING] > This project is packaged using Nix, it's easier to work it this way :3 From 5fee4396ac0d23b471475185eca586e2130088f6 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 14 Mar 2026 16:49:54 +1000 Subject: [PATCH 6/6] chat am i stupid? --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 03e2492..f5511f0 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ First add a the wa2k flake as an input: # in flake.nix inputs = { wa2k = { - # url = "git+https://tearforge.net/cry/wa2k.com"; - url = "/home/me/test/wa2k"; + url = "git+https://tearforge.net/cry/wa2k.com"; inputs = { systems.follows = "systems"; nixpkgs.follows = "nixpkgs";