1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-01 14:41:03 +01:00

mullvad-vpn: add module

This commit is contained in:
awwpotato 2025-08-06 21:18:47 -07:00 committed by Austin Horstman
parent 6275d1fc57
commit c7acf2b1bf
3 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,52 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.programs.mullvad-vpn;
jsonFormat = pkgs.formats.json { };
in
{
meta.maintainers = [ lib.maintainers.awwpotato ];
options.programs.mullvad-vpn = {
enable = lib.mkEnableOption "Mullvad VPN";
package = lib.mkPackageOption pkgs "mullvad-vpn" { nullable = true; };
settings = lib.mkOption {
inherit (jsonFormat) type;
default = { };
description = ''
Written to {file}`XDG_CONFIG_HOME/Mullvad VPN/gui_settings.json` or
{file}`~/Library/Application Support/Mullvad VPN/gui_settings.json`.
See <https://github.com/mullvad/mullvadvpn-app/blob/main/desktop/packages/mullvad-vpn/src/main/gui-settings.ts>
for options.
'';
example = {
preferredLocale = "system";
autoConnect = false;
enableSystemNotifications = true;
monochromaticIcon = false;
startMinimized = false;
unpinnedWindow = true;
browsedForSplitTunnelingApplications = [ ];
changelogDisplayedForVersion = "";
updateDismissedForVersion = "";
animateMap = true;
};
};
};
config = lib.mkIf cfg.enable {
home.package = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file."${
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome
}/Mullvad VPN/gui_settings.json" =
lib.mkIf (cfg.settings != { }) {
source = jsonFormat.generate "mullvad-gui-settings" cfg.settings;
};
};
}

View file

@ -0,0 +1,45 @@
{ pkgs, ... }:
{
programs.mullvad-vpn = {
enable = true;
settings = {
preferredLocale = "system";
autoConnect = false;
enableSystemNotifications = true;
monochromaticIcon = false;
startMinimized = false;
unpinnedWindow = true;
browsedForSplitTunnelingApplications = [ ];
changelogDisplayedForVersion = "";
updateDismissedForVersion = "";
animateMap = true;
};
};
nmt.script =
let
configFile =
if pkgs.stdenv.isDarwin then
"home-files/Library/Application\\ Support/Mullvad\\ VPN/gui_settings.json"
else
"home-files/.config/Mullvad\\ VPN/gui_settings.json";
in
''
assertFileExists ${configFile}
assertFileContent ${configFile} \
${pkgs.writeText "settings-expected" ''
{
"animateMap": true,
"autoConnect": false,
"browsedForSplitTunnelingApplications": [],
"changelogDisplayedForVersion": "",
"enableSystemNotifications": true,
"monochromaticIcon": false,
"preferredLocale": "system",
"startMinimized": false,
"unpinnedWindow": true,
"updateDismissedForVersion": ""
}
''}
'';
}

View file

@ -0,0 +1,3 @@
{
mullvad-vpn-basic-config = ./basic-config.nix;
}