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