From 110864d9d0089054d4426e26ee4d01c6dce40ee5 Mon Sep 17 00:00:00 2001 From: Snorre Date: Tue, 4 Mar 2025 15:24:46 +0100 Subject: [PATCH] sonarr runs in a vm now --- lib/default.nix | 40 -------------------------------------- packages/shoko/service.nix | 2 +- services/sonarr.nix | 24 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 44 deletions(-) delete mode 100644 lib/default.nix diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index 96e9b2e..0000000 --- a/lib/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - self, - nixpkgs, - ... -}: -nixpkgs.lib.extend ( - _final: prev: let - inherit (prev) mkIf; - in { - extensions = { - createVm = { - name, - system ? nixpkgs.system, - }: config: {microvm, ...}: { - imports = [microvm.host]; - microvm.hypervisor = "cloud-hypervisor"; - microvm.vms.${name} = { - pkgs = import nixpkgs {inherit system;}; - microvm.shares = [ - { - tag = "ro-store"; - source = "/nix/store"; - mountPoint = "/nix/.ro-store"; - } - ]; - inherit config; - }; - # Mount host /nix/store for drastically reduced image size and evaluation time - microvm.vms.${name}.config.shares = [ - { - source = "/nix/store"; - mountPoint = "/nix/.ro-store"; - tag = "ro-store"; - proto = "virtiofs"; - } - ]; - }; - }; - } -) diff --git a/packages/shoko/service.nix b/packages/shoko/service.nix index c9850a9..e167392 100644 --- a/packages/shoko/service.nix +++ b/packages/shoko/service.nix @@ -55,7 +55,7 @@ in { }; systemd.services.shoko-init = { - wantedeBy = ["multi-user.target"]; + wantedBy = ["multi-user.target"]; # TODO: Check if shoko requires a db # requires = optional haveLocalDB "postgresql.service"; # after = optional haveLocalDB "postgresql.service"; diff --git a/services/sonarr.nix b/services/sonarr.nix index 2c59b46..d81d40c 100644 --- a/services/sonarr.nix +++ b/services/sonarr.nix @@ -1,9 +1,14 @@ -{...}: let +{lib, ...}: let host = "127.0.0.1"; port = 8989; in { - microvm.autostart = ["sonarr"]; - microvm.vms."sonarr" = { + config.microvm.autostart = ["sonarr"]; + + config.system.activationScripts.makeSonarrDir = lib.stringAfter ["var"] '' + mkdir -p /var/lib/sonarr + ''; + + config.microvm.vms."sonarr" = { config = { system.stateVersion = "24.11"; microvm.shares = [ @@ -18,6 +23,19 @@ in { mountPoint = "/var/lib/sonarr"; } ]; + microvm.interfaces = [ + { + type = "tap"; + + # interface name on the host + id = "vm-sonarr"; + + # Ethernet address of the MicroVM's interface, not the host's + # + # Locally administered have one of 2/6/A/E in the second nibble. + mac = "02:00:00:00:00:01"; + } + ]; services.sonarr = { enable = true;