mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-01 22:51:03 +01:00
mullvad-vpn: add module
This commit is contained in:
parent
6275d1fc57
commit
c7acf2b1bf
3 changed files with 100 additions and 0 deletions
52
modules/programs/mullvad-vpn.nix
Normal file
52
modules/programs/mullvad-vpn.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
45
tests/modules/programs/mullvad-vpn/basic-config.nix
Normal file
45
tests/modules/programs/mullvad-vpn/basic-config.nix
Normal 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": ""
|
||||||
|
}
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
}
|
||||||
3
tests/modules/programs/mullvad-vpn/default.nix
Normal file
3
tests/modules/programs/mullvad-vpn/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
mullvad-vpn-basic-config = ./basic-config.nix;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue