vpn: allow disabling vpn config

This commit is contained in:
Leonardo Eugênio 2023-06-02 10:40:51 -03:00
parent 10380a53b5
commit 2dd9bea706
3 changed files with 83 additions and 72 deletions

View file

@ -116,6 +116,7 @@
inherit system specialArgs; inherit system specialArgs;
modules = [ modules = [
./hosts/rainbow.nix ./hosts/rainbow.nix
{ vpn.enable = true; }
./system/rainbow-gitlab-runner.nix ./system/rainbow-gitlab-runner.nix
] ++ common_modules; ] ++ common_modules;
}; };

View file

@ -1,4 +1,13 @@
{ pkgs, ... }: { { pkgs, lib, config, ... }:
let
cfg = config.services.vpn;
in
{
options.services.vpn = {
enable = lib.mkEnableOption "Whether vpn should be enabled";
};
config = lib.mkIf cfg.enable {
networking.firewall.enable = false; networking.firewall.enable = false;
services.mullvad-vpn.enable = true; services.mullvad-vpn.enable = true;
@ -80,4 +89,5 @@
''; '';
}; };
};
} }

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, font, ... }: { config, osConfig, pkgs, lib, font, ... }:
let let
inherit (pkgs.uservars) key theme accent font; inherit (pkgs.uservars) key theme accent font;
inherit (theme) color; inherit (theme) color;
@ -13,14 +13,14 @@ in
layer = "top"; layer = "top";
modules-left = [ "sway/workspaces" "sway/mode" "sway/window" ]; modules-left = [ "sway/workspaces" "sway/mode" "sway/window" ];
modules-center = [ "clock" ]; modules-center = [ "clock" ];
modules-right = [ modules-right = lib.flatten [
"sway/language" "sway/language"
"mpd" "mpd"
"custom/playerctl" "custom/playerctl"
"tray" "tray"
"custom/caffeine" "custom/caffeine"
"pulseaudio" "pulseaudio"
"custom/vpn" (lib.optional osConfig.services.vpn.enable "custom/vpn")
"network" "network"
"battery" "battery"
]; ];
@ -110,7 +110,7 @@ in
interval = 1; interval = 1;
tooltip = false; tooltip = false;
}; };
"custom/vpn" = { "custom/vpn" = lib.mkIf osConfig.services.vpn.enable {
format = "{}"; format = "{}";
exec = '' exec = ''
mullvad status | grep "^Connected" > /dev/null \ mullvad status | grep "^Connected" > /dev/null \