Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync dae module with nixpkgs #11

Merged
merged 4 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/sync-upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 40 additions & 21 deletions dae/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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.
Expand All @@ -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`.
'';
Expand All @@ -82,13 +96,15 @@ in
global{}
routing{}
'';
description = lib.mdDoc ''
description = mdDoc ''
Config text for dae.

See <https://github.com/daeuniverse/dae/blob/main/example.dae>.
'';
};


disableTxChecksumIpGeneric = mkEnableOption (mkDoc "See https://github.com/daeuniverse/dae/issues/43");
disableTxChecksumIpGeneric =
mkEnableOption (mdDoc "See https://github.com/daeuniverse/dae/issues/43");

};
};
Expand All @@ -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 =
Expand Down Expand Up @@ -149,6 +169,5 @@ in
'';
}
];
}
;
};
}
2 changes: 1 addition & 1 deletion dae/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down
2 changes: 1 addition & 1 deletion daed/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down