diff options
author | Maximilian Güntner <code@klandest.in> | 2019-09-01 16:55:46 +0200 |
---|---|---|
committer | Maximilian Güntner <code@klandest.in> | 2019-10-07 18:57:15 +0200 |
commit | 176b1aeb4ee17f6ab7d5bb9275514d900e848ec1 (patch) | |
tree | 1a62746f69f61d237f2df00366c5082bd699681b /nixos/modules/services/networking/mxisd.nix | |
parent | ce587047e63ea6c44b55d915af4863d41d985b31 (diff) | |
download | nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar.gz nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar.bz2 nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar.lz nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar.xz nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.tar.zst nixpkgs-176b1aeb4ee17f6ab7d5bb9275514d900e848ec1.zip |
nixos/mxisd: add support for ma1sd
both servers only differ slighly so the module can be reused
Diffstat (limited to 'nixos/modules/services/networking/mxisd.nix')
-rw-r--r-- | nixos/modules/services/networking/mxisd.nix | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/nixos/modules/services/networking/mxisd.nix b/nixos/modules/services/networking/mxisd.nix index 02e89f441b3..a3d61922e57 100644 --- a/nixos/modules/services/networking/mxisd.nix +++ b/nixos/modules/services/networking/mxisd.nix @@ -3,6 +3,15 @@ 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; } @@ -12,37 +21,41 @@ let matrix.domain = cfg.matrix.domain; key.path = "${cfg.dataDir}/signing.key"; storage = { - provider.sqlite.database = "${cfg.dataDir}/mxisd.db"; + 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 = pkgs.writeText "mxisd-config.yaml" (builtins.toJSON fullConfig); + 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 "mxisd matrix federated identity server"; + enable = mkEnableOption "matrix federated identity server"; package = mkOption { type = types.package; default = pkgs.mxisd; defaultText = "pkgs.mxisd"; - description = "The mxisd package to use"; + description = "The mxisd/ma1sd package to use"; }; dataDir = mkOption { type = types.str; default = "/var/lib/mxisd"; - description = "Where data mxisd uses resides"; + description = "Where data mxisd/ma1sd uses resides"; }; extraConfig = mkOption { type = types.attrs; default = {}; - description = "Extra options merged into the mxisd configuration"; + description = "Extra options merged into the mxisd/ma1sd configuration"; }; matrix = { @@ -62,7 +75,7 @@ in { type = types.nullOr types.str; default = null; description = '' - Public hostname of mxisd, if different from the Matrix domain. + Public hostname of mxisd/ma1sd, if different from the Matrix domain. ''; }; @@ -103,11 +116,13 @@ in { after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - serviceConfig = { + serviceConfig = let + executable = if isMa1sd cfg.package then "ma1sd" else "mxisd"; + in { Type = "simple"; User = "mxisd"; Group = "mxisd"; - ExecStart = "${cfg.package}/bin/mxisd -c ${configFile}"; + ExecStart = "${cfg.package}/bin/${executable} -c ${configFile}"; WorkingDirectory = cfg.dataDir; Restart = "on-failure"; }; |