Commit 4f93d9a2 authored by Jade Lovelace's avatar Jade Lovelace
Browse files

mx-puppet-discord: remove

According to emilazy these were the only usages of sha1 in nixpkgs:

```
pkgs/servers/mx-puppet-discord/node-packages.nix
111:        sha1 = "532e01241dbcb0f2769f1b9a7cde313d30101173";
120:        sha1 = "68018cab4f59834b3fef2e59fbfd52938403e001";
129:        sha1 = "52b0e8bb808a1202602899af67939b049dd42402";
138:        sha1 = "0a37a3f9430ff7c29512d29882e25ae738a31283";
```

Anyone motivated to maintain it can feel free to restore this, it's just
not maintained at the moment, and the sha1 hashes need to go.

This was found after Ericson proposed implementing something like
https://github.com/NixOS/nix/issues/13544 in Lix, which led to the
question "who is using sha1 anyway?" and the realization we could just
*remove* support for it outside of .. the known chromium crimes.
parent 94aa5ea1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@

- `victoriametrics` no longer contains VictoriaLogs components. These have been separated into the new package `victorialogs`.

- `mx-puppet-discord` was removed from nixpkgs along with its NixOS module as it was unmaintained and was the only user of sha1 hashes in tree.

- `gnome-keyring` no longer ships with an SSH agent anymore because it has been deprecated upstream. You should use `gcr_4` instead, which provides the same features. More information on why this was done can be found on [the relevant GCR upstream PR](https://gitlab.gnome.org/GNOME/gcr/-/merge_requests/67).

- `stdenv.mkDerivation` and other derivation builders that use it no longer allow the value of `env` to be anything but an attribute set, for the purpose of setting environment variables that are available to the [builder](https://nix.dev/manual/nix/latest/store/derivation/#builder) process. An environment variable called `env` can still be provided by means of `mkDerivation { env.env = ...; }`, though we recommend to use a more specific name than "env".
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ In addition to numerous new and upgraded packages, this release has the followin

- [influxdb-exporter](https://github.com/prometheus/influxdb_exporter) a Prometheus exporter that exports metrics received on an InfluxDB compatible endpoint is now available as [services.prometheus.exporters.influxdb](#opt-services.prometheus.exporters.influxdb.enable).

- [mx-puppet-discord](https://github.com/matrix-discord/mx-puppet-discord), a discord puppeting bridge for matrix. Available as [services.mx-puppet-discord](#opt-services.mx-puppet-discord.enable).
- [mx-puppet-discord](https://github.com/matrix-discord/mx-puppet-discord), a discord puppeting bridge for matrix. Available as `services.mx-puppet-discord`.

- [MeshCentral](https://www.meshcommander.com/meshcentral2/overview), a remote administration service ("TeamViewer but self-hosted and with more features") is now available with a package and a module: [services.meshcentral.enable](#opt-services.meshcentral.enable)

+0 −1
Original line number Diff line number Diff line
@@ -779,7 +779,6 @@
  ./services/matrix/mautrix-telegram.nix
  ./services/matrix/mautrix-whatsapp.nix
  ./services/matrix/mjolnir.nix
  ./services/matrix/mx-puppet-discord.nix
  ./services/matrix/pantalaimon.nix
  ./services/matrix/synapse-auto-compressor.nix
  ./services/matrix/synapse.nix
+4 −0
Original line number Diff line number Diff line
@@ -190,6 +190,10 @@ in
    (mkRemovedOptionModule [ "services" "matrix-sliding-sync" ]
      "The matrix-sliding-sync package has been removed, since matrix-synapse incorporated its functionality. Remove `services.sliding-sync` from your NixOS Configuration, and the `.well-known` record for `org.matrix.msc3575.proxy` from your webserver"
    )
    (mkRemovedOptionModule [
      "services"
      "mx-puppet-discord"
    ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "meguca" ] "Use meguca has been removed from nixpkgs")
    (mkRemovedOptionModule [ "services" "mesos" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [
+0 −125
Original line number Diff line number Diff line
{
  config,
  pkgs,
  lib,
  ...
}:
let
  dataDir = "/var/lib/mx-puppet-discord";
  registrationFile = "${dataDir}/discord-registration.yaml";
  cfg = config.services.mx-puppet-discord;
  settingsFormat = pkgs.formats.json { };
  settingsFile = settingsFormat.generate "mx-puppet-discord-config.json" cfg.settings;

in
{
  options = {
    services.mx-puppet-discord = {
      enable = lib.mkEnableOption ''
        mx-puppet-discord is a discord puppeting bridge for matrix.
        It handles bridging private and group DMs, as well as Guilds (servers)
      '';

      settings = lib.mkOption rec {
        apply = lib.recursiveUpdate default;
        inherit (settingsFormat) type;
        default = {
          bridge.port = 8434;
          presence = {
            enabled = true;
            interval = 500;
          };
          provisioning.whitelist = [ ];
          relay.whitelist = [ ];

          # variables are preceded by a colon.
          namePatterns = {
            user = ":name";
            userOverride = ":displayname";
            room = ":name";
            group = ":name";
          };

          #defaults to sqlite but can be configured to use postgresql with
          #connstring
          database.filename = "${dataDir}/database.db";
          logging = {
            console = "info";
            lineDateFormat = "MMM-D HH:mm:ss.SSS";
          };
        };
        example = lib.literalExpression ''
          {
            bridge = {
              bindAddress = "localhost";
              domain = "example.com";
              homeserverUrl = "https://example.com";
            };

            provisioning.whitelist = [ "@admin:example.com" ];
            relay.whitelist = [ "@.*:example.com" ];
          }
        '';
        description = ''
          {file}`config.yaml` configuration as a Nix attribute set.
          Configuration options should match those described in
          [
          sample.config.yaml](https://github.com/matrix-discord/mx-puppet-discord/blob/master/sample.config.yaml).
        '';
      };
      serviceDependencies = lib.mkOption {
        type = with lib.types; listOf str;
        default = lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
        defaultText = lib.literalExpression ''
          lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
        '';
        description = ''
          List of Systemd services to require and wait for when starting the application service.
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.mx-puppet-discord = {
      description = "Matrix to Discord puppeting bridge";

      wantedBy = [ "multi-user.target" ];
      wants = [ "network-online.target" ] ++ cfg.serviceDependencies;
      after = [ "network-online.target" ] ++ cfg.serviceDependencies;

      preStart = ''
        # generate the appservice's registration file if absent
        if [ ! -f '${registrationFile}' ]; then
          ${pkgs.mx-puppet-discord}/bin/mx-puppet-discord -r -c ${settingsFile} \
          -f ${registrationFile}
        fi
      '';

      serviceConfig = {
        Type = "simple";
        Restart = "always";

        ProtectSystem = "strict";
        ProtectHome = true;
        ProtectKernelTunables = true;
        ProtectKernelModules = true;
        ProtectControlGroups = true;

        DynamicUser = true;
        PrivateTmp = true;
        WorkingDirectory = pkgs.mx-puppet-discord;
        StateDirectory = baseNameOf dataDir;
        UMask = "0027";

        ExecStart = ''
          ${pkgs.mx-puppet-discord}/bin/mx-puppet-discord \
            -c ${settingsFile} \
            -f ${registrationFile}
        '';
      };
    };
  };

  meta.maintainers = with lib.maintainers; [ govanify ];
}
Loading