diff --git a/README.md b/README.md index e69de29..f5511f0 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,44 @@ +# 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"; + 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 + +```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..045307a --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,49 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption types; + + cfg = config.services.wa2k; +in { + options.services.wa2k = { + enable = mkEnableOption "webserver for wa2k.com"; + + port = mkOption { + type = types.port; + default = 8080; + example = 8080; + description = '' + The listening port on localhost to bind the wa2k.com server to. + ''; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether the wa2k listening port should be automatically opened in the system's firewall. + ''; + }; + }; + + 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 = cfg.enable; + listen = "[::]:${builtins.toString 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 -->
+           <-- !                   ! -->
+    
+ +