1 { config, lib, pkgs, ... }:
4 cfg = config.services.rstudio-server;
6 rserver-conf = builtins.toFile "rserver.conf" ''
7 server-working-dir=${cfg.serverWorkingDir}
8 www-address=${cfg.listenAddr}
9 ${cfg.rserverExtraConfig}
12 rsession-conf = builtins.toFile "rsession.conf" ''
13 ${cfg.rsessionExtraConfig}
18 meta.maintainers = with lib.maintainers; [ jbedo cfhammill ];
20 options.services.rstudio-server = {
21 enable = lib.mkEnableOption "RStudio server";
23 serverWorkingDir = lib.mkOption {
25 default = "/var/lib/rstudio-server";
27 Default working directory for server (server-working-dir in rserver.conf).
31 listenAddr = lib.mkOption {
33 default = "127.0.0.1";
35 Address to listen on (www-address in rserver.conf).
39 package = lib.mkPackageOption pkgs "rstudio-server" {
40 example = "rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }";
43 rserverExtraConfig = lib.mkOption {
47 Extra contents for rserver.conf.
51 rsessionExtraConfig = lib.mkOption {
55 Extra contents for resssion.conf.
61 config = lib.mkIf cfg.enable
63 systemd.services.rstudio-server = {
64 description = "Rstudio server";
66 after = [ "network.target" ];
67 wantedBy = [ "multi-user.target" ];
68 restartTriggers = [ rserver-conf rsession-conf ];
71 Restart = "on-failure";
73 ExecStart = "${cfg.package}/bin/rserver";
74 StateDirectory = "rstudio-server";
75 RuntimeDirectory = "rstudio-server";
80 "rstudio/rserver.conf".source = rserver-conf;
81 "rstudio/rsession.conf".source = rsession-conf;
82 "pam.d/rstudio".source = "/etc/pam.d/login";
84 environment.systemPackages = [ cfg.package ];
87 users.rstudio-server = {
88 uid = config.ids.uids.rstudio-server;
89 description = "rstudio-server";
90 group = "rstudio-server";
92 groups.rstudio-server = {
93 gid = config.ids.gids.rstudio-server;