diff options
author | Nick Cao <nickcao@nichi.co> | 2023-02-19 09:19:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-19 09:19:56 +0800 |
commit | a3755116c55043bf229f196f1a79f0dd72669b2b (patch) | |
tree | 6985e9c27928f355af0638326bf933e84bcd7d6b /pkgs/data | |
parent | 3902eed4a0e946d5e7280e199211d4dfe871d8d8 (diff) | |
parent | 99892e9bfb144dbb3aa2b2dae336e7472206c9e1 (diff) |
Merge pull request #216943 from linsui/sing
sing-geosite: init at 20230202101858
Diffstat (limited to 'pkgs/data')
-rw-r--r-- | pkgs/data/misc/sing-geosite/default.nix | 50 | ||||
-rw-r--r-- | pkgs/data/misc/sing-geosite/main.go | 19 |
2 files changed, 69 insertions, 0 deletions
diff --git a/pkgs/data/misc/sing-geosite/default.nix b/pkgs/data/misc/sing-geosite/default.nix new file mode 100644 index 0000000000000..55ba01c61559d --- /dev/null +++ b/pkgs/data/misc/sing-geosite/default.nix @@ -0,0 +1,50 @@ +{ lib +, buildGoModule +, fetchFromGitHub +, substituteAll +, v2ray-domain-list-community +}: + +let + patch = substituteAll { + src = ./main.go; + geosite_data = "${v2ray-domain-list-community}/share/v2ray/geosite.dat"; + }; +in +buildGoModule rec { + pname = "sing-geosite"; + inherit (v2ray-domain-list-community) version; + + src = fetchFromGitHub { + owner = "SagerNet"; + repo = "sing-geosite"; + rev = "4a32d56c1705f77668beb5828df0b0a051efdeb9"; + hash = "sha256-P/EBcwJI2G9327BNi84R+q6BABx9DEKpN6ETTp8Q4NU="; + }; + + vendorHash = "sha256-uQOmUXT2wd40DwwTCMnFFKd47eu+BPBDjiCGtUNFoKY="; + + patchPhase = '' + sed -i -e '/func main()/,/^}/d' -e '/"io"/a "io/ioutil"' main.go + cat ${patch} >> main.go + ''; + + buildPhase = '' + runHook preBuild + go run -v . + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -Dm644 geosite.db $out/share/sing-box/geosite.db + runHook postInstall + ''; + + meta = with lib; { + description = "community managed domain list"; + homepage = "https://github.com/SagerNet/sing-geosite"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ linsui ]; + }; +} diff --git a/pkgs/data/misc/sing-geosite/main.go b/pkgs/data/misc/sing-geosite/main.go new file mode 100644 index 0000000000000..d059d99ffe1eb --- /dev/null +++ b/pkgs/data/misc/sing-geosite/main.go @@ -0,0 +1,19 @@ +func main() { + outputFile, err := os.Create("geosite.db") + if err != nil { + panic(err) + } + defer outputFile.Close() + vData, err := ioutil.ReadFile("@geosite_data@") + if err != nil { + panic(err) + } + domainMap, err := parse(vData) + if err != nil { + panic(err) + } + err = geosite.Write(outputFile, domainMap) + if err != nil { + panic(err) + } +} |