Compare commits

...

9 commits

13 changed files with 181 additions and 95 deletions

View file

@ -8,6 +8,7 @@
./git.nix
./github.nix
./go.nix
./jellyfin.nix
./microsoft-edge.nix
./mpv.nix
./neovide.nix

View file

@ -4,7 +4,7 @@ let
in
{
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf cfg.client.enable [
home.packages = [
unstable.jellyfin-media-player
];
};

View file

@ -6,5 +6,8 @@
pihole.enable = lib.mkEnableOption "pihole podman";
suwayomi.enable = lib.mkEnableOption "suwayomi podman";
ytptube.enable = lib.mkEnableOption "metube podman";
redmage.enable = lib.mkEnableOption "redmage podman";
redmage-demo.enable = lib.mkEnableOption "redmage-demo podman";
qbittorrent.enable = lib.mkEnableOption "qbittorrent podman";
};
}

View file

@ -28,6 +28,9 @@
pihole.enable = true;
suwayomi.enable = true;
ytptube.enable = true;
redmage.enable = true;
redmage-demo.enable = true;
qbittorrent.enable = true;
};
docker = {

View file

@ -1,37 +0,0 @@
{ config, lib, pkgs, ... }:
let
user = config.profile.user;
podman = config.profile.podman;
cache = "/home/${user.name}/.cache/podman/caddy";
in
{
config = lib.mkIf (podman.enable && podman.caddy.enable) {
system.activationScripts.podman-caddy = ''
mkdir -p ${cache}
chown -R ${config.profile.user.name} ${cache}
'';
# https://fictionbecomesfact.com/caddy-container
systemd.services.create-caddy-network = with config.virtualisation.oci-containers; {
serviceConfig.Type = "oneshot";
wantedBy = [ "${backend}-caddy.service" ];
script = ''${pkgs.podman}/bin/podman network exists caddy || ${pkgs.podman}/bin/podman network create caddy'';
};
virtualisation.oci-containers.containers = {
caddy = {
image = "lucaslorentz/caddy-docker-proxy:ci-alpine";
environment = {
TZ = "Asia/Jakarta";
};
ports = [ "80:80" "443:443" ];
autoStart = true;
volumes = [
"/run/user/${toString(user.uid)}/podman/podman.sock:/var/run/docker.sock:z"
"${cache}:/data"
];
extraOptions = [
"--network=caddy"
];
};
};
};
}

View file

@ -34,13 +34,17 @@ in
# Taken IP-Range Subnets
#
# 10.1.1.0-4 -> Pihole
# 10.1.1.4-8 -> ytptube
# 10.1.1.8-12 -> Suwayomi
# 10.1.1.12-16 -> Suwayomi
# 10.88.0.2 -> Redmage
# 10.88.0.3 -> Redmage Demo
# 10.88.0.4 -> ytptube
# 10.88.0.5 -> Suwayomi
# 10.88.0.6 -> Suwayomi Flaresolverr
# 10.88.1.1 -> Pihole
imports = [
./caddy.nix
./pihole.nix
./qbittorrent.nix
./redmage-demo.nix
./redmage.nix
./suwayomi.nix
./ytptube.nix
];

View file

@ -1,13 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
name = "pihole";
podman = config.profile.podman;
pihole = podman.pihole;
inherit (lib) mkIf strings attrsets;
gateway = "10.1.1.1";
subnet = "10.1.1.0/30";
ip = "10.1.1.2";
ip-range = "10.1.1.2/30";
inherit (lib) mkIf attrsets;
ip = "10.88.1.1";
image = "pihole/pihole:latest";
piholeDNSIPBind = "192.168.100.3";
in
@ -25,16 +22,6 @@ in
networking.nameservers = [ piholeDNSIPBind ];
systemd.services."create-${name}-network" = {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
wantedBy = [ "podman-${name}.service" ];
script = ''${pkgs.podman}/bin/podman network exists ${name} || ${pkgs.podman}/bin/podman network create --gateway=${gateway} --subnet=${subnet} --ip-range=${ip-range} ${name}'';
};
# We have refresh the custom.list dns list when caddy virtual hosts changes,
# the easiest way to do so is to restart the pihole container.
#
@ -63,6 +50,7 @@ in
};
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
environment = {
TZ = "Asia/Jakarta";
PIHOLE_DNS_ = "192.168.100.5";
@ -87,7 +75,7 @@ in
];
extraOptions = [
"--ip=${ip}"
"--network=${name}"
"--network=podman"
"--cap-add=NET_ADMIN"
"--cap-add=NET_BIND_SERVICE"
"--cap-add=NET_RAW"

View file

@ -0,0 +1,54 @@
{ config, lib, ... }:
let
name = "qbittorrent";
domain = "${name}.tigor.web.id";
podman = config.profile.podman;
qbittorrent = podman.qbittorrent;
inherit (lib) mkIf;
ip = "10.88.0.7";
image = "lscr.io/linuxserver/qbittorrent:latest";
volume = "/nas/torrents";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
in
{
config = mkIf (podman.enable && qbittorrent.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8080
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${volume}/{config,downloads,progress,watch}
chown ${uid}:${gid} ${volume} ${volume}/{config,downloads,progress,watch}
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
environment = {
PUID = uid;
PGID = gid;
TZ = "Asia/Jakarta";
WEBUI_PORT = "8080";
TORRENTING_PORT = "6881";
};
volumes = [
"${volume}/config:/config"
"${volume}/downloads:/downloads"
"${volume}/progress:/progress"
"${volume}/watch:/watch"
];
ports = [
"6881:6881"
"6881:6881/udp"
];
extraOptions = [
"--ip=${ip}"
"--network=podman"
];
};
};
}

View file

@ -0,0 +1,45 @@
{ config, lib, ... }:
let
name = "redmage-demo";
podman = config.profile.podman;
inherit (lib) mkIf;
ip = "10.88.0.3";
image = "git.tigor.web.id/tigor/redmage:latest";
rootVolume = "/nas/redmage-demo";
domain = "${name}.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
in
{
config = mkIf (podman.enable && podman.${name}.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8080
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${rootVolume}/db
mkdir -p ${rootVolume}/images
chown ${uid}:${gid} ${rootVolume} ${rootVolume}/db ${rootVolume}/images
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
user = "${uid}:${gid}";
environment = {
TZ = "Asia/Jakarta";
};
volumes = [
"${rootVolume}/db:/app/db"
"${rootVolume}/images:/app/downloads"
];
extraOptions = [
"--network=podman"
"--ip=${ip}"
];
};
};
}

45
system/podman/redmage.nix Normal file
View file

@ -0,0 +1,45 @@
{ config, lib, ... }:
let
name = "redmage";
podman = config.profile.podman;
inherit (lib) mkIf;
ip = "10.88.0.2";
image = "git.tigor.web.id/tigor/redmage:latest";
rootVolume = "/nas/redmage";
domain = "${name}.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
in
{
config = mkIf (podman.enable && podman.${name}.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8080
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${rootVolume}/db
mkdir -p ${rootVolume}/images
chown ${uid}:${gid} ${rootVolume} ${rootVolume}/db ${rootVolume}/images
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
user = "${uid}:${gid}";
environment = {
TZ = "Asia/Jakarta";
};
volumes = [
"${rootVolume}/db:/app/db"
"${rootVolume}/images:/app/downloads"
];
extraOptions = [
"--network=podman"
"--ip=${ip}"
];
};
};
}

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
name = "suwayomi";
name-flaresolverr = "${name}-flaresolverr";
@ -6,11 +6,8 @@ let
podman = config.profile.podman;
suwayomi = podman.suwayomi;
inherit (lib) mkIf;
subnet = "10.1.1.8/29";
gateway = "10.1.1.9";
ip = "10.1.1.10";
ip-flaresolverr = "10.1.1.11";
ip-range = "10.1.1.10/29";
ip = "10.88.0.5";
ip-flaresolverr = "10.88.0.6";
image = "ghcr.io/suwayomi/tachidesk:latest";
image-flaresolverr = "ghcr.io/flaresolverr/flaresolverr:latest";
volume = "/nas/podman/suwayomi";
@ -24,22 +21,14 @@ in
reverse_proxy ${ip}:4567
'';
systemd.services."create-${name}-network" = {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
wantedBy = [ "podman-${name}.service" ];
script = ''${pkgs.podman}/bin/podman network exists ${name} || ${pkgs.podman}/bin/podman network create --gateway=${gateway} --subnet=${subnet} --ip-range=${ip-range} ${name}'';
};
system.activationScripts."podman-${name}" = ''
mkdir -p ${volume}
chown -R ${uid}:${gid} ${volume}
chown ${uid}:${gid} ${volume}
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
user = "${uid}:${gid}";
environment = {
@ -61,20 +50,21 @@ in
];
extraOptions = [
"--ip=${ip}"
"--network=${name}"
"--network=podman"
];
dependsOn = [ "${name}-flaresolverr" ];
};
virtualisation.oci-containers.containers.${name-flaresolverr} = {
image = image-flaresolverr;
hostname = name-flaresolverr;
autoStart = true;
environment = {
TZ = "Asia/Jakarta";
};
extraOptions = [
"--ip=${ip-flaresolverr}"
"--network=${name}"
"--network=podman"
];
};
};

View file

@ -3,10 +3,7 @@ let
name = "ytptube";
podman = config.profile.podman;
inherit (lib) mkIf;
gateway = "10.1.1.5";
subnet = "10.1.1.4/30";
ip = "10.1.1.6";
ip-range = "10.1.1.6/30";
ip = "10.88.0.4";
image = "ghcr.io/arabcoders/${name}:latest";
volume = "/nas/mediaserver/${name}";
domain = "${name}.tigor.web.id";
@ -19,17 +16,6 @@ in
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8081
'';
systemd.services."create-${name}-network" = {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
wantedBy = [ "podman-${name}.service" ];
script = ''${pkgs.podman}/bin/podman network exists ${name} || ${pkgs.podman}/bin/podman network create --gateway=${gateway} --subnet=${subnet} --ip-range=${ip-range} ${name}'';
};
system.activationScripts."podman-${name}" = ''
mkdir -p ${volume}
chown -R ${uid}:${gid} ${volume}
@ -76,6 +62,7 @@ in
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
user = "${uid}:${gid}";
environment = {
@ -87,7 +74,7 @@ in
];
extraOptions = [
"--ip=${ip}"
"--network=${name}"
"--network=podman"
];
};
};

View file

@ -16,7 +16,10 @@ in
upstream_recursive_servers = [
{
address_data = "1.1.1.1";
tls_port = 853;
tls_auth_name = "cloudflare-dns.com";
}
{
address_data = "1.0.0.1";
tls_auth_name = "cloudflare-dns.com";
}
];