mirror of
https://codeberg.org/muon/home.git
synced 2026-03-08 03:25:16 +00:00
Merge branch 'main' of codeberg.org:muon/home
This commit is contained in:
commit
ce74d1b0eb
3 changed files with 237 additions and 171 deletions
|
|
@ -1,12 +1,17 @@
|
|||
{ config, lib, pkgs, inputs, system, ... }:
|
||||
let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
cfg = config.mods;
|
||||
keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKEio+Y5wBVD1wILaH2R3wV10FvVjiqy/4gGBWHOITTB muon@muon"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKevYmkH7xvYoquBjnYZ7PJiVqf+GOh9fxAJBN6wZGBB gin4@hi.is"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILmAOd9VbhyJeibt6Vrb101MNTk5W8+rh94Djv/C+pyu muon@muho"
|
||||
];
|
||||
|
||||
in {
|
||||
# Hardware
|
||||
imports = [./hardware-configuration.nix ../ports.nix];
|
||||
|
|
@ -70,6 +75,59 @@ in {
|
|||
forceSSL = true;
|
||||
locations."/" = {proxyPass = "http://10.0.0.3:5001";};
|
||||
};
|
||||
"seedbox.muon.host" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://10.0.0.3:3013";
|
||||
};
|
||||
"/api" = {
|
||||
proxyPass = "http://10.0.0.3:3014";
|
||||
extraConfig =
|
||||
#sh
|
||||
''
|
||||
limit_req zone=api burst=20 nodelay;
|
||||
|
||||
# CORS headers
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
|
||||
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always;
|
||||
add_header Access-Control-Expose-Headers "Content-Length,Content-Range" always;
|
||||
|
||||
# Handle preflight requests
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
|
||||
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization";
|
||||
add_header Content-Type text/plain;
|
||||
add_header Content-Length 0;
|
||||
return 204;
|
||||
}
|
||||
'';
|
||||
};
|
||||
"/api/stream" = {
|
||||
proxyPass = "http://10.0.0.3:3014";
|
||||
extraConfig =
|
||||
#sh
|
||||
''
|
||||
limit_req zone=download burst=10 nodelay;
|
||||
proxy_set_header Range $http_range;
|
||||
|
||||
# Streaming optimizations
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_connect_timeout 30s;
|
||||
proxy_send_timeout 300s;
|
||||
|
||||
# Allow large file streaming
|
||||
client_max_body_size 0;
|
||||
proxy_max_temp_file_size 0;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Enable the OpenSSH daemon.
|
||||
|
|
@ -84,4 +142,3 @@ in {
|
|||
|
||||
system.stateVersion = "24.05"; # Did you read the comment?
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@
|
|||
ntfy = 3010;
|
||||
audio = 3011;
|
||||
atuin = 3012;
|
||||
stream = 3013;
|
||||
# stream = 3013; # seedbox-frontend
|
||||
# seedbox = 3014; # seedbox-backend
|
||||
|
||||
search = 8081;
|
||||
videos = 8082;
|
||||
|
|
@ -39,7 +40,6 @@
|
|||
prowlarr = 5006;
|
||||
flaresolverr = 5007;
|
||||
torrent = 5008;
|
||||
seedbox = 5009;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
...
|
||||
}: let
|
||||
cfg = config.mods.server.seedbox;
|
||||
port = config.mods.server.nginx.ports.stream;
|
||||
backend-port = config.mods.server.local.ports.seedbox;
|
||||
port = 3013;
|
||||
bport = 3014;
|
||||
in
|
||||
with lib; {
|
||||
options.mods.server.seedbox = {
|
||||
|
|
@ -17,67 +17,71 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config =
|
||||
mkIf config.mods.server.nginx.enable {
|
||||
}
|
||||
// mkIf cfg.enable {
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [port bport];
|
||||
allowedUDPPorts = [port bport];
|
||||
};
|
||||
|
||||
# Runtime
|
||||
virtualisation.podman = {
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
autoPrune.enable = true;
|
||||
dockerCompat = true;
|
||||
};
|
||||
|
||||
# Enable container name DNS for all Podman networks.
|
||||
networking.firewall.interfaces = let
|
||||
matchAll =
|
||||
if !config.networking.nftables.enable
|
||||
then "podman+"
|
||||
else "podman*";
|
||||
in {
|
||||
"${matchAll}".allowedUDPPorts = [53];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.backend = "podman";
|
||||
virtualisation.oci-containers.backend = "docker";
|
||||
|
||||
# Containers
|
||||
virtualisation.oci-containers.containers."seedbox-backend" = {
|
||||
image = "localhost/compose2nix/seedbox-backend";
|
||||
image = "compose2nix/seedbox-backend";
|
||||
volumes = [
|
||||
"seedbox-lite_seedbox_cache:/app/cache:rw"
|
||||
"seedbox-lite_seedbox_data:/app/data:rw"
|
||||
];
|
||||
ports = [
|
||||
"${backend-port}:3001/tcp"
|
||||
"${toString bport}:3001/tcp"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network-alias=seedbox-backend"
|
||||
"--network=seedbox-lite_seedbox-network"
|
||||
];
|
||||
environment = {
|
||||
NODE_ENV = "production";
|
||||
ACCESS_PASSWORD = "temp_pass";
|
||||
FRONTEND_URL = "http://localhost:${toString port}";
|
||||
};
|
||||
systemd.services."podman-seedbox-backend" = {
|
||||
};
|
||||
systemd.services."docker-seedbox-backend" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
RestartMaxDelaySec = lib.mkOverride 90 "1m";
|
||||
RestartSec = lib.mkOverride 90 "100ms";
|
||||
RestartSteps = lib.mkOverride 90 9;
|
||||
};
|
||||
after = [
|
||||
"podman-network-seedbox-lite_seedbox-network.service"
|
||||
"podman-volume-seedbox-lite_seedbox_cache.service"
|
||||
"podman-volume-seedbox-lite_seedbox_data.service"
|
||||
"docker-network-seedbox-lite_seedbox-network.service"
|
||||
"docker-volume-seedbox-lite_seedbox_cache.service"
|
||||
"docker-volume-seedbox-lite_seedbox_data.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-network-seedbox-lite_seedbox-network.service"
|
||||
"podman-volume-seedbox-lite_seedbox_cache.service"
|
||||
"podman-volume-seedbox-lite_seedbox_data.service"
|
||||
"docker-network-seedbox-lite_seedbox-network.service"
|
||||
"docker-volume-seedbox-lite_seedbox_cache.service"
|
||||
"docker-volume-seedbox-lite_seedbox_data.service"
|
||||
];
|
||||
partOf = [
|
||||
"podman-compose-seedbox-lite-root.target"
|
||||
"docker-compose-seedbox-lite-root.target"
|
||||
];
|
||||
wantedBy = [
|
||||
"podman-compose-seedbox-lite-root.target"
|
||||
"docker-compose-seedbox-lite-root.target"
|
||||
];
|
||||
};
|
||||
virtualisation.oci-containers.containers."seedbox-frontend" = {
|
||||
image = "localhost/compose2nix/seedbox-frontend";
|
||||
image = "compose2nix/seedbox-frontend";
|
||||
ports = [
|
||||
"${port}:80/tcp"
|
||||
"${toString port}:8080/tcp"
|
||||
];
|
||||
dependsOn = [
|
||||
"seedbox-backend"
|
||||
|
|
@ -87,98 +91,103 @@ in
|
|||
"--network-alias=seedbox-frontend"
|
||||
"--network=seedbox-lite_seedbox-network"
|
||||
];
|
||||
environment = {
|
||||
NODE_ENV = "production";
|
||||
ACCESS_PASSWORD = "temp_pass";
|
||||
};
|
||||
systemd.services."podman-seedbox-frontend" = {
|
||||
};
|
||||
systemd.services."docker-seedbox-frontend" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
RestartMaxDelaySec = lib.mkOverride 90 "1m";
|
||||
RestartSec = lib.mkOverride 90 "100ms";
|
||||
RestartSteps = lib.mkOverride 90 9;
|
||||
};
|
||||
after = [
|
||||
"podman-network-seedbox-lite_seedbox-network.service"
|
||||
"docker-network-seedbox-lite_seedbox-network.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-network-seedbox-lite_seedbox-network.service"
|
||||
"docker-network-seedbox-lite_seedbox-network.service"
|
||||
];
|
||||
partOf = [
|
||||
"podman-compose-seedbox-lite-root.target"
|
||||
"docker-compose-seedbox-lite-root.target"
|
||||
];
|
||||
wantedBy = [
|
||||
"podman-compose-seedbox-lite-root.target"
|
||||
"docker-compose-seedbox-lite-root.target"
|
||||
];
|
||||
};
|
||||
|
||||
# Networks
|
||||
systemd.services."podman-network-seedbox-lite_seedbox-network" = {
|
||||
path = [pkgs.podman];
|
||||
systemd.services."docker-network-seedbox-lite_seedbox-network" = {
|
||||
path = [pkgs.docker];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStop = "podman network rm -f seedbox-lite_seedbox-network";
|
||||
ExecStop = "docker network rm -f seedbox-lite_seedbox-network";
|
||||
};
|
||||
script = ''
|
||||
podman network inspect seedbox-lite_seedbox-network || podman network create seedbox-lite_seedbox-network --driver=bridge
|
||||
docker network inspect seedbox-lite_seedbox-network || docker network create seedbox-lite_seedbox-network --driver=bridge
|
||||
'';
|
||||
partOf = ["podman-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["podman-compose-seedbox-lite-root.target"];
|
||||
partOf = ["docker-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["docker-compose-seedbox-lite-root.target"];
|
||||
};
|
||||
|
||||
# Volumes
|
||||
systemd.services."podman-volume-seedbox-lite_seedbox_cache" = {
|
||||
path = [pkgs.podman];
|
||||
systemd.services."docker-volume-seedbox-lite_seedbox_cache" = {
|
||||
path = [pkgs.docker];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
podman volume inspect seedbox-lite_seedbox_cache || podman volume create seedbox-lite_seedbox_cache --driver=local
|
||||
docker volume inspect seedbox-lite_seedbox_cache || docker volume create seedbox-lite_seedbox_cache --driver=local
|
||||
'';
|
||||
partOf = ["podman-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["podman-compose-seedbox-lite-root.target"];
|
||||
partOf = ["docker-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["docker-compose-seedbox-lite-root.target"];
|
||||
};
|
||||
systemd.services."podman-volume-seedbox-lite_seedbox_data" = {
|
||||
path = [pkgs.podman];
|
||||
systemd.services."docker-volume-seedbox-lite_seedbox_data" = {
|
||||
path = [pkgs.docker];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
podman volume inspect seedbox-lite_seedbox_data || podman volume create seedbox-lite_seedbox_data --driver=local
|
||||
docker volume inspect seedbox-lite_seedbox_data || docker volume create seedbox-lite_seedbox_data --driver=local
|
||||
'';
|
||||
partOf = ["podman-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["podman-compose-seedbox-lite-root.target"];
|
||||
partOf = ["docker-compose-seedbox-lite-root.target"];
|
||||
wantedBy = ["docker-compose-seedbox-lite-root.target"];
|
||||
};
|
||||
|
||||
# Builds
|
||||
systemd.services."podman-build-seedbox-backend" = {
|
||||
path = [pkgs.podman pkgs.git];
|
||||
systemd.services."docker-build-seedbox-backend" = {
|
||||
path = [pkgs.docker pkgs.git];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
TimeoutSec = 300;
|
||||
};
|
||||
script = ''
|
||||
cd /tmp
|
||||
git clone https://github.com/hotheadhacker/seedbox-lite.git
|
||||
cd seedbox-lite/server
|
||||
git clone https://github.com/hotheadhacker/seedbox-lite.git && cd seedbox-lite/server || cd seedbox-lite/server
|
||||
podman build -t compose2nix/seedbox-backend .
|
||||
'';
|
||||
};
|
||||
systemd.services."podman-build-seedbox-frontend" = {
|
||||
path = [pkgs.podman pkgs.git];
|
||||
systemd.services."docker-build-seedbox-frontend" = {
|
||||
path = [pkgs.docker pkgs.git];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
TimeoutSec = 300;
|
||||
};
|
||||
script = ''
|
||||
cd /tmp
|
||||
git clone https://github.com/hotheadhacker/seedbox-lite.git
|
||||
cd seedbox-lite/client
|
||||
podman build -t compose2nix/seedbox-frontend --build-arg VITE_API_BASE_URL=http://localhost:${backend-port} .
|
||||
git clone https://github.com/hotheadhacker/seedbox-lite.git && cd seedbox-lite/client || cd seedbox-lite/client
|
||||
podman build -t compose2nix/seedbox-frontend --build-arg VITE_API_BASE_URL=http://localhost:${toString bport} .
|
||||
'';
|
||||
};
|
||||
|
||||
# Root service
|
||||
# When started, this will automatically create all resources and start
|
||||
# the containers. When stopped, this will teardown all resources.
|
||||
systemd.targets."podman-compose-seedbox-lite-root" = {
|
||||
systemd.targets."docker-compose-seedbox-lite-root" = {
|
||||
unitConfig = {
|
||||
Description = "Root target generated by compose2nix.";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue