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 ./nnn.nix
./node.nix ./node.nix
./obsidian.nix ./obsidian.nix
./redis.nix
./slack.nix ./slack.nix
./spotify.nix ./spotify.nix
./starship.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 = { options.profile.flatpak = {
enable = mkEnableOption "flatpak"; enable = mkEnableOption "flatpak";
zen-browser.enable = mkEnableOption "zen-browser"; 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"; couchdb.enable = mkEnableOption "couchdb";
telemetry = { telemetry = {

View file

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

View file

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

View file

@ -13,7 +13,8 @@ in
onCalendar = "weekly"; # Default value onCalendar = "weekly"; # Default value
}; };
packages = [ ] 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 let
name = "valheim"; name = "valheim";
podman = config.profile.podman; podman = config.profile.podman;
inherit (lib) mkIf strings; inherit (lib) mkIf strings;
ip = "10.88.200.10"; ip = "10.88.200.10";
ip-hutasuhut = "10.88.200.11";
image = "docker.io/lloesche/valheim-server"; image = "docker.io/lloesche/valheim-server";
domain = "${name}.tigor.web.id"; domain = "${name}.tigor.web.id";
user = config.profile.user; user = config.profile.user;
uid = toString user.uid; uid = toString user.uid;
gid = toString user.gid; gid = toString user.gid;
base_dir = "/var/lib/${name}"; base_dir = "/var/lib/${name}";
base_dir_hutasuhut = "/var/lib/${name}_hutasuhut";
in in
lib.mkMerge [ lib.mkMerge [
(mkIf (podman.${name}.enable) { (mkIf (podman.${name}.enable) {
@ -39,11 +41,23 @@ lib.mkMerge [
''; '';
}; };
systemd.tmpfiles.settings."podman-${name}".${base_dir}.d = { systemd.tmpfiles.settings."podman-${name}" = {
${base_dir}.d = {
group = config.profile.user.name; group = config.profile.user.name;
mode = "0755"; mode = "0755";
user = config.profile.user.name; 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} = virtualisation.oci-containers.containers.${name} =
{ {
@ -52,7 +66,6 @@ lib.mkMerge [
autoStart = true; autoStart = true;
ports = [ ports = [
"2456:2456/udp" "2456:2456/udp"
"2457:2457/udp"
]; ];
volumes = [ volumes = [
"${base_dir}/config:/config" "${base_dir}/config:/config"
@ -78,6 +91,38 @@ lib.mkMerge [
"io.containers.autoupdate" = "registry"; "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 = [ 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 let
cfg = config.profile.services.caddy; cfg = config.profile.services.caddy;
inherit (lib) mkIf attrsets strings lists; inherit (lib) mkIf attrsets strings lists;
@ -7,6 +7,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.caddy = { services.caddy = {
enable = true; enable = true;
package = unstable.caddy;
}; };
services.caddy.globalConfig = /*caddy*/ '' services.caddy.globalConfig = /*caddy*/ ''
@ -15,7 +16,8 @@ in
} }
''; '';
services.caddy.virtualHosts = environment.etc."caddy/static/tigor.web.id/index.html" = {
text =
let let
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts; domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
sortedDomains = lists.sort (a: b: a < b) domains; sortedDomains = lists.sort (a: b: a < b) domains;
@ -23,11 +25,13 @@ in
(domain: /*html*/ '' (domain: /*html*/ ''
<div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle"> <div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle">
<a href="https://${domain}">${domain}</a> <a href="https://${domain}">${domain}</a>
</div>'') </div>
'')
sortedDomains; sortedDomains;
items = strings.concatStringsSep "\n" list; items = strings.concatStringsSep "\n" list;
html = /*html*/ in
''<!DOCTYPE html> /*html*/ ''
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>Hosted Sites</title> <title>Hosted Sites</title>
@ -43,8 +47,13 @@ in
${items} ${items}
</div> </div>
</body> </body>
</html>''; </html>
in '';
user = "caddy";
group = "caddy";
};
services.caddy.virtualHosts =
{ {
"router.tigor.web.id".extraConfig = '' "router.tigor.web.id".extraConfig = ''
@denied not remote_ip private_ranges @denied not remote_ip private_ranges
@ -55,17 +64,13 @@ in
''; '';
"tigor.web.id".extraConfig = "tigor.web.id".extraConfig =
'' ''
header Content-Type text/html root * /etc/caddy/static/tigor.web.id
respond <<EOF file_server
${html}
EOF 200
''; '';
"crowfx.web.id".extraConfig = "crowfx.web.id".extraConfig =
'' ''
header Content-Type text/html root * /etc/caddy/static/tigor.web.id
respond <<EOF file_server
${html}
EOF 200
''; '';
}; };