diff --git a/modules/mullvad/default.nix b/modules/mullvad/default.nix index 4f2873b..91fdd61 100644 --- a/modules/mullvad/default.nix +++ b/modules/mullvad/default.nix @@ -47,9 +47,26 @@ in }; config = lib.mkIf cfg.enable { - environment.etc = builtins.listToAttrs - (map - (name: lib.nameValuePair "wireguard/${name}" { source = "${relayConfigFiles}/${name}"; }) - (lib.attrNames relayConfigs)); + environment = { + etc = builtins.listToAttrs + (map + (name: lib.nameValuePair "wireguard/${name}" { source = "${relayConfigFiles}/${name}"; }) + (lib.attrNames relayConfigs)); + + systemPackages = lib.singleton (pkgs.stdenv.mkDerivation { + name = "mullvad-on-demand"; + + src = ./mullvad.sh; + + dontUnpack = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + install -D $src $out/bin/mullvad + runHook postInstall + ''; + }); + }; }; } diff --git a/users/simon/files/scripts/mullvad b/modules/mullvad/mullvad.sh similarity index 100% rename from users/simon/files/scripts/mullvad rename to modules/mullvad/mullvad.sh