summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2024-01-13 00:35:13 +0100
committerstuebinm2024-01-13 00:35:13 +0100
commitb2fc20fe8080e4c083b08354afdce287a91de0b7 (patch)
tree9cd539dd9b2f11515d8bc36ff86fb81256ba9d92
parent3c752004c4a49319aa93eb586e77b563811a1217 (diff)
nomsable webring
(just messing around for now)
-rw-r--r--flake.nix2
-rw-r--r--flora/services/nginx.nix11
-rw-r--r--ilex/configuration.nix13
-rw-r--r--pkgs/nomsring/.gitignore1
-rw-r--r--pkgs/nomsring/Main.hs32
-rw-r--r--pkgs/nomsring/default.nix12
-rw-r--r--pkgs/nomsring/nomsring.cabal19
-rw-r--r--pkgs/overlay.nix2
8 files changed, 90 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 3ee0949..81e9768 100644
--- a/flake.nix
+++ b/flake.nix
@@ -141,7 +141,7 @@
kijetesantakaluotokieni showrt isabelle-utils isabat
travelynx crs-tracker crs-php bahnhof-name matrix-to
hikari_unstable heartwood radicle-interface radicle-tui
- inweb;
+ inweb nomsring;
};
nixosModules = { glitchtip = import ./modules/glitchtip.nix; };
diff --git a/flora/services/nginx.nix b/flora/services/nginx.nix
index 7c792ba..1d95255 100644
--- a/flora/services/nginx.nix
+++ b/flora/services/nginx.nix
@@ -20,5 +20,16 @@
forceSSL = true;
locations."/".root = ../../pkgs/nomsing;
};
+ virtualHosts."webring.noms.ing" = {
+ enableACME = true;
+ forceSSL = true;
+ locations."~ (.*)".extraConfig = ''
+ fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
+ include ${pkgs.nginx}/conf/fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME ${lib.getExe pkgs.nomsring};
+ fastcgi_param PATH_INFO $1;
+ '';
+ };
};
+ services.fcgiwrap.enable = true;
}
diff --git a/ilex/configuration.nix b/ilex/configuration.nix
index e87af9a..0f0e528 100644
--- a/ilex/configuration.nix
+++ b/ilex/configuration.nix
@@ -83,6 +83,19 @@
# };
+ # for testing nomsring
+ # services.fcgiwrap.enable = true;
+ # services.nginx = {
+ # enable = true;
+ # virtualHosts.default = {
+ # locations."~ (.*)".extraConfig = ''
+ # fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
+ # include ${pkgs.nginx}/conf/fastcgi_params;
+ # fastcgi_param SCRIPT_FILENAME /tmp/dingsda;
+ # fastcgi_param PATH_INFO $1;
+ # '';
+ # };
+ # };
services.tlp = {
enable = true;
settings = {
diff --git a/pkgs/nomsring/.gitignore b/pkgs/nomsring/.gitignore
new file mode 100644
index 0000000..b5e3679
--- /dev/null
+++ b/pkgs/nomsring/.gitignore
@@ -0,0 +1 @@
+dist-newstyle/*
diff --git a/pkgs/nomsring/Main.hs b/pkgs/nomsring/Main.hs
new file mode 100644
index 0000000..5c70491
--- /dev/null
+++ b/pkgs/nomsring/Main.hs
@@ -0,0 +1,32 @@
+module Main where
+
+import Network.CGI (CGIResult, runCGI, getInput, output, redirect, pathInfo, CGI, outputNotFound, liftIO)
+import Data.CircularList (CList, fromList, rotR, rotateTo, focus, rotL)
+import Data.Maybe(fromJust, fromMaybe)
+import Data.Functor ((<&>))
+
+webring :: CList String
+webring = fromList
+ [ "stuebinm.eu"
+ , "nwex.de"
+ ]
+
+main :: IO ()
+main = runCGI $ do
+ path <- pathInfo
+ case path of
+ "/" -> output "nomsable websites"
+ "/next" -> rotate True
+ "/previous" -> rotate False
+ _ -> outputNotFound path
+
+rotate :: Bool -> CGI CGIResult
+rotate backwards = do
+ from <- getInput "from" <&> fromMaybe (focus' webring)
+ case rotateTo from webring of
+ Nothing -> redirect ("https://" <> focus' webring)
+ Just ring -> redirect ("https://" <> focus' (step ring))
+ where step = if backwards then rotL else rotR
+
+focus' :: CList c -> c
+focus' = fromJust . focus
diff --git a/pkgs/nomsring/default.nix b/pkgs/nomsring/default.nix
new file mode 100644
index 0000000..c7ad358
--- /dev/null
+++ b/pkgs/nomsring/default.nix
@@ -0,0 +1,12 @@
+{ mkDerivation, base, cgi, data-clist, lib }:
+mkDerivation {
+ pname = "nomsring";
+ version = "0.1.0.0";
+ src = ./.;
+ isLibrary = false;
+ isExecutable = true;
+ executableHaskellDepends = [ base cgi data-clist ];
+ description = "noms noms";
+ license = lib.licenses.bsd3;
+ mainProgram = "nomsring";
+}
diff --git a/pkgs/nomsring/nomsring.cabal b/pkgs/nomsring/nomsring.cabal
new file mode 100644
index 0000000..0ee04a3
--- /dev/null
+++ b/pkgs/nomsring/nomsring.cabal
@@ -0,0 +1,19 @@
+cabal-version: 3.0
+name: nomsring
+version: 0.1.0.0
+synopsis: noms noms
+description: a webring for nomsable websites
+license: BSD-3-Clause
+author: stuebinm
+maintainer: stuebinm@disroot.org
+
+common warnings
+ ghc-options: -Wall
+
+executable nomsring
+ import: warnings
+ main-is: Main.hs
+ build-depends: base ^>=4.17.2.1
+ , cgi ^>=3001.5
+ , data-clist ^>= 0.2
+ default-language: GHC2021
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
index 5da88f1..671a7c2 100644
--- a/pkgs/overlay.nix
+++ b/pkgs/overlay.nix
@@ -116,7 +116,7 @@ in
in
haskellPkgs.callPackage pkg {};
-
+ nomsring = super.haskellPackages.callPackage ./nomsring {};
#### sporadically maintained / updated ####