From 185bcfa5e8e2ae34bce2ea5196e97df9a83dac65 Mon Sep 17 00:00:00 2001 From: oluceps Date: Sun, 3 Sep 2023 02:39:20 +0800 Subject: [PATCH 1/4] chore: sync dae module to nixpkgs --- dae/module.nix | 61 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/dae/module.nix b/dae/module.nix index 86766e4..460b601 100644 --- a/dae/module.nix +++ b/dae/module.nix @@ -3,7 +3,7 @@ inputs: { config, lib, pkgs, ... }: let cfg = config.services.dae; defaultDaePackage = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.dae; - defaultAssets = with pkgs; [ v2ray-geoip v2ray-domain-list-community ]; + assets = cfg.assets; genAssetsDrv = paths: pkgs.symlinkJoin { name = "dae-assets"; inherit paths; @@ -16,7 +16,7 @@ in options = { services.dae = with lib;{ enable = mkEnableOption - (mkDoc "A Linux high-performance transparent proxy solution based on eBPF"); + (mdDoc "A Linux high-performance transparent proxy solution based on eBPF"); package = mkOption { type = types.path; @@ -31,21 +31,22 @@ in }; assets = mkOption { + type = with types;(listOf path); + default = with pkgs; [ v2ray-geoip v2ray-domain-list-community ]; + defaultText = literalExpression "with pkgs; [ v2ray-geoip v2ray-domain-list-community ]"; description = mdDoc '' Assets required to run dae. ''; - type = with types;(listOf path); - default = defaultAssets; }; assetsPath = mkOption { type = types.str; - default = "${genAssetsDrv cfg.assets}/share/v2ray"; - example = '' - "${pkgs.symlinkJoin { - name = "assets"; - paths = with pkgs; [ v2ray-geoip v2ray-domain-list-community ]; - }}/share/v2ray" + default = "${genAssetsDrv assets}/share/v2ray"; + defaultText = literalExpression '' + (symlinkJoin { + name = "dae-assets"; + paths = assets; + })/share/v2ray ''; description = mdDoc '' The path which contains geolocation database. @@ -54,23 +55,36 @@ in }; openFirewall = mkOption { - description = mdDoc '' - Port to be opened. Consist with field `tproxy_port` in config file. - ''; type = with types; submodule { options = { enable = mkEnableOption "enable"; port = mkOption { type = types.int; - default = 12345; + description = '' + Port to be opened. Consist with field `tproxy_port` in config file. + ''; }; }; }; + default = { + enable = true; + port = 12345; + }; + defaultText = literalExpression '' + { + enable = true; + port = 12345; + } + ''; + description = mdDoc '' + Open the firewall port. + ''; }; configFile = mkOption { type = types.path; default = "/etc/dae/config.dae"; + example = "/path/to/your/config.dae"; description = mdDoc '' The path of dae config file, end with `.dae`. ''; @@ -82,13 +96,15 @@ in global{} routing{} ''; - description = lib.mdDoc '' + description = mdDoc '' Config text for dae. + + See . ''; }; - - disableTxChecksumIpGeneric = mkEnableOption (mkDoc "See https://github.com/daeuniverse/dae/issues/43"); + disableTxChecksumIpGeneric = + mkEnableOption (mdDoc "See https://github.com/daeuniverse/dae/issues/43"); }; }; @@ -106,8 +122,12 @@ in networking = lib.mkIf cfg.openFirewall.enable { firewall = - builtins.listToAttrs - (map (k: { name = "allowed${k}Ports"; value = [ cfg.openFirewall.port ]; }) [ "UDP" "TCP" ]); + let portToOpen = cfg.openFirewall.port; + in + { + allowedTCPPorts = [ portToOpen ]; + allowedUDPPorts = [ portToOpen ]; + }; }; systemd.services.dae = @@ -149,6 +169,5 @@ in ''; } ]; - } - ; + }; } From e219a18fd34be5f92f2f59dec49ba0e715cfcdf6 Mon Sep 17 00:00:00 2001 From: oluceps Date: Tue, 5 Sep 2023 22:45:02 +0800 Subject: [PATCH 2/4] ci: fix double commit on sync --- .github/workflows/sync-upstream.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yaml b/.github/workflows/sync-upstream.yaml index 0b98a9c..d7d7364 100644 --- a/.github/workflows/sync-upstream.yaml +++ b/.github/workflows/sync-upstream.yaml @@ -26,7 +26,6 @@ jobs: git checkout -B sync-upstream nix run nixpkgs#nix-update -- --commit --version=branch --flake dae - git commit -m "chore: sync upstream" --no-verify if [[ "${{ steps.check_remote_branch.outputs.stdout }}" != '' ]]; then git pull origin sync-upstream --rebase From 1ad4096769ebb69a0870861dceb939099653a077 Mon Sep 17 00:00:00 2001 From: oluceps Date: Tue, 5 Sep 2023 22:51:13 +0800 Subject: [PATCH 3/4] add: flag to ignore unused arg warning --- dae/package.nix | 2 +- daed/package.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dae/package.nix b/dae/package.nix index e6ad7f2..c6ce9b5 100644 --- a/dae/package.nix +++ b/dae/package.nix @@ -28,7 +28,7 @@ buildGoModule rec { ]; preBuild = '' - make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector" \ + make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector -Wno-unused-command-line-argument" \ NOSTRIP=y \ ebpf ''; diff --git a/daed/package.nix b/daed/package.nix index 9dc58c5..62cc907 100644 --- a/daed/package.nix +++ b/daed/package.nix @@ -34,7 +34,7 @@ let nativeBuildInputs = [ clang ]; buildPhase = '' - make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector" \ + make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector -Wno-unused-command-line-argument" \ NOSTRIP=y \ ebpf ''; From 426284dac5bde2572b739000d922863e0a841987 Mon Sep 17 00:00:00 2001 From: oluceps Date: Wed, 6 Sep 2023 07:14:09 +0800 Subject: [PATCH 4/4] chore: enhance document --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46f6d79..387d120 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,13 @@ Modify flake.nix }; } -# use package +# use packages #... -environment.systemPackages = with inputs.daeuniverse.packages.x86_64-linux; [ dae daed ]; +environment.systemPackages = + with inputs.daeuniverse.packages.x86_64-linux; + [ dae daed ]; + ``` ## License