wowzers #1

Merged
cry merged 6 commits from cry/wa2k.com:main into main 2026-03-14 16:54:38 +10:00
7 changed files with 275 additions and 0 deletions

View file

@ -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 &
```

43
flake.lock generated Normal file
View file

@ -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
}

68
flake.nix Normal file
View file

@ -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;
};
});
};
}

49
nixos/default.nix Normal file
View file

@ -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;
};
};
};
};
}

35
scripts/serve Executable file
View file

@ -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[@]}"

0
www/css/style.css Normal file
View file

36
www/index.html Normal file
View file

@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>idk chat</title>
<!-- !! Favicon !! -->
<!-- <link rel="icon" href="imgs/favicon/favicon.ico" /> -->
<!-- Styling -->
<link type="text/css" rel="stylesheet" href="css/style.css">
</head>
<body>
<pre>
&lt;-- ` ' --&gt;
&lt;-- ;,,, ` ' ,,,; --&gt;
&lt;-- `CRY6666bo. : : .od8888CRY' --&gt;
&lt;-- 888IO8DO88b. : : .d8888I8DO88 --&gt;
&lt;-- 8LOVET' `Y8b. ` ' .d8Y' `TLOVE8 --&gt;
&lt;-- jYOUM! .db. Yb. ' ' .dY .db. !MYOUk --&gt;
&lt;-- `888 Y88Y `q ( ) p' Y88Y 888' --&gt;
&lt;-- 8SOb '" ,', "' dSO8 --&gt;
&lt;-- j8plEASEYgr"' ':' `"?gpYplEASESk --&gt;
&lt;-- 'Y' .8' d' 'b '8. 'Y' --&gt;
&lt;-- ! .8' db d'; ;`b db '8. ! --&gt;
&lt;-- d88 `' 8 ; ; 8 `' 88b --&gt;
&lt;-- d88Ib .g8 ',' 8g. dI88b --&gt;
&lt;-- :888LOVE88Y' 'Y88LOVE888: --&gt;
&lt;-- '! YpME888' `888MEpY !' --&gt;
&lt;-- '8Y `Y Y' Y8' --&gt;
&lt;-- Y Y --&gt;
&lt;-- ! ! --&gt;
</pre>
</body>
</html>