about summary refs log tree commit diff
path: root/nix/modules
diff options
context:
space:
mode:
Diffstat (limited to 'nix/modules')
-rw-r--r--nix/modules/ports/default.nix9
-rw-r--r--nix/modules/r2wars-web/default.nix11
-rw-r--r--nix/modules/vm/default.nix44
3 files changed, 39 insertions, 25 deletions
diff --git a/nix/modules/ports/default.nix b/nix/modules/ports/default.nix
index 6f79635..fe98536 100644
--- a/nix/modules/ports/default.nix
+++ b/nix/modules/ports/default.nix
@@ -1,7 +1,6 @@
-{ lib, ... }: 
+{ lib, ... }:
 
-with lib; {
-  options.emile.ports = mkOption {
-    type = types.anything;
-  };
+with lib;
+{
+  options.emile.ports = mkOption { type = types.anything; };
 }
diff --git a/nix/modules/r2wars-web/default.nix b/nix/modules/r2wars-web/default.nix
index 509824e..58be2ad 100644
--- a/nix/modules/r2wars-web/default.nix
+++ b/nix/modules/r2wars-web/default.nix
@@ -1,8 +1,15 @@
-{ config, lib, pkgs, ... }: 
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}:
 
 let
   cfg = config.services.emile.r2wars-web;
-in with lib; {
+in
+with lib;
+{
   options.services.emile.r2wars-web = {
     enable = mkEnableOption "Enable r2wars-web";
 
diff --git a/nix/modules/vm/default.nix b/nix/modules/vm/default.nix
index 0f65765..6352c80 100644
--- a/nix/modules/vm/default.nix
+++ b/nix/modules/vm/default.nix
@@ -1,8 +1,15 @@
-{ config, lib, pkgs, ... }: 
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}:
 
 let
   cfg = config.services.emile.r2wars-web;
-in with lib; {
+in
+with lib;
+{
   options.services.emile.r2wars-web = {
     enable = mkEnableOption "Enable r2wars-web";
 
@@ -16,18 +23,19 @@ in with lib; {
   };
 
   config = mkIf cfg.enable {
-    systemd.services = lib.mapAttrs' (name: guest: lib.nameValuePair "libvirtd-guest-${name}" {
-      after = [ "libvirtd.service" ];
-      requires = [ "libvirtd.service" ];
-      wantedBy = [ "multi-user.target" ];
-      serviceConfig = {
-        Type = "oneshot";
-        RemainAfterExit = "yes";
-      };
-      script =
-        let
-          xml = pkgs.writeText "libvirt-guest-${name}.xml"
-            ''
+    systemd.services = lib.mapAttrs' (
+      name: guest:
+      lib.nameValuePair "libvirtd-guest-${name}" {
+        after = [ "libvirtd.service" ];
+        requires = [ "libvirtd.service" ];
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig = {
+          Type = "oneshot";
+          RemainAfterExit = "yes";
+        };
+        script =
+          let
+            xml = pkgs.writeText "libvirt-guest-${name}.xml" ''
               <domain type="kvm">
                 <name>${name}</name>
                 <uuid>UUID</uuid>
@@ -53,14 +61,13 @@ in with lib; {
                 </features>
               </domain>
             '';
-        in
+          in
           ''
             uuid="$(${pkgs.libvirt}/bin/virsh domuuid '${name}' || true)"
             ${pkgs.libvirt}/bin/virsh define <(sed "s/UUID/$uuid/" '${xml}')
             ${pkgs.libvirt}/bin/virsh start '${name}'
           '';
-      preStop =
-        ''
+        preStop = ''
           ${pkgs.libvirt}/bin/virsh shutdown '${name}'
           let "timeout = $(date +%s) + 10"
           while [ "$(${pkgs.libvirt}/bin/virsh list --name | grep --count '^${name}$')" -gt 0 ]; do
@@ -73,6 +80,7 @@ in with lib; {
             fi
           done
         '';
-    }) guests;
+      }
+    ) guests;
   };
 }