1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00

3 Commits

Author SHA1 Message Date
e3f4c34ac3 ical-ephemeris: remove 2025-12-13 22:41:55 +01:00
3a9bfab5fd ful: remove openapi joke 2025-12-13 22:40:20 +01:00
fc238008c8 update 2025-12-13 22:37:47 +01:00
9 changed files with 51 additions and 383 deletions

View File

@@ -37,7 +37,7 @@ in {
};
scripts = [
pkgs.mpvScripts.quality-menu
niveumPackages.mpv-visualizer
pkgs.mpvScripts.visualizer
];
};
};

217
flake.lock generated
View File

@@ -53,43 +53,6 @@
"type": "github"
}
},
"almanac": {
"flake": false,
"locked": {
"lastModified": 1640984494,
"narHash": "sha256-xxbrGJtRK6wzOR09vGPqoUvnY5f0h6hn6Uecy331Zhw=",
"owner": "lfborjas",
"repo": "almanac",
"rev": "72931bd9accefccd2df59d9d64a6cbb91f2d5f17",
"type": "github"
},
"original": {
"owner": "lfborjas",
"repo": "almanac",
"type": "github"
}
},
"astro-calendar": {
"inputs": {
"almanac": "almanac",
"nixpkgs": "nixpkgs_4",
"swiss-ephemeris": "swiss-ephemeris",
"swisseph": "swisseph"
},
"locked": {
"lastModified": 1759827606,
"narHash": "sha256-JunaXkzalZtQYjGxJrMGYDEgOwullKLnpAFj/SaJaKI=",
"owner": "kmein",
"repo": "astro-calendar",
"rev": "f1579f087ee49e4c6a3bcf130b20738123f8616a",
"type": "github"
},
"original": {
"owner": "kmein",
"repo": "astro-calendar",
"type": "github"
}
},
"autorenkalender": {
"inputs": {
"nixpkgs": [
@@ -345,7 +308,7 @@
},
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs_6",
"nixpkgs": "nixpkgs_4",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
@@ -648,25 +611,6 @@
"type": "github"
}
},
"ical-ephemeris": {
"inputs": {
"astro-calendar": "astro-calendar",
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1761309163,
"narHash": "sha256-x5BdTIoG/ANMhJJw+IMWLbdXJ7vTh3dou8zN4LCnTeU=",
"ref": "refs/heads/master",
"rev": "949682c2ec4da9a23c414a8ca8c039652cbbef0c",
"revCount": 22,
"type": "git",
"url": "ssh://gitea@code.kmein.de:22022/kfm/ical-ephemeris"
},
"original": {
"type": "git",
"url": "ssh://gitea@code.kmein.de:22022/kfm/ical-ephemeris"
}
},
"kellia-dictionary": {
"flake": false,
"locked": {
@@ -734,7 +678,7 @@
"menstruation-backend_2": {
"inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs_7"
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1765657254,
@@ -990,7 +934,7 @@
},
"nixinate_2": {
"inputs": {
"nixpkgs": "nixpkgs_8"
"nixpkgs": "nixpkgs_6"
},
"locked": {
"lastModified": 1742737607,
@@ -1119,38 +1063,6 @@
}
},
"nixpkgs_10": {
"locked": {
"lastModified": 1765186076,
"narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_11": {
"locked": {
"lastModified": 1760878510,
"narHash": "sha256-K5Osef2qexezUfs0alLvZ7nQFTGS9DL2oTVsIXsqLgs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e2a59a5b1a82f89f2c7e598302a9cacebb72a67",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_12": {
"locked": {
"lastModified": 1659446231,
"narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=",
@@ -1166,7 +1078,7 @@
"type": "github"
}
},
"nixpkgs_13": {
"nixpkgs_11": {
"locked": {
"lastModified": 1615532953,
"narHash": "sha256-SWpaGjrp/INzorEqMz3HLi6Uuk9I0KAn4YS8B4n3q5g=",
@@ -1210,11 +1122,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1758035966,
"narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=",
"lastModified": 1701436327,
"narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b",
"rev": "91050ea1e57e50388fa87a3302ba12d188ef723a",
"type": "github"
},
"original": {
@@ -1226,11 +1138,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1759381078,
"narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=",
"lastModified": 1701436327,
"narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee",
"rev": "91050ea1e57e50388fa87a3302ba12d188ef723a",
"type": "github"
},
"original": {
@@ -1241,38 +1153,6 @@
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1701436327,
"narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "91050ea1e57e50388fa87a3302ba12d188ef723a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_7": {
"locked": {
"lastModified": 1701436327,
"narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "91050ea1e57e50388fa87a3302ba12d188ef723a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1653060744,
"narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=",
@@ -1288,7 +1168,7 @@
"type": "github"
}
},
"nixpkgs_9": {
"nixpkgs_7": {
"locked": {
"lastModified": 1764983851,
"narHash": "sha256-y7RPKl/jJ/KAP/VKLMghMgXTlvNIJMHKskl8/Uuar7o=",
@@ -1304,6 +1184,38 @@
"type": "github"
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1765186076,
"narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1760878510,
"narHash": "sha256-K5Osef2qexezUfs0alLvZ7nQFTGS9DL2oTVsIXsqLgs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e2a59a5b1a82f89f2c7e598302a9cacebb72a67",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nmd": {
"flake": false,
"locked": {
@@ -1418,7 +1330,7 @@
"nur_2": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_10"
"nixpkgs": "nixpkgs_8"
},
"locked": {
"lastModified": 1765367248,
@@ -1545,12 +1457,11 @@
"coptic-dictionary": "coptic-dictionary",
"flake-utils": "flake-utils_3",
"home-manager": "home-manager_2",
"ical-ephemeris": "ical-ephemeris",
"menstruation-backend": "menstruation-backend_2",
"menstruation-telegram": "menstruation-telegram_2",
"nix-on-droid": "nix-on-droid_2",
"nixinate": "nixinate_2",
"nixpkgs": "nixpkgs_9",
"nixpkgs": "nixpkgs_7",
"nixpkgs-old": "nixpkgs-old_2",
"nixpkgs-unstable": "nixpkgs-unstable_2",
"nur": "nur_2",
@@ -1690,7 +1601,7 @@
"inputs": {
"buildbot-nix": "buildbot-nix",
"nix-writers": "nix-writers",
"nixpkgs": "nixpkgs_11"
"nixpkgs": "nixpkgs_9"
},
"locked": {
"lastModified": 1763891069,
@@ -1771,38 +1682,6 @@
"type": "github"
}
},
"swiss-ephemeris": {
"flake": false,
"locked": {
"lastModified": 1638583659,
"narHash": "sha256-EEgKk5DDkmICteFzFzXdvdGke7aPoJa6aQ228nAYieQ=",
"owner": "lfborjas",
"repo": "swiss-ephemeris",
"rev": "3094368f5f963e8756e89e3b3dd24b96796b8682",
"type": "github"
},
"original": {
"owner": "lfborjas",
"repo": "swiss-ephemeris",
"type": "github"
}
},
"swisseph": {
"flake": false,
"locked": {
"lastModified": 1757697308,
"narHash": "sha256-m2Qgzhsgrv0KyJin8UfNFJ8KL/HFfoN8AmCTlcirHXE=",
"owner": "aloistr",
"repo": "swisseph",
"rev": "3084917b5d2384af6fb928583552e0a299fb6d83",
"type": "github"
},
"original": {
"owner": "aloistr",
"repo": "swisseph",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
@@ -1899,7 +1778,7 @@
},
"telebots_2": {
"inputs": {
"nixpkgs": "nixpkgs_12"
"nixpkgs": "nixpkgs_10"
},
"locked": {
"lastModified": 1765657917,
@@ -2132,7 +2011,7 @@
"wallpaper-generator_2": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_13"
"nixpkgs": "nixpkgs_11"
},
"locked": {
"lastModified": 1615819231,

View File

@@ -27,7 +27,6 @@
voidrice.url = "github:Lukesmithxyz/voidrice";
wallpaper-generator.url = "github:pinpox/wallpaper-generator/v1.1";
wallpapers.url = "github:kmein/wallpapers";
ical-ephemeris.url = "git+ssh://gitea@code.kmein.de:22022/kfm/ical-ephemeris";
autorenkalender.inputs.nixpkgs.follows = "nixpkgs";
agenix.inputs.home-manager.follows = "home-manager";
@@ -224,7 +223,6 @@
systems/ful/configuration.nix
agenix.nixosModules.default
inputs.self.nixosModules.passport
inputs.ical-ephemeris.nixosModules.default
inputs.self.nixosModules.panoptikon
inputs.self.nixosModules.go-webring
inputs.self.nixosModules.htgen

View File

@@ -29,7 +29,7 @@
default = "daily";
};
loadCredential = lib.mkOption {
type = lib.types.listOf lib.types.string;
type = lib.types.listOf lib.types.str;
description = ''
This can be used to pass secrets to the systemd service without adding them to the nix store.
'';

View File

@@ -2,7 +2,6 @@
config,
pkgs,
lib,
inputs,
...
}: let
inherit (import ../../lib) kieran retiolumAddresses restic;
@@ -15,7 +14,6 @@ in {
./hledger.nix
./go-webring.nix
./gemini.nix
./ical-ephemeris.nix
./wallabag.nix
../../configs/monitoring.nix
../../configs/mycelium.nix
@@ -72,64 +70,6 @@ in {
];
};
users.users.servant = {
isSystemUser = true;
group = "servant";
};
users.groups.servant = {};
systemd.services.servant = {
enable = true;
environment.PORT = toString 18987;
environment.VIRTUAL_HOST = "https://openapiaiapi.kmein.de";
serviceConfig.ExecStart = pkgs.writers.writeHaskell "server" {
libraries = with pkgs.haskellPackages; [
servant
servant-server
servant-openapi3
servant-swagger-ui
servant-client
aeson
text
warp
uuid
lens
];
ghcArgs = ["-O3" "-threaded"];
} ./servant-openapi.hs;
serviceConfig.User = "servant";
serviceConfig.Group = "servant";
};
services.htgen.openapi-conversion = {
port = 18988;
script = ''. ${pkgs.writers.writeDash "openapi-conversion" ''
case "$Method $Request_URI" in
"GET /openapi-3.1.json")
schema=$(mktemp -d)
trap 'rm -rf $schema' EXIT
${pkgs.wget}/bin/wget http://127.0.0.1:${toString 18987}/openapi.json -O "$schema"/openapi.json
cat "$schema"/openapi.json >&2
PATH=${lib.makeBinPath [pkgs.bashInteractive pkgs.nodejs]} ${pkgs.nodejs}/bin/npx --yes openapi-format "$schema"/openapi.json --convertTo "3.1" -o "$schema"/openapi-new.json
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$(${pkgs.file}/bin/file -ib "$schema"/openapi-new.json)"
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(${pkgs.coreutils}/bin/wc -c < "$schema"/openapi-new.json)
printf '\r\n'
cat "$schema"/openapi-new.json
exit
;;
esac
''}'';
};
services.nginx.virtualHosts."openapiaiapi.kmein.de" = {
enableACME = true;
forceSSL = true;
locations."/openapi-3.1.json".proxyPass = "http://127.0.0.1:${toString 18988}";
locations."/".proxyPass = "http://127.0.0.1:${toString 18987}";
};
networking = {
firewall.allowedTCPPorts = [80 443];
hostName = "ful";

View File

@@ -1,29 +0,0 @@
{ config, ... }:
let
port = 9090;
in
{
services.nginx.virtualHosts."ical-ephemeris.kmein.de" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}/";
};
};
services.ical-ephemeris = {
enable = true;
inherit port;
brevoApiKeyFile = config.age.secrets.brevo-key.path;
copecartIpnKeyFile = config.age.secrets.copecart-ipn.path;
baseUrl = "https://ical-ephemeris.kmein.de";
};
age.secrets.copecart-ipn = {
file = ../../secrets/copecart-ipn.age;
};
age.secrets.brevo-key = {
file = ../../secrets/brevo-key.age;
};
}

View File

@@ -21,7 +21,7 @@ in {
nginx = {
serverName = "matomo.kmein.de";
};
package = pkgs.matomo_5;
package = pkgs.matomo;
};
services.mysql = {

View File

@@ -1,119 +0,0 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Aeson (ToJSON, FromJSON)
import GHC.Generics (Generic)
import Data.String (IsString(..))
import Network.Wai (Application)
import Network.Wai.Handler.Warp (run)
import Servant
import Servant.Client (HasClient (..))
import Servant.OpenApi (HasOpenApi(..), toOpenApi)
import qualified Data.Version as Version
import Servant.Swagger.UI (SwaggerSchemaUI, swaggerSchemaUIServer)
import Data.OpenApi (ToSchema, servers, license, info, description, version, title)
import qualified Data.OpenApi as OpenApi
import Control.Concurrent.MVar (MVar, newMVar, modifyMVar, readMVar)
import System.Environment (getEnv)
import Control.Monad.IO.Class (liftIO)
import Control.Lens
import qualified Data.Text as T
import GHC.Generics
import GHC.TypeLits
import Data.UUID (UUID)
import Data.UUID.V4 (nextRandom)
import qualified Data.UUID as UUID
-- Define a simple data type
data User = User
{ userId :: UUID
, name :: String
, age :: Int
} deriving (Generic, Show)
instance ToJSON User
instance FromJSON User
instance ToSchema User
-- Define the API type
type API = "users" :> OperationId "getUsers" :> Get '[JSON] [User]
:<|> "users" :> OperationId "insertUser" :> ReqBody '[JSON] User :> Post '[JSON] User
:<|> "users" :> OperationId "updateUser" :> Capture "id" UUID :> ReqBody '[JSON] User :> Put '[JSON] User
:<|> "users" :> OperationId "deleteUser" :> Capture "id" UUID :> Delete '[JSON] NoContent
-- Define the API with Swagger endpoints
type APIWithSwagger = API
:<|> SwaggerSchemaUI "swagger-ui" "openapi.json"
data OperationId (name :: Symbol)
instance HasServer subApi ctx => HasServer (OperationId name :> subApi) ctx where
type ServerT (OperationId name :> subApi) m = ServerT subApi m
route _ = route (Proxy @subApi)
hoistServerWithContext _ = hoistServerWithContext (Proxy @subApi)
instance (HasOpenApi subApi, KnownSymbol name) => HasOpenApi (OperationId name :> subApi) where
toOpenApi _ = toOpenApi (Proxy @subApi) & OpenApi.allOperations . OpenApi.operationId ?~ apiName
where
apiName = T.pack $ symbolVal (Proxy @name)
instance HasClient m api => HasClient m (OperationId name :> api) where
type Client m (OperationId name :> api) = Client m api
clientWithRoute pm Proxy = clientWithRoute pm (Proxy :: Proxy api)
hoistClientMonad pm _ = hoistClientMonad pm (Proxy :: Proxy api)
-- Handlers for the API
getUsers :: MVar [User] -> Handler [User]
getUsers usersVar = liftIO $ readMVar usersVar
addUser :: MVar [User] -> User -> Handler User
addUser usersVar newUser = liftIO $ do
newId <- nextRandom
let userWithId = newUser { userId = newId }
modifyMVar usersVar $ \users -> return (userWithId : users, userWithId)
updateUser :: MVar [User] -> UUID -> User -> Handler User
updateUser usersVar uid updatedUser = liftIO $ do
modifyMVar usersVar $ \users ->
let newUsers = map (\user -> if userId user == uid then updatedUser { userId = uid } else user) users
in return (newUsers, updatedUser { userId = uid })
deleteUser :: MVar [User] -> UUID -> Handler NoContent
deleteUser usersVar uid = liftIO $ do
modifyMVar usersVar $ \users ->
let newUsers = filter (\user -> userId user /= uid) users
in return (newUsers, NoContent)
-- Implement the server
server :: OpenApi.Server -> MVar [User] -> Server APIWithSwagger
server virtualHost usersVar = (getUsers usersVar
:<|> addUser usersVar
:<|> updateUser usersVar
:<|> deleteUser usersVar)
:<|> swaggerSchemaUIServer (toOpenApi (Proxy :: Proxy API)
& info.title .~ "OpenAPI AI API"
& info.version .~ "1.0"
& info.description ?~ "This is an API for AI with OpenAPI"
& info.license ?~ "MIT"
& servers .~ [virtualHost])
-- Create the application
app :: OpenApi.Server -> MVar [User] -> Application
app virtualHost usersVar = serve (Proxy :: Proxy APIWithSwagger) (server virtualHost usersVar)
-- Main entry point
main :: IO ()
main = do
initialUsers <- mapM (\(name, age) -> nextRandom >>= \uid -> return (User uid name age)) [("Alice", 30), ("Bob", 25)]
usersVar <- newMVar initialUsers
virtualHost <- getEnv "VIRTUAL_HOST"
port <- read <$> getEnv "PORT" -- Assuming PORT is a number
run port (app (fromString virtualHost) usersVar)

View File

@@ -14,7 +14,6 @@
../../configs/sound.nix
../../configs/printing.nix
../../configs/nix.nix
../../configs/flix.nix
../../configs/fonts.nix
../../configs/mycelium.nix
../../configs/retiolum.nix