aboutsummaryrefslogtreecommitdiffstats
path: root/modules/networking/usque/default.nix
blob: 9d04ab7535d987ea38912c22510e01b50d9f018c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Open-source reimplementation of the Cloudflare WARP client's MASQUE protocol
{
  config,
  pkgs,
  lib,
  ...
}:
let
  inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule;
  usqueWarp = mkScriptModule {
    scope = [
      "networking"
      "usque"
    ];
    name = "usque-warp";
    path = ./usque-warp.sh;
    description = "Connect/disconnect to Cloudflare WARP via usque MASQUE tunnel";
    deps = [
      config.networking.usque.package
      pkgs.bash
    ];
    completion.zsh = builtins.readFile ./usque-warp.zsh;
    inherit config;
  };
in
{
  options.networking.usque = {
    enable = lib.mkEnableOption "Enables usque.";
    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.usque;
      description = "The usque package to use.";
    };
  }
  // usqueWarp.options.networking.usque;

  config = lib.mkMerge [
    (lib.mkIf config.networking.usque.enable {
      home.packages = [ config.networking.usque.package ];
    })
    usqueWarp.config
  ];
}