From 042cb2d517fe89904f0c4211ecdb629c1303b64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Tue, 24 Sep 2024 14:40:35 +0200 Subject: [PATCH] Move Garage VM stuff out of main file --- fediversity/garage.nix | 16 +--------------- flake.nix | 8 +++++--- tests/mastodon-garage.nix | 2 +- tests/pixelfed-garage.nix | 2 +- vm/garage-vm.nix | 25 +++++++++++++++++++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 vm/garage-vm.nix diff --git a/fediversity/garage.nix b/fediversity/garage.nix index a3cbbeb..cc6187f 100644 --- a/fediversity/garage.nix +++ b/fediversity/garage.nix @@ -134,20 +134,6 @@ in }; config = lib.mkIf config.fediversity.enable { - # virtualisation.diskSize = 2048; - # virtualisation.forwardPorts = [ - # { - # from = "host"; - # host.port = fedicfg.rpc.port; - # guest.port = fedicfg.rpc.port; - # } - # { - # from = "host"; - # host.port = fedicfg.web.port; - # guest.port = fedicfg.web.port; - # } - # ]; - environment.systemPackages = [ pkgs.minio-client pkgs.awscli ]; networking.firewall.allowedTCPPorts = [ @@ -185,7 +171,7 @@ in ''; }; }; - + systemd.services.ensure-garage = { after = [ "garage.service" ]; wantedBy = [ "garage.service" ]; diff --git a/flake.nix b/flake.nix index 737ad31..5950b6b 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,7 @@ ## VM-specific modules interactive-vm = import ./vm/interactive-vm.nix; + garage-vm = import ./vm/garage-vm.nix; mastodon-vm = import ./vm/mastodon-vm.nix; peertube-vm = import ./vm/peertube-vm.nix; pixelfed-vm = import ./vm/pixelfed-vm.nix; @@ -25,17 +26,17 @@ nixosConfigurations = { mastodon = nixpkgs.lib.nixosSystem { inherit system; - modules = with self.nixosModules; [ fediversity interactive-vm mastodon-vm ]; + modules = with self.nixosModules; [ fediversity interactive-vm garage-vm mastodon-vm ]; }; peertube = nixpkgs.lib.nixosSystem { inherit system; - modules = with self.nixosModules; [ fediversity interactive-vm peertube-vm ]; + modules = with self.nixosModules; [ fediversity interactive-vm garage-vm peertube-vm ]; }; pixelfed = nixpkgs.lib.nixosSystem { inherit system; - modules = with self.nixosModules; [ fediversity interactive-vm pixelfed-vm ]; + modules = with self.nixosModules; [ fediversity interactive-vm garage-vm pixelfed-vm ]; }; all = nixpkgs.lib.nixosSystem { @@ -43,6 +44,7 @@ modules = with self.nixosModules; [ fediversity interactive-vm + garage-vm peertube-vm pixelfed-vm mastodon-vm diff --git a/tests/mastodon-garage.nix b/tests/mastodon-garage.nix index 672b70f..ef53c6a 100644 --- a/tests/mastodon-garage.nix +++ b/tests/mastodon-garage.nix @@ -37,7 +37,7 @@ pkgs.nixosTest { nodes = { server = { config, ... }: { virtualisation.memorySize = lib.mkVMOverride 4096; - imports = with self.nixosModules; [ mastodon-vm ]; + imports = with self.nixosModules; [ garage-vm mastodon-vm ]; # TODO: pair down environment.systemPackages = with pkgs; [ python3 diff --git a/tests/pixelfed-garage.nix b/tests/pixelfed-garage.nix index f921c77..4137ede 100644 --- a/tests/pixelfed-garage.nix +++ b/tests/pixelfed-garage.nix @@ -136,7 +136,7 @@ pkgs.nixosTest { memorySize = lib.mkVMOverride 8192; cores = 8; }; - imports = with self.nixosModules; [ pixelfed-vm ]; + imports = with self.nixosModules; [ garage-vm pixelfed-vm ]; # TODO: pair down environment.systemPackages = with pkgs; [ python3 diff --git a/vm/garage-vm.nix b/vm/garage-vm.nix new file mode 100644 index 0000000..cd9c81c --- /dev/null +++ b/vm/garage-vm.nix @@ -0,0 +1,25 @@ +{ config, modulesPath, ... }: + +let + fedicfg = config.fediversity.internal.garage; + +in { + imports = [ + ../fediversity + (modulesPath + "/virtualisation/qemu-vm.nix") + ]; + + virtualisation.diskSize = 2048; + virtualisation.forwardPorts = [ + { + from = "host"; + host.port = fedicfg.rpc.port; + guest.port = fedicfg.rpc.port; + } + { + from = "host"; + host.port = fedicfg.web.port; + guest.port = fedicfg.web.port; + } + ]; +}