forked from mirrors/nixpkgs
nixos/rstudio-server: init
This commit is contained in:
parent
fd51177e5c
commit
0fe0153003
|
@ -353,6 +353,7 @@ in
|
|||
distcc = 321;
|
||||
webdav = 322;
|
||||
pipewire = 323;
|
||||
rstudio-server = 324;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -660,6 +661,7 @@ in
|
|||
distcc = 321;
|
||||
webdav = 322;
|
||||
pipewire = 323;
|
||||
rstudio-server = 324;
|
||||
|
||||
# When adding a gid, make sure it doesn't match an existing
|
||||
# uid. Users and groups with the same name should have equal
|
||||
|
|
|
@ -394,6 +394,7 @@
|
|||
./services/development/hoogle.nix
|
||||
./services/development/jupyter/default.nix
|
||||
./services/development/jupyterhub/default.nix
|
||||
./services/development/rstudio-server/default.nix
|
||||
./services/development/lorri.nix
|
||||
./services/display-managers/greetd.nix
|
||||
./services/editors/emacs.nix
|
||||
|
|
107
nixos/modules/services/development/rstudio-server/default.nix
Normal file
107
nixos/modules/services/development/rstudio-server/default.nix
Normal file
|
@ -0,0 +1,107 @@
|
|||
{ 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 = {
|
||||
enable = mkEnableOption "RStudio server";
|
||||
|
||||
serverWorkingDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/rstudio-server";
|
||||
description = ''
|
||||
Default working directory for server (server-working-dir in rserver.conf).
|
||||
'';
|
||||
};
|
||||
|
||||
listenAddr = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = ''
|
||||
Address to listen on (www-address in rserver.conf).
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.rstudio-server;
|
||||
defaultText = literalExpression "pkgs.rstudio-server";
|
||||
example = literalExpression "pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }";
|
||||
description = ''
|
||||
Rstudio server package to use. Can be set to rstudioServerWrapper to provide packages.
|
||||
'';
|
||||
};
|
||||
|
||||
rserverExtraConfig = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra contents for rserver.conf.
|
||||
'';
|
||||
};
|
||||
|
||||
rsessionExtraConfig = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
30
nixos/tests/rstudio-server.nix
Normal file
30
nixos/tests/rstudio-server.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
import ./make-test-python.nix ({ pkgs, ... }:
|
||||
{
|
||||
name = "rstudio-server-test";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ jbedo cfhammill ];
|
||||
|
||||
nodes.machine = { config, lib, pkgs, ... }: {
|
||||
services.rstudio-server.enable = true;
|
||||
};
|
||||
|
||||
nodes.customPackageMachine = { config, lib, pkgs, ... }: {
|
||||
services.rstudio-server = {
|
||||
enable = true;
|
||||
package = pkgs.rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; };
|
||||
};
|
||||
};
|
||||
|
||||
users.testuser = {
|
||||
uid = 1000;
|
||||
group = "testgroup";
|
||||
};
|
||||
groups.testgroup.gid = 1000;
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("rstudio-server.service")
|
||||
machine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
|
||||
|
||||
customPackageMachine.wait_for_unit("rstudio-server.service")
|
||||
customPackageMachine.succeed("curl -f -vvv -s http://127.0.0.1:8787")
|
||||
'';
|
||||
})
|
Loading…
Reference in a new issue