From 33e25a1d3f7861a91f9215373e81238c7bbe1c69 Mon Sep 17 00:00:00 2001
From: Jens Nolte <git@queezle.net>
Date: Thu, 9 Sep 2021 18:03:06 +0200
Subject: [PATCH] Set some vpn-related options

---
 bin/wg-add-external-qrcode |  2 +-
 configuration.nix          | 14 ++++++++++++++
 machine-manager.nix        |  3 ++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/bin/wg-add-external-qrcode b/bin/wg-add-external-qrcode
index bd09106..aefe0d0 100755
--- a/bin/wg-add-external-qrcode
+++ b/bin/wg-add-external-qrcode
@@ -32,7 +32,7 @@ fi
 
 hostname=$1
 
-readonly config_file_path="$MACHINES_PATH/external/$hostname/wg_gateway.json"
+readonly config_file_path="$MACHINES_PATH/external/$hostname/qnet.json"
 
 if [[ ! -f $config_file_path ]]
 then
diff --git a/configuration.nix b/configuration.nix
index e5a3d1a..96239da 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -2,6 +2,7 @@
 { name, path, channel, isIso, extraLayersDir, flakeInputs, flakeOutputs, system, extraOverlays }:
 { lib, config, pkgs, ... }:
 
+with lib;
 
 let
   installResult = builtins.fromJSON (builtins.readFile (path + "/install-result.json"));
@@ -83,4 +84,17 @@ in
 
   # Default hostname ist machine directory name
   networking.hostName = lib.mkDefault name;
+
+  queezle.qnet =
+    let
+      qnetFile = path + "/qnet.json";
+      exists = builtins.pathExists qnetFile;
+      qnet = if exists then builtins.fromJSON (builtins.readFile qnetFile) else null;
+    in if exists then {
+      enable = mkDefault true;
+      address = mkDefault qnet.address;
+      allowedIPs = mkDefault qnet.allowedIPs;
+      peerEndpoint = mkDefault qnet.peerEndpoint;
+      publicKey = mkDefault qnet.publicKey;
+    } else {};
 }
diff --git a/machine-manager.nix b/machine-manager.nix
index 2db4f47..8bbd901 100644
--- a/machine-manager.nix
+++ b/machine-manager.nix
@@ -1,7 +1,7 @@
 # applied by this repositories flake
 { flakeInputs, flakeOutputs }:
 # applied by outer flake
-{ extraFlakeInputs, extraFlakeOutputs, machinesDir, extraLayersDir, extraOverlays ? [] }:
+{ extraFlakeInputs, extraFlakeOutputs, machinesDir, extraModules, extraLayersDir, extraOverlays ? [] }:
 
 with builtins;
 with flakeInputs.nixpkgs.lib;
@@ -35,6 +35,7 @@ let
             flakeOutputs = finalFlakeOutputs;
             channel = machineChannels.${name};
           })
+          extraModules
         ] ++ optional isMobileNixos (import "${flakeInputs.mobile-nixos}/lib/configuration.nix" { device = mobileNixosDevice; });
         _module.args.flakeInputs = finalFlakeInputs;
         _module.args.flakeOutputs = finalFlakeOutputs;
-- 
GitLab