|
| 1 | +# Auto-generated by compose2nix. |
| 2 | + |
| 3 | +{ pkgs, lib, config, ... }: |
| 4 | + |
| 5 | +{ |
| 6 | + # Runtime |
| 7 | + virtualisation.podman = { |
| 8 | + enable = true; |
| 9 | + autoPrune.enable = true; |
| 10 | + dockerCompat = true; |
| 11 | + }; |
| 12 | + |
| 13 | + # Enable container name DNS for all Podman networks. |
| 14 | + networking.firewall.interfaces = let |
| 15 | + matchAll = if !config.networking.nftables.enable then "podman+" else "podman*"; |
| 16 | + in { |
| 17 | + "${matchAll}".allowedUDPPorts = [ 53 ]; |
| 18 | + }; |
| 19 | + |
| 20 | + virtualisation.oci-containers.backend = "podman"; |
| 21 | + |
| 22 | + # Containers |
| 23 | + virtualisation.oci-containers.containers."test-jellyfin" = { |
| 24 | + image = "lscr.io/linuxserver/jellyfin:latest"; |
| 25 | + volumes = [ |
| 26 | + "/media/raid/books:/media/books:rw" |
| 27 | + "/media/raid/music:/media/music:rw" |
| 28 | + "test_jellyfin-cache:/cache:rw" |
| 29 | + "test_jellyfin-config:/config:rw" |
| 30 | + ]; |
| 31 | + log-driver = "journald"; |
| 32 | + autoStart = false; |
| 33 | + extraOptions = [ |
| 34 | + "--network-alias=jellyfin" |
| 35 | + "--network=test_default" |
| 36 | + ]; |
| 37 | + }; |
| 38 | + systemd.services."podman-test-jellyfin" = { |
| 39 | + serviceConfig = { |
| 40 | + Restart = lib.mkOverride 90 "no"; |
| 41 | + }; |
| 42 | + after = [ |
| 43 | + "podman-network-test_default.service" |
| 44 | + "podman-volume-test_jellyfin-cache.service" |
| 45 | + "podman-volume-test_jellyfin-config.service" |
| 46 | + ]; |
| 47 | + requires = [ |
| 48 | + "podman-network-test_default.service" |
| 49 | + "podman-volume-test_jellyfin-cache.service" |
| 50 | + "podman-volume-test_jellyfin-config.service" |
| 51 | + ]; |
| 52 | + }; |
| 53 | + |
| 54 | + # Networks |
| 55 | + systemd.services."podman-network-test_default" = { |
| 56 | + path = [ pkgs.podman ]; |
| 57 | + serviceConfig = { |
| 58 | + Type = "oneshot"; |
| 59 | + RemainAfterExit = true; |
| 60 | + ExecStop = "podman network rm -f test_default"; |
| 61 | + }; |
| 62 | + script = '' |
| 63 | + podman network inspect test_default || podman network create test_default |
| 64 | + ''; |
| 65 | + partOf = [ "podman-compose-test-root.target" ]; |
| 66 | + wantedBy = [ "podman-compose-test-root.target" ]; |
| 67 | + }; |
| 68 | + |
| 69 | + # Volumes |
| 70 | + systemd.services."podman-volume-test_jellyfin-cache" = { |
| 71 | + path = [ pkgs.podman ]; |
| 72 | + serviceConfig = { |
| 73 | + Type = "oneshot"; |
| 74 | + RemainAfterExit = true; |
| 75 | + }; |
| 76 | + script = '' |
| 77 | + podman volume inspect test_jellyfin-cache || podman volume create test_jellyfin-cache |
| 78 | + ''; |
| 79 | + partOf = [ "podman-compose-test-root.target" ]; |
| 80 | + wantedBy = [ "podman-compose-test-root.target" ]; |
| 81 | + }; |
| 82 | + systemd.services."podman-volume-test_jellyfin-config" = { |
| 83 | + path = [ pkgs.podman ]; |
| 84 | + serviceConfig = { |
| 85 | + Type = "oneshot"; |
| 86 | + RemainAfterExit = true; |
| 87 | + }; |
| 88 | + script = '' |
| 89 | + podman volume inspect test_jellyfin-config || podman volume create test_jellyfin-config |
| 90 | + ''; |
| 91 | + partOf = [ "podman-compose-test-root.target" ]; |
| 92 | + wantedBy = [ "podman-compose-test-root.target" ]; |
| 93 | + }; |
| 94 | + |
| 95 | + # Root service |
| 96 | + # When started, this will automatically create all resources and start |
| 97 | + # the containers. When stopped, this will teardown all resources. |
| 98 | + systemd.targets."podman-compose-test-root" = { |
| 99 | + unitConfig = { |
| 100 | + Description = "Root target generated by compose2nix."; |
| 101 | + }; |
| 102 | + }; |
| 103 | +} |
0 commit comments