From 945f767d08d5b5c9f8e299d30a7795f95deb8d84 Mon Sep 17 00:00:00 2001 From: DACHXY Date: Fri, 3 Jan 2025 14:33:27 +0800 Subject: [PATCH] fix: wireguard config file permission issue --- README.md | 3 +++ flake.nix | 22 +++++++++++++++++++--- home/user/git.nix | 2 +- system/dev/dn-lap/default.nix | 7 ++----- system/dev/dn-pre7780/default.nix | 7 ++----- system/modules/wireguard.nix | 16 ++++++---------- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 9e1da6a..c0caaff 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ ## 🌐 VPN - Wireguard (You need put your own `wg0.conf` file) +. + +> NOTE: If import `wireguard.nix` without config file, the Build will fail. --- diff --git a/flake.nix b/flake.nix index 87021b2..cf51b3c 100644 --- a/flake.nix +++ b/flake.nix @@ -40,7 +40,6 @@ outputs = { - self, nixpkgs, nix-index-database, ... @@ -48,6 +47,11 @@ let system = "x86_64-linux"; nix-version = "25.05"; + username = "danny"; + git-config = { + username = "DACHXY"; + email = "danny10132024@gmail.com"; + }; in { nixosConfigurations = { @@ -57,7 +61,13 @@ ./system/dev/dn-pre7780 ]; specialArgs = { - inherit inputs system nix-version; + inherit + inputs + system + nix-version + username + git-config + ; }; }; @@ -67,7 +77,13 @@ ./system/dev/dn-lap ]; specialArgs = { - inherit inputs system nix-version; + inherit + inputs + system + nix-version + username + git-config + ; }; }; }; diff --git a/home/user/git.nix b/home/user/git.nix index 9279791..1bde8b4 100644 --- a/home/user/git.nix +++ b/home/user/git.nix @@ -1,4 +1,4 @@ -{ git-config }: +{ git-config, ... }: let userName = git-config.username; email = git-config.email; diff --git a/system/dev/dn-lap/default.nix b/system/dev/dn-lap/default.nix index 1a5997d..fd532b5 100644 --- a/system/dev/dn-lap/default.nix +++ b/system/dev/dn-lap/default.nix @@ -3,16 +3,13 @@ system, inputs, nix-version, + git-config, + username, ... }: let cursor-size = "24"; - username = "danny"; - git-config = { - username = "DACHXY"; - email = "danny10132024@gmail.com"; - }; in { imports = [ diff --git a/system/dev/dn-pre7780/default.nix b/system/dev/dn-pre7780/default.nix index 10311c2..a63093a 100644 --- a/system/dev/dn-pre7780/default.nix +++ b/system/dev/dn-pre7780/default.nix @@ -3,16 +3,13 @@ inputs, system, nix-version, + git-config, + username, ... }: let cursor-size = "32"; - username = "danny"; - git-config = { - username = "DACHXY"; - email = "danny10132024@gmail.com"; - }; in { imports = [ diff --git a/system/modules/wireguard.nix b/system/modules/wireguard.nix index 04ab5e5..8381c77 100644 --- a/system/modules/wireguard.nix +++ b/system/modules/wireguard.nix @@ -1,16 +1,12 @@ -{ ... }: +{ lib, ... }: let configPath = "/etc/wireguard/wg0.conf"; in { - networking.firewall = { - allowedUDPPorts = [ 51820 ]; + networking = { + firewall = { + allowedUDPPorts = [ 51820 ]; + }; + wg-quick.interfaces.wg0.configFile = configPath; }; - networking.wg-quick.interfaces.wg0 = - if builtins.pathExists configPath then - { - configFile = configPath; - } - else - { }; }