Skip to content

Commit 7efc4cb

Browse files
committed
chore: Replace Transmission NixOS module deployment with container
1 parent 711927d commit 7efc4cb

File tree

12 files changed

+35
-127
lines changed

12 files changed

+35
-127
lines changed

flake.lock

Lines changed: 1 addition & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
url = "github:nix-community/nixos-generators";
4040
inputs.nixpkgs.follows = "nixpkgs";
4141
};
42-
vpnconfinement = {
43-
url = "github:Maroka-chan/VPN-Confinement";
44-
inputs.nixpkgs.follows = "nixpkgs";
45-
};
4642
nix-topology = {
4743
url = "github:oddlama/nix-topology";
4844
inputs.nixpkgs.follows = "nixpkgs";

hostModules/homelab/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ in {
88
./acme.nix
99
./homepage.nix
1010
./ntfs.nix
11-
./vpn.nix
1211
inputs.nix-topology.nixosModules.default
1312
];
1413

hostModules/homelab/media/readarr.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ in {
3030
};
3131

3232
topology.self.services.readarr = {
33+
name = "Readarr";
3334
details.listen.text = lib.mkForce cfg.domain;
3435
};
3536
};

hostModules/homelab/media/transmission.nix

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,39 @@
22
let cfg = config.homelab.media.transmission;
33
in {
44
options.homelab.media.transmission =
5-
config.lib.homelab.mkServiceOptionSet "Transmission" "transmission" cfg;
5+
(config.lib.homelab.mkServiceOptionSet "Transmission" "transmission" cfg)
6+
// {
7+
transmissionEnvFile = lib.mkOption {
8+
type = lib.types.path;
9+
description = "Path to the Transmission env file";
10+
};
11+
};
612

713
config = lib.mkIf cfg.enable {
8-
services.transmission = {
9-
enable = true;
10-
group = config.homelab.media.group;
11-
settings = {
12-
download-dir = "${config.homelab.media.storageRoot}/torrents/completed";
13-
incomplete-dir-enabled = true;
14-
incomplete-dir =
15-
"${config.homelab.media.storageRoot}/torrents/incomplete";
16-
watch-dir-enabled = true;
17-
watch-dir = "${config.homelab.media.storageRoot}/torrents/watch";
18-
19-
rpc-whitelist = "127.*,192.168.*,10.*";
20-
rpc-whitelist-enabled = true;
21-
rpc-host-whitelist-enabled = true;
22-
rpc-host-whitelist = cfg.domain;
23-
rpc-bind-address = "192.168.15.1"; # Bind RPC/WebUI to bridge address
24-
25-
rpc-authentication-required = false;
14+
virtualisation.oci-containers.containers.transmission = {
15+
image = "haugene/transmission-openvpn";
16+
environment = {
17+
# TODO: Set up a user for Transmission
18+
PUID = "1000";
19+
PGID = toString config.users.groups.${config.homelab.media.group}.gid;
20+
LOCAL_NETWORK = "10.69.0.0/24";
21+
OPENVPN_OPTS = "--inactive 3600 --ping 10 --ping-exit 60";
2622
};
23+
environmentFiles = [ cfg.transmissionEnvFile ];
24+
ports = [ "9091:9091" ];
25+
volumes = [
26+
"${config.homelab.media.storageRoot}/torrents:/data"
27+
"${config.homelab.media.storageRoot}/config/transmission:/config"
28+
];
29+
extraOptions =
30+
[ "--cap-add=NET_ADMIN,NET_RAW,mknod" "--device" "/dev/net/tun" ];
2731
};
2832

2933
services.nginx.virtualHosts.${cfg.domain} = {
3034
forceSSL = true;
3135
useACMEHost = config.homelab.domain;
3236
locations."/" = {
33-
proxyPass = "http://192.168.15.1:${
34-
toString config.services.transmission.settings.rpc-port
35-
}";
37+
proxyPass = "http://127.0.0.1:9091";
3638
recommendedProxySettings = true;
3739
extraConfig = ''
3840
proxy_pass_header X-Transmission-Session-Id;
@@ -44,23 +46,6 @@ in {
4446
};
4547
};
4648

47-
systemd.services.transmission.vpnconfinement = {
48-
enable = true;
49-
vpnnamespace = config.homelab.vpn.namespace;
50-
};
51-
52-
vpnnamespaces.${config.homelab.vpn.namespace} = {
53-
portMappings = let port = config.services.transmission.settings.rpc-port;
54-
in [{
55-
from = port;
56-
to = port;
57-
}];
58-
openVPNPorts = [{
59-
port = config.services.transmission.settings.peer-port;
60-
protocol = "both";
61-
}];
62-
};
63-
6449
homelab.media.homepageConfig.Transmission = {
6550
priority = lib.mkDefault 2;
6651
config = {
@@ -71,6 +56,8 @@ in {
7156
};
7257

7358
topology.self.services.transmission = {
59+
name = "Transmission";
60+
icon = "services.transmission";
7461
details.listen.text = lib.mkForce cfg.domain;
7562
};
7663
};

hostModules/homelab/vpn.nix

Lines changed: 0 additions & 31 deletions
This file was deleted.

hosts/hades/default.nix

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@
3030
homelab.observability.enable = true;
3131

3232
# Media
33-
age.secrets."wg.conf".file = secrets."wg.conf";
33+
age.secrets."transmission".file = secrets."transmission";
3434
homelab.media = {
3535
enable = true;
3636
storageRoot = "/storage2/media";
37+
transmission.transmissionEnvFile = config.age.secrets."transmission".path;
3738
};
38-
homelab.vpn = {
39-
enable = true;
40-
wireguardConfigFile = config.age.secrets."wg.conf".path;
41-
accessibleFrom = "10.69.0.0/24";
42-
};
39+
users.groups.media.gid = 993;
4340

4441
# Auth
4542
age.secrets.keycloak-db-pw.file = secrets.keycloak-db-pw;

hosts/voyager/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
home.packages = with pkgs; [ tor-browser-bundle-bin ];
4646
};
4747

48+
programs.nix-ld.enable = true;
49+
4850
networking.hostName = "voyager";
4951

5052
# Bootloader.

secrets/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
traefik = ./traefik.env.age;
33
keycloak-db-pw = ./keycloak-db-pw.age;
4-
"wg.conf" = ./wg.conf.age;
4+
transmission = ./transmission.env.age;
55
}

secrets/secrets.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ let
55
in {
66
"traefik.env.age".publicKeys = [ keys.hades keys.iris ] ++ keys.trusted_users;
77
"keycloak-db-pw.age".publicKeys = hades_keyset;
8-
"wg.conf.age".publicKeys = hades_keyset;
8+
"transmission.env.age".publicKeys = hades_keyset;
99
}

0 commit comments

Comments
 (0)