2022-01-19 23:45:15 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.rstudio-server;
|
|
|
|
|
|
|
|
rserver-conf = builtins.toFile "rserver.conf" ''
|
|
|
|
server-working-dir=${cfg.serverWorkingDir}
|
|
|
|
www-address=${cfg.listenAddr}
|
|
|
|
${cfg.rserverExtraConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
rsession-conf = builtins.toFile "rsession.conf" ''
|
|
|
|
${cfg.rsessionExtraConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
meta.maintainers = with maintainers; [ jbedo cfhammill ];
|
|
|
|
|
|
|
|
options.services.rstudio-server = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "RStudio server");
|
2022-01-19 23:45:15 +00:00
|
|
|
|
|
|
|
serverWorkingDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/rstudio-server";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-19 23:45:15 +00:00
|
|
|
Default working directory for server (server-working-dir in rserver.conf).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddr = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-19 23:45:15 +00:00
|
|
|
Address to listen on (www-address in rserver.conf).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "rstudio-server" {
|
|
|
|
example = "rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }";
|
2022-01-19 23:45:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
rserverExtraConfig = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-19 23:45:15 +00:00
|
|
|
Extra contents for rserver.conf.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
rsessionExtraConfig = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-01-19 23:45:15 +00:00
|
|
|
Extra contents for resssion.conf.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable
|
|
|
|
{
|
|
|
|
systemd.services.rstudio-server = {
|
|
|
|
description = "Rstudio server";
|
|
|
|
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
restartTriggers = [ rserver-conf rsession-conf ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "on-failure";
|
|
|
|
Type = "forking";
|
|
|
|
ExecStart = "${cfg.package}/bin/rserver";
|
|
|
|
StateDirectory = "rstudio-server";
|
|
|
|
RuntimeDirectory = "rstudio-server";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.etc = {
|
|
|
|
"rstudio/rserver.conf".source = rserver-conf;
|
|
|
|
"rstudio/rsession.conf".source = rsession-conf;
|
|
|
|
"pam.d/rstudio".source = "/etc/pam.d/login";
|
|
|
|
};
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
|
|
|
users = {
|
|
|
|
users.rstudio-server = {
|
|
|
|
uid = config.ids.uids.rstudio-server;
|
|
|
|
description = "rstudio-server";
|
|
|
|
group = "rstudio-server";
|
|
|
|
};
|
|
|
|
groups.rstudio-server = {
|
|
|
|
gid = config.ids.gids.rstudio-server;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|