1 { config, lib, pkgs, ... }:
7 cfg = config.services.rstudio-server;
9 rserver-conf = builtins.toFile "rserver.conf" ''
10 server-working-dir=${cfg.serverWorkingDir}
11 www-address=${cfg.listenAddr}
12 ${cfg.rserverExtraConfig}
15 rsession-conf = builtins.toFile "rsession.conf" ''
16 ${cfg.rsessionExtraConfig}
21 meta.maintainers = with maintainers; [ jbedo cfhammill ];
23 options.services.rstudio-server = {
24 enable = mkEnableOption (lib.mdDoc "RStudio server");
26 serverWorkingDir = mkOption {
28 default = "/var/lib/rstudio-server";
29 description = lib.mdDoc ''
30 Default working directory for server (server-working-dir in rserver.conf).
34 listenAddr = mkOption {
36 default = "127.0.0.1";
37 description = lib.mdDoc ''
38 Address to listen on (www-address in rserver.conf).
44 default = pkgs.rstudio-server;
45 defaultText = literalExpression "pkgs.rstudio-server";
46 example = literalExpression "pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }";
47 description = lib.mdDoc ''
48 Rstudio server package to use. Can be set to rstudioServerWrapper to provide packages.
52 rserverExtraConfig = mkOption {
55 description = lib.mdDoc ''
56 Extra contents for rserver.conf.
60 rsessionExtraConfig = mkOption {
63 description = lib.mdDoc ''
64 Extra contents for resssion.conf.
70 config = mkIf cfg.enable
72 systemd.services.rstudio-server = {
73 description = "Rstudio server";
75 after = [ "network.target" ];
76 wantedBy = [ "multi-user.target" ];
77 restartTriggers = [ rserver-conf rsession-conf ];
80 Restart = "on-failure";
82 ExecStart = "${cfg.package}/bin/rserver";
83 StateDirectory = "rstudio-server";
84 RuntimeDirectory = "rstudio-server";
89 "rstudio/rserver.conf".source = rserver-conf;
90 "rstudio/rsession.conf".source = rsession-conf;
91 "pam.d/rstudio".source = "/etc/pam.d/login";
93 environment.systemPackages = [ cfg.package ];
96 users.rstudio-server = {
97 uid = config.ids.uids.rstudio-server;
98 description = "rstudio-server";
99 group = "rstudio-server";
101 groups.rstudio-server = {
102 gid = config.ids.gids.rstudio-server;