9 cfg = config.services.dae;
19 meta.maintainers = with lib.maintainers; [
25 services.dae = with lib; {
26 enable = mkEnableOption "dae, a Linux high-performance transparent proxy solution based on eBPF";
28 package = mkPackageOption pkgs "dae" { };
31 type = with types; (listOf path);
32 default = with pkgs; [
34 v2ray-domain-list-community
36 defaultText = literalExpression "with pkgs; [ v2ray-geoip v2ray-domain-list-community ]";
38 Assets required to run dae.
42 assetsPath = mkOption {
44 default = "${genAssetsDrv assets}/share/v2ray";
45 defaultText = literalExpression ''
52 The path which contains geolocation database.
53 This option will override `assets`.
57 openFirewall = mkOption {
62 enable = mkEnableOption "opening {option}`port` in the firewall";
66 Port to be opened. Consist with field `tproxy_port` in config file.
75 defaultText = literalExpression ''
82 Open the firewall port.
86 configFile = mkOption {
87 type = with types; (nullOr path);
89 example = "/path/to/your/config.dae";
91 The path of dae config file, end with `.dae`.
96 type = with types; (nullOr str);
99 WARNING: This option will expose store your config unencrypted world-readable in the nix store.
102 See <https://github.com/daeuniverse/dae/blob/main/example.dae>.
106 disableTxChecksumIpGeneric = mkEnableOption "" // {
107 description = "See <https://github.com/daeuniverse/dae/issues/43>";
117 environment.systemPackages = [ cfg.package ];
118 systemd.packages = [ cfg.package ];
120 networking = lib.mkIf cfg.openFirewall.enable {
123 portToOpen = cfg.openFirewall.port;
126 allowedTCPPorts = [ portToOpen ];
127 allowedUDPPorts = [ portToOpen ];
131 systemd.services.dae =
133 daeBin = lib.getExe cfg.package;
136 if cfg.configFile != null then cfg.configFile else pkgs.writeText "config.dae" cfg.config;
138 TxChecksumIpGenericWorkaround =
140 (getExe pkgs.writeShellApplication {
141 name = "disable-tx-checksum-ip-generic";
143 iface=$(${iproute2}/bin/ip route | ${lib.getExe gawk} '/default/ {print $5}')
144 ${lib.getExe ethtool} -K "$iface" tx-checksum-ip-generic off
149 wantedBy = [ "multi-user.target" ];
151 LoadCredential = [ "config.dae:${configPath}" ];
154 "${daeBin} validate -c \${CREDENTIALS_DIRECTORY}/config.dae"
155 ] ++ (with lib; optional cfg.disableTxChecksumIpGeneric TxChecksumIpGenericWorkaround);
158 "${daeBin} run --disable-timestamp -c \${CREDENTIALS_DIRECTORY}/config.dae"
160 Environment = "DAE_LOCATION_ASSET=${cfg.assetsPath}";
166 assertion = lib.pathExists (toString (genAssetsDrv cfg.assets) + "/share/v2ray");
168 Packages in `assets` has no preset paths included.
169 Please set `assetsPath` instead.
174 assertion = !((config.services.dae.config != null) && (config.services.dae.configFile != null));
176 Option `config` and `configFile` could not be set
182 assertion = !((config.services.dae.config == null) && (config.services.dae.configFile == null));
184 Either `config` or `configFile` should be set.