# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/nextdns/nextdns 1.48.0 v
revision            0
categories          net sysutils
maintainers         nomaintainer
platforms           {darwin >= 21}
license             MIT

homepage            https://nextdns.io/

description         NextDNS CLI client

long_description    NextDNS protects you from all kinds of security threats, \
                    blocks ads and trackers on websites and in apps and provides \
                    a safe and supervised Internet for kids — on all devices and on \
                    all networks.

checksums           ${distname}${extract.suffix} \
                        rmd160  6ea7b28960707e991e1ef30ecbd34ef39f675406 \
                        sha256  ddcb5e0022d3c2c732f333666704b5c890dd57438e45f295ccd6347b943d6011 \
                        size    238868

go.vendors          golang.org/x/sys \
                        lock    v0.47.0 \
                        rmd160  1be59a8208fd6f7f4319b306138e77f215293e1a \
                        sha256  2bed220513067f721fc7c19314bab58860c28397f5e48093a8fe35a27a915b06 \
                        size    1551474 \
                    golang.org/x/net \
                        lock    v0.57.0 \
                        rmd160  32c1b1c4903de772168076e5747a60c0b27f245e \
                        sha256  1f5e7fae3267c8d518156b2b6e24c7f92175c82e6e2a7e8383b41cf50805c600 \
                        size    1443429 \
                    github.com/hashicorp/golang-lru/v2 \
                        lock    v2.0.7 \
                        rmd160  2f1bb029285d1f25ec7b2b55623c8b8a221154c0 \
                        sha256  7e0d056d9ae52e411de5945162e0dee0e7974dec527858f2fec39cfeff6afd3f \
                        size    23862 \
                    github.com/godbus/dbus/v5 \
                        lock    v5.2.2 \
                        rmd160  246dd5e5235b59b789f02727588f70369b0f13bd \
                        sha256  4255168f8ba1a60120341af5d5c0a5f4d956caa1de5e7dd2147efe65f761898c \
                        size    79076 \
                    github.com/dustin/go-humanize \
                        lock    v1.0.1 \
                        rmd160  3c799a1cbda2e82f3d35ec20e539581fd9c24b9d \
                        sha256  aa5a5059ebd8fffc9e9b9e3c888d85cdb1f4c8f7b73944a6c027647039a83df7 \
                        size    17709 \
                    github.com/dgraph-io/ristretto/v2 \
                        lock    v2.4.2 \
                        rmd160  c885b27dd1d269f677a0a62b7f8abef4d393bf9b \
                        sha256  7f256536b7b743c13ebf1ee1c6d154b54cf1d65da7138f68e83c85faec24d46f \
                        size    159842 \
                    github.com/denisbrodbeck/machineid \
                        lock    v1.0.1 \
                        rmd160  c782c29a666ff8e4ad93945389ca9c395754c2c4 \
                        sha256  98e4169e90ef7e087d47c2620f94aba71f2087f41f64d85509570c2161e85101 \
                        size    27812 \
                    github.com/cespare/xxhash/v2 \
                        lock    v2.3.0 \
                        rmd160  dfed275969e04769f613bd08336420dc9009794a \
                        sha256  79cc788ad30f0d7987fb1f259f21477a74178e30f4a2b2803af2b43c3ebcfa91 \
                        size    12704

build.args          -ldflags="-X main.version=${version}"

post-build {
    foreach shell {bash zsh fish} {
        system -W ${worksrcpath} "./${name} completion ${shell} > ${name}.${shell}"
    }
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
    set comp_file(bash) ${destroot}${prefix}/share/bash-completion/completions/${name}
    set comp_file(zsh)  ${destroot}${prefix}/share/zsh/site-functions/_${name}
    set comp_file(fish) ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish
    foreach shell {bash zsh fish} {
        xinstall -d [file dirname $comp_file(${shell})]
        xinstall -m 644 ${worksrcpath}/${name}.${shell} $comp_file(${shell})
    }
}

notes "
Install the nextdns daemon with

    sudo nextdns install \
        -config <your config id> \
        -report-client-info \
        -auto-activate

Configure the daemon with

    sudo nextdns config
"
