Compare commits

..

4 commits

Author SHA1 Message Date
Tigor Hutasuhut 1767610c7c flatpak: added support for redis 2024-10-15 08:25:08 +07:00
Tigor Hutasuhut ed60032f75 caddy: fix indentation for static site
Fix by moving the inline HTML to a separate file and serve it using
`file_server` directive.
2024-10-13 16:01:52 +07:00
Tigor Hutasuhut da88afbb51 valheim: added hutasuhut server 2024-10-11 19:39:07 +07:00
Tigor Hutasuhut f26fe1533b ntfy-sh: disabled client on homeserver 2024-10-11 10:40:42 +07:00
9 changed files with 123 additions and 45 deletions

View file

@ -23,6 +23,7 @@
./nnn.nix
./node.nix
./obsidian.nix
./redis.nix
./slack.nix
./spotify.nix
./starship.nix

12
home/programs/redis.nix Normal file
View file

@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
let
cfg = config.profile.services.redis;
inherit (lib) mkIf;
in
lib.mkMerge [
(mkIf cfg.client.cli.enable {
home.packages = [
pkgs.redis
];
})
]

View file

@ -6,5 +6,6 @@ in
options.profile.flatpak = {
enable = mkEnableOption "flatpak";
zen-browser.enable = mkEnableOption "zen-browser";
redisinsight.enable = mkEnableOption "redisinsight";
};
}

View file

@ -35,6 +35,10 @@ in
};
};
redis = {
client.cli.enable = mkEnableOption "redis cli client";
};
couchdb.enable = mkEnableOption "couchdb";
telemetry = {

View file

@ -82,6 +82,7 @@ in
flatpak = {
enable = true;
zen-browser.enable = true;
redisinsight.enable = true;
};
microsoft-edge.enable = true;

View file

@ -68,6 +68,7 @@
navidrome.enable = true;
telemetry.enable = true;
ntfy-sh.enable = true;
ntfy-sh.client.enable = false;
couchdb.enable = true;
};
};

View file

@ -13,7 +13,8 @@ in
onCalendar = "weekly"; # Default value
};
packages = [ ]
++ optional cfg.zen-browser.enable "io.github.zen_browser.zen";
++ optional cfg.zen-browser.enable "io.github.zen_browser.zen"
++ optional cfg.redisinsight.enable "com.redis.RedisInsight";
};
};
}

View file

@ -1,15 +1,17 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
name = "valheim";
podman = config.profile.podman;
inherit (lib) mkIf strings;
ip = "10.88.200.10";
ip-hutasuhut = "10.88.200.11";
image = "docker.io/lloesche/valheim-server";
domain = "${name}.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
base_dir = "/var/lib/${name}";
base_dir_hutasuhut = "/var/lib/${name}_hutasuhut";
in
lib.mkMerge [
(mkIf (podman.${name}.enable) {
@ -39,12 +41,24 @@ lib.mkMerge [
'';
};
systemd.tmpfiles.settings."podman-${name}".${base_dir}.d = {
group = config.profile.user.name;
mode = "0755";
user = config.profile.user.name;
systemd.tmpfiles.settings."podman-${name}" = {
${base_dir}.d = {
group = config.profile.user.name;
mode = "0755";
user = config.profile.user.name;
};
};
systemd.tmpfiles.settings."podman-${name}-hutasuhut" = {
${base_dir_hutasuhut}.d = {
group = config.profile.user.name;
mode = "0755";
user = config.profile.user.name;
};
};
virtualisation.oci-containers.containers.${name} =
{
inherit image;
@ -52,7 +66,6 @@ lib.mkMerge [
autoStart = true;
ports = [
"2456:2456/udp"
"2457:2457/udp"
];
volumes = [
"${base_dir}/config:/config"
@ -78,6 +91,38 @@ lib.mkMerge [
"io.containers.autoupdate" = "registry";
};
};
virtualisation.oci-containers.containers."${name}-hutasuhut" =
{
inherit image;
hostname = name;
autoStart = true;
ports = [
"2457:2457/udp"
];
volumes = [
"${base_dir_hutasuhut}/config:/config"
"${base_dir_hutasuhut}/data:/opt/valheim"
];
environment = {
TZ = "Asia/Jakarta";
SERVER_NAME = "Hutasuhut";
WORLD_NAME = "Hutasuhut";
STATUS_HTTP = "true";
PUID = uid;
PGID = gid;
};
extraOptions = [
"--network=podman"
"--ip=${ip-hutasuhut}"
"--cap-add=sys_nice"
];
environmentFiles = [
config.sops.templates."valheim-env".path
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
})
{
profile.services.ntfy-sh.client.settings.subscribe = [
@ -86,4 +131,11 @@ lib.mkMerge [
}
];
}
{
profile.services.ntfy-sh.client.settings.subscribe = [
{
topic = "valheim-hutasuhut";
}
];
}
]

View file

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, unstable, ... }:
let
cfg = config.profile.services.caddy;
inherit (lib) mkIf attrsets strings lists;
@ -7,6 +7,7 @@ in
config = mkIf cfg.enable {
services.caddy = {
enable = true;
package = unstable.caddy;
};
services.caddy.globalConfig = /*caddy*/ ''
@ -15,36 +16,44 @@ in
}
'';
environment.etc."caddy/static/tigor.web.id/index.html" = {
text =
let
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
sortedDomains = lists.sort (a: b: a < b) domains;
list = map
(domain: /*html*/ ''
<div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle">
<a href="https://${domain}">${domain}</a>
</div>
'')
sortedDomains;
items = strings.concatStringsSep "\n" list;
in
/*html*/ ''
<!DOCTYPE html>
<html>
<head>
<title>Hosted Sites</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous">
</head>
<body class="container">
<h1 class="text-center">Hosted Sites</h1>
<div class="row g-4">
${items}
</div>
</body>
</html>
'';
user = "caddy";
group = "caddy";
};
services.caddy.virtualHosts =
let
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
sortedDomains = lists.sort (a: b: a < b) domains;
list = map
(domain: /*html*/ ''
<div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle">
<a href="https://${domain}">${domain}</a>
</div>'')
sortedDomains;
items = strings.concatStringsSep "\n" list;
html = /*html*/
''<!DOCTYPE html>
<html>
<head>
<title>Hosted Sites</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous">
</head>
<body class="container">
<h1 class="text-center">Hosted Sites</h1>
<div class="row g-4">
${items}
</div>
</body>
</html>'';
in
{
"router.tigor.web.id".extraConfig = ''
@denied not remote_ip private_ranges
@ -55,17 +64,13 @@ in
'';
"tigor.web.id".extraConfig =
''
header Content-Type text/html
respond <<EOF
${html}
EOF 200
root * /etc/caddy/static/tigor.web.id
file_server
'';
"crowfx.web.id".extraConfig =
''
header Content-Type text/html
respond <<EOF
${html}
EOF 200
root * /etc/caddy/static/tigor.web.id
file_server
'';
};