From 5c318a6897fc8ecb1e05eee2e65bf587c41e0c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Wed, 20 Jul 2022 09:36:55 +0100 Subject: [PATCH] add mautrix-discord --- .drone.yml | 7 +++ flake.lock | 17 ++++++ flake.nix | 44 +++++++++------ matrix/mautrix-discord/default.nix | 17 ++++++ matrix/mautrix-discord/gomod2nix.toml | 79 +++++++++++++++++++++++++++ matrix/mautrix-discord/source.nix | 7 +++ matrix/mautrix-discord/update.sh | 32 +++++++++++ 7 files changed, 187 insertions(+), 16 deletions(-) create mode 100644 matrix/mautrix-discord/default.nix create mode 100644 matrix/mautrix-discord/gomod2nix.toml create mode 100644 matrix/mautrix-discord/source.nix create mode 100755 matrix/mautrix-discord/update.sh diff --git a/.drone.yml b/.drone.yml index 2049743..65bc399 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,6 +39,12 @@ steps: - mkdir -p /etc/nix - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf - (cd matrix/mautrix-whatsapp && ./update.sh) + - name: Update mautrix-discord + image: nixos/nix + commands: + - mkdir -p /etc/nix + - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf + - (cd matrix/mautrix-discord && ./update.sh) environment: USER: nobody depends_on: @@ -74,6 +80,7 @@ steps: - Update mastodon-glitch - Update matrix-media-repo - Update mautrix-whatsapp + - Update mautrix-discord - Update art - Update pypi - Update miifox diff --git a/flake.lock b/flake.lock index 8ec774d..211932f 100644 --- a/flake.lock +++ b/flake.lock @@ -322,6 +322,22 @@ "type": "github" } }, + "mautrix-discord": { + "flake": false, + "locked": { + "lastModified": 1657375847, + "narHash": "sha256-3oFWMP/xMKdbA3CPlpyY7s4axUC+CGSEzt9prm/oC0A=", + "owner": "mautrix", + "repo": "discord", + "rev": "11efa4996186656dee186ba519d1f6893873ab5f", + "type": "github" + }, + "original": { + "owner": "mautrix", + "repo": "discord", + "type": "github" + } + }, "mautrix-whatsapp": { "flake": false, "locked": { @@ -682,6 +698,7 @@ "kreative-open-relay": "kreative-open-relay", "mastodon": "mastodon", "matrix-media-repo": "matrix-media-repo", + "mautrix-discord": "mautrix-discord", "mautrix-whatsapp": "mautrix-whatsapp", "miifox-net": "miifox-net", "nasin-nanpa": "nasin-nanpa", diff --git a/flake.nix b/flake.nix index 42cfc58..03b760a 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,8 @@ matrix-media-repo.flake = false; mautrix-whatsapp.url = "github:mautrix/whatsapp"; mautrix-whatsapp.flake = false; + mautrix-discord.url = "github:mautrix/discord"; + mautrix-discord.flake = false; gomod2nix.url = "github:tweag/gomod2nix"; kreative-open-relay.url = "github:kreativekorp/open-relay"; kreative-open-relay.flake = false; @@ -61,22 +63,32 @@ }; packages = pkgs.lib.lists.foldl (a: b: a // b) {} (map (f: import f {inherit pkgs inputs;}) ([ - ./scripts/clean-s3-cache.nix - ./web/old-homepage.nix - ./web/miifox-net.nix - ./mastodon - ./matrix/matrix-media-repo - ./matrix/mautrix-whatsapp - ./fonts/kreative.nix - ./fonts/nasin-nanpa.nix - ./plover - ./plover/dicts.nix - ./art - ./ci/drone-runner-docker - ./vim - ./python/tarballs.nix - ] ++ (if system == "x86_64-linux" then [./hydra] else []) - ++ (if system != "i686-linux" then [./minecraft/paper.nix] else []))); + ./scripts/clean-s3-cache.nix + ./web/old-homepage.nix + ./web/miifox-net.nix + ./mastodon + ./matrix/matrix-media-repo + ./matrix/mautrix-whatsapp + ./matrix/mautrix-discord + ./fonts/kreative.nix + ./fonts/nasin-nanpa.nix + ./plover + ./plover/dicts.nix + ./art + ./ci/drone-runner-docker + ./vim + ./python/tarballs.nix + ] + ++ ( + if system == "x86_64-linux" + then [./hydra] + else [] + ) + ++ ( + if system != "i686-linux" + then [./minecraft/paper.nix] + else [] + ))); hydraJobs = if pkgs.lib.strings.hasSuffix "-linux" system diff --git a/matrix/mautrix-discord/default.nix b/matrix/mautrix-discord/default.nix new file mode 100644 index 0000000..b34e265 --- /dev/null +++ b/matrix/mautrix-discord/default.nix @@ -0,0 +1,17 @@ +{ + pkgs, + inputs, + ... +} @ args: let + inherit ((pkgs.callPackage "${inputs.gomod2nix}/builder" {})) buildGoApplication; +in { + mautrix-discord = buildGoApplication rec { + pname = "mautrix-discord"; + version = inputs.mautrix-discord.lastModifiedDate; + src = pkgs.callPackage ./source.nix {}; + proxyVendor = true; + modules = ./gomod2nix.toml; + CGO_ENABLED = "1"; + buildInputs = [pkgs.olm]; + }; +} diff --git a/matrix/mautrix-discord/gomod2nix.toml b/matrix/mautrix-discord/gomod2nix.toml new file mode 100644 index 0000000..58d9404 --- /dev/null +++ b/matrix/mautrix-discord/gomod2nix.toml @@ -0,0 +1,79 @@ +schema = 3 + +[mod] + [mod."github.com/bwmarrin/discordgo"] + version = "v0.23.3-0.20220708141955-6445b637ad87" + hash = "sha256-8QVvFW6sLEJ5biGXV9mIM6Sm2pZdEZFeJk1eSJilmQs=" + replaced = "gitlab.com/beeper/discordgo" + [mod."github.com/davecgh/go-spew"] + version = "v1.1.1" + hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI=" + [mod."github.com/gorilla/mux"] + version = "v1.8.0" + hash = "sha256-s905hpzMH9bOLue09E2JmzPXfIS4HhAlgT7g13HCwKE=" + [mod."github.com/gorilla/websocket"] + version = "v1.5.0" + hash = "sha256-EYVgkSEMo4HaVrsWKqnsYRp8SSS8gNf7t+Elva02Ofc=" + [mod."github.com/lib/pq"] + version = "v1.10.6" + hash = "sha256-8EhFwY/9YH5L/fd6l2beOnC3VvpegRAmCCsnDVJBqBM=" + [mod."github.com/mattn/go-sqlite3"] + version = "v1.14.14" + hash = "sha256-9ih+l+JbwfjfpJEjFyO996rJIFFMg7Tfb0SAinp/01I=" + [mod."github.com/pmezard/go-difflib"] + version = "v1.0.0" + hash = "sha256-/FtmHnaGjdvEIKAJtrUfEhV7EVo5A/eYrtdnUkuxLDA=" + [mod."github.com/skip2/go-qrcode"] + version = "v0.0.0-20200617195104-da1b6568686e" + hash = "sha256-ST9t4/b7WFXUb8wra4ZYVDNZJGrEykw8dkWhLrxp8F0=" + [mod."github.com/stretchr/testify"] + version = "v1.8.0" + hash = "sha256-LDxBAebK+A06y4vbH7cd1sVBOameIY81Xm8/9OPZh7o=" + [mod."github.com/tidwall/gjson"] + version = "v1.14.1" + hash = "sha256-v8zb6n6ReFE9hmiwT7tu4avTgLCrelD9lDMMg2My/AI=" + [mod."github.com/tidwall/match"] + version = "v1.1.1" + hash = "sha256-M2klhPId3Q3T3VGkSbOkYl/2nLHnsG+yMbXkPkyrRdg=" + [mod."github.com/tidwall/pretty"] + version = "v1.2.0" + hash = "sha256-esRQGsn2Ee/CiySlwyuOICSLdqUkH4P7u8qXszos8Yc=" + [mod."github.com/tidwall/sjson"] + version = "v1.2.4" + hash = "sha256-Y26Yf4u/GitvqI75f5oucCew6sQjxjRNo77ab58ofVw=" + [mod."github.com/yuin/goldmark"] + version = "v1.4.12" + hash = "sha256-x32PnjUc9H2k7ZVP5v+/NWsjWXuGy/Ycse2ERtokq6k=" + [mod."golang.org/x/crypto"] + version = "v0.0.0-20220622213112-05595931fe9d" + hash = "sha256-2c4wvwiQ0DJSJsApfmNoxCxx1siRCiJvW9hhrGlcvds=" + [mod."golang.org/x/net"] + version = "v0.0.0-20220624214902-1bab6f366d9e" + hash = "sha256-LKDxEsF5v+SorAzHZGCjcY5dnpZMixI54NqapJy5jtY=" + [mod."golang.org/x/sys"] + version = "v0.0.0-20220520151302-bc2c85ada10a" + hash = "sha256-3xm4LbLhZjjeb8scaNFRa9zYb8z2fZj+/JBcoyXGPR8=" + [mod."golang.org/x/term"] + version = "v0.0.0-20210927222741-03fcf44c2211" + hash = "sha256-DsX2xay7Y/0/bikp4vU8ArF0B6KHyqEc37PwgvmjhSs=" + [mod."golang.org/x/text"] + version = "v0.3.7" + hash = "sha256-XH2pUzzQx95O0rak00grQvfACfL+EmZiV7ZzJBkX+XY=" + [mod."golang.org/x/tools"] + version = "v0.0.0-20180917221912-90fa682c2a6e" + hash = "sha256-NPoE7uVvwjV2PRIxI3DpegOZc8IuUs4XUJuH3ubKHJg=" + [mod."gopkg.in/check.v1"] + version = "v0.0.0-20161208181325-20d25e280405" + hash = "sha256-1w5mgYaZUC52uzDnpXXVqle/9AVkH4WePSrQFOVANUw=" + [mod."gopkg.in/yaml.v3"] + version = "v3.0.1" + hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU=" + [mod."maunium.net/go/mauflag"] + version = "v1.0.0" + hash = "sha256-fYc/WwqE0ev0dvnu5qGmHJsYiSTuWeOTiAVzmQIKWyY=" + [mod."maunium.net/go/maulogger/v2"] + version = "v2.3.2" + hash = "sha256-FlrO1bogPrIzzVzDtIovYyr+1mNk0YaO5hEVv5zovM8=" + [mod."maunium.net/go/mautrix"] + version = "v0.11.1-0.20220708142125-1f795238d635" + hash = "sha256-dQ6ItIw3Gr+Dq7gIhMOjpTV8YNYV3H93jx1CXfYEyUA=" diff --git a/matrix/mautrix-discord/source.nix b/matrix/mautrix-discord/source.nix new file mode 100644 index 0000000..adbdaca --- /dev/null +++ b/matrix/mautrix-discord/source.nix @@ -0,0 +1,7 @@ +{fetchgit}: +fetchgit { + url = "https://github.com/mautrix/discord"; + rev = "11efa4996186656dee186ba519d1f6893873ab5f"; + sha256 = "0fpddiarixppdqdi1is84lag96hr7lppqvjf0v4s1jy8ljj48lbl"; + leaveDotGit = true; +} diff --git a/matrix/mautrix-discord/update.sh b/matrix/mautrix-discord/update.sh new file mode 100755 index 0000000..6f5c2f2 --- /dev/null +++ b/matrix/mautrix-discord/update.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p nix-prefetch-git jq +set -e + +WORK_DIR=$(mktemp -d) +URL=https://github.com/mautrix/discord +REVISION=$(jq -r '.nodes."mautrix-discord".locked.rev' ../../flake.lock) +TARGET_DIR="$PWD" + +function cleanup { + grep "fatal" $WORK_DIR/nix-prefetch-git.out >/dev/stderr || true + rm -rf "$WORK_DIR" +} +trap cleanup EXIT + +echo "Fetching source code $REVISION from $URL" +JSON=$(nix-prefetch-git --url "$URL" --rev "$REVISION" --leave-dotGit 2> $WORK_DIR/nix-prefetch-git.out) +SHA=$(echo $JSON | jq -r .sha256) +SOURCE_DIR=$(grep '^path is' $WORK_DIR/nix-prefetch-git.out | sed 's/^path is //') + +cat > source.nix << EOF +{fetchgit}: +fetchgit { + url = "$URL"; + rev = "$REVISION"; + sha256 = "$SHA"; + leaveDotGit = true; +} +EOF + +echo "Creating gomod2nix.toml" +nix run github:tweag/gomod2nix -- --dir $SOURCE_DIR --outdir $TARGET_DIR