Unverified Commit e62de266 authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

Merge pull request #326149 from mguentner/remove_mxisd_ma1sd

nixos/mxisd: remove module
parents 8b5a3d5a ebda20cc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -197,6 +197,9 @@

- `services.roundcube.maxAttachmentSize` will multiply the value set with `1.37` to offset overhead introduced by the base64 encoding applied to attachments.

- The `services.mxisd` module has been removed as both [mxisd](https://github.com/kamax-matrix/mxisd) and [ma1sd](https://github.com/ma1uta/ma1sd) are not maintained any longer.
  Consequently the package `pkgs.ma1sd` has also been removed.

## Other Notable Changes {#sec-release-24.11-notable-changes}

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ in
      #dnsmasq = 141;# dynamically allocated as of 2021-09-03
      #uhub = 142; # unused
      yandexdisk = 143;
      mxisd = 144; # was once collectd
      # mxisd = 144; # removed 2024-07-10
      #consul = 145;# dynamically allocated as of 2021-09-03
      #mailpile = 146; # removed 2022-01-12
      redmine = 147;
@@ -503,7 +503,7 @@ in
      #dnsmasq = 141; # unused
      uhub = 142;
      #yandexdisk = 143; # unused
      mxisd = 144; # was once collectd
      # mxisd = 144; # removed 2024-07-10
      #consul = 145; # unused
      #mailpile = 146; # removed 2022-01-12
      redmine = 147;
+0 −1
Original line number Diff line number Diff line
@@ -1087,7 +1087,6 @@
  ./services/networking/mullvad-vpn.nix
  ./services/networking/multipath.nix
  ./services/networking/murmur.nix
  ./services/networking/mxisd.nix
  ./services/networking/mycelium.nix
  ./services/networking/namecoind.nix
  ./services/networking/nar-serve.nix
+2 −1
Original line number Diff line number Diff line
{ lib, pkgs, ... }:
{ lib, ... }:

let
  inherit (lib)
@@ -74,6 +74,7 @@ in
    (mkRemovedOptionModule [ "services" "mathics" ] "The Mathics module has been removed")
    (mkRemovedOptionModule [ "services" "meguca" ] "Use meguca has been removed from nixpkgs")
    (mkRemovedOptionModule [ "services" "mesos" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "mxisd" ] "The mxisd module has been removed as both mxisd and ma1sd got removed.")
    (mkRemovedOptionModule [ "services" "moinmoin" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "mwlib" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "pantheon" "files" ] ''
+0 −137
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:

with lib;

let

  isMa1sd =
    package:
    lib.hasPrefix "ma1sd" package.name;

  isMxisd =
    package:
    lib.hasPrefix "mxisd" package.name;

  cfg = config.services.mxisd;

  server = optionalAttrs (cfg.server.name != null) { inherit (cfg.server) name; }
        // optionalAttrs (cfg.server.port != null) { inherit (cfg.server) port; };

  baseConfig = {
    matrix.domain = cfg.matrix.domain;
    key.path = "${cfg.dataDir}/signing.key";
    storage = {
      provider.sqlite.database = if isMa1sd cfg.package
                                 then "${cfg.dataDir}/ma1sd.db"
                                 else "${cfg.dataDir}/mxisd.db";
    };
  } // optionalAttrs (server != {}) { inherit server; };

  # merges baseConfig and extraConfig into a single file
  fullConfig = recursiveUpdate baseConfig cfg.extraConfig;

  configFile = if isMa1sd cfg.package
               then pkgs.writeText "ma1sd-config.yaml" (builtins.toJSON fullConfig)
               else pkgs.writeText "mxisd-config.yaml" (builtins.toJSON fullConfig);

in {
  options = {
    services.mxisd = {
      enable = mkEnableOption "matrix federated identity server";

      package = mkPackageOption pkgs "ma1sd" { };

      environmentFile = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = ''
          Path to an environment-file which may contain secrets to be
          substituted via `envsubst`.
        '';
      };

      dataDir = mkOption {
        type = types.str;
        default = "/var/lib/mxisd";
        description = "Where data mxisd/ma1sd uses resides";
      };

      extraConfig = mkOption {
        type = types.attrs;
        default = {};
        description = "Extra options merged into the mxisd/ma1sd configuration";
      };

      matrix = {

        domain = mkOption {
          type = types.str;
          description = ''
            the domain of the matrix homeserver
          '';
        };

      };

      server = {

        name = mkOption {
          type = types.nullOr types.str;
          default = null;
          description = ''
            Public hostname of mxisd/ma1sd, if different from the Matrix domain.
          '';
        };

        port = mkOption {
          type = types.nullOr types.int;
          default = null;
          description = ''
            HTTP port to listen on (unencrypted)
          '';
        };

      };

    };
  };

  config = mkIf cfg.enable {
    users.users.mxisd =
      {
        group = "mxisd";
        home = cfg.dataDir;
        createHome = true;
        shell = "${pkgs.bash}/bin/bash";
        uid = config.ids.uids.mxisd;
      };

    users.groups.mxisd =
      {
        gid = config.ids.gids.mxisd;
      };

    systemd.services.mxisd = {
      description = "a federated identity server for the matrix ecosystem";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];

      serviceConfig = let
        executable = if isMa1sd cfg.package then "ma1sd" else "mxisd";
      in {
        Type = "simple";
        User = "mxisd";
        Group = "mxisd";
        EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
        ExecStart = "${cfg.package}/bin/${executable} -c ${cfg.dataDir}/mxisd-config.yaml";
        ExecStartPre = "${pkgs.writeShellScript "mxisd-substitute-secrets" ''
          umask 0077
          ${pkgs.envsubst}/bin/envsubst -o ${cfg.dataDir}/mxisd-config.yaml \
            -i ${configFile}
        ''}";
        WorkingDirectory = cfg.dataDir;
        Restart = "on-failure";
      };
    };
  };
}
Loading