blob: aa3304c7ba09062ff1948878fcc3082721819918 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Open-source reimplementation of the Cloudflare WARP client's MASQUE protocol
{
config,
lib,
pkgs,
...
}:
let
cfg = config.networking.usque;
usqueWarpScript = pkgs.writeShellApplication {
name = "usque-warp";
runtimeInputs = [
cfg.package
config.terminal.bash.package
];
text = builtins.readFile ./usque-warp.sh;
};
usqueWarpCompletion =
pkgs.runCommand "usque-warp-completion"
{
nativeBuildInputs = [ pkgs.installShellFiles ];
}
''
mkdir -p $out/share/zsh/site-functions
installShellCompletion --zsh --name _usque-warp ${pkgs.writeText "usque-warp.zsh" (builtins.readFile ./usque-warp.zsh)}
'';
usqueWarpScriptPkg = pkgs.symlinkJoin {
name = "usque-warp";
paths = [
usqueWarpScript
usqueWarpCompletion
];
meta = usqueWarpScript.meta or { };
};
in
{
imports = [ ./assertions.nix ];
options.networking.usque = {
enable = lib.mkEnableOption "Enables usque.";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.usque;
description = "The usque package to use.";
};
warp = lib.mkOption {
type = lib.types.submodule {
options = {
enable = lib.mkEnableOption "Enables the usque-warp script.";
package = lib.mkOption {
type = lib.types.package;
readOnly = true;
default = usqueWarpScriptPkg;
description = "The usque-warp script package.";
};
};
};
default = { };
description = "WARP script configuration.";
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
})
(lib.mkIf cfg.warp.enable {
home.packages = [ cfg.warp.package ];
})
];
}
|