python312Packages.types-aiobotocore: 2.15.2 -> 2.15.2.post3 (#361801)
[NixPkgs.git] / nixos / modules / services / computing / torque / server.nix
blob27be2c65b7e0f07cb49267002a6cf3183b508ab3
1 { config, pkgs, lib, ... }:
2 let
3   cfg = config.services.torque.server;
4   torque = pkgs.torque;
5 in
7   options = {
9     services.torque.server = {
11       enable = lib.mkEnableOption "torque server";
13     };
15   };
17   config = lib.mkIf cfg.enable {
18     environment.systemPackages = [ pkgs.torque ];
20     systemd.services.torque-server-init = {
21       path = with pkgs; [ torque util-linux procps inetutils ];
23       script = ''
24         tmpsetup=$(mktemp -t torque-XXXX)
25         cp -p ${torque}/bin/torque.setup $tmpsetup
26         sed -i $tmpsetup -e 's/pbs_server -t create/pbs_server -f -t create/'
28         pbs_mkdirs -v aux
29         pbs_mkdirs -v server
30         hostname > /var/spool/torque/server_name
31         cp -prv ${torque}/var/spool/torque/* /var/spool/torque/
32         $tmpsetup root
34         sleep 1
35         rm -f $tmpsetup
36         kill $(pgrep pbs_server) 2>/dev/null
37         kill $(pgrep trqauthd) 2>/dev/null
38       '';
40       serviceConfig = {
41         Type = "oneshot";
42         RemainAfterExit = true;
43       };
45       unitConfig = {
46         ConditionPathExists = "!/var/spool/torque";
47       };
48     };
50     systemd.services.trqauthd = {
51       path = [ torque ];
53       requires = [ "torque-server-init.service" ];
54       after = [ "torque-server-init.service" ];
56       serviceConfig = {
57         Type = "forking";
58         ExecStart = "${torque}/bin/trqauthd";
59       };
60     };
62     systemd.services.torque-server = {
63       path = [ torque ];
65       wantedBy = [ "multi-user.target" ];
66       wants = [ "torque-scheduler.service" "trqauthd.service" ];
67       before = [ "trqauthd.service" ];
68       requires = [ "torque-server-init.service" ];
69       after = [ "torque-server-init.service" "network.target" ];
71       serviceConfig = {
72         Type = "forking";
73         ExecStart = "${torque}/bin/pbs_server";
74         ExecStop = "${torque}/bin/qterm";
75         PIDFile = "/var/spool/torque/server_priv/server.lock";
76       };
77     };
79     systemd.services.torque-scheduler = {
80       path = [ torque ];
82       requires = [ "torque-server-init.service" ];
83       after = [ "torque-server-init.service" ];
85       serviceConfig = {
86         Type = "forking";
87         ExecStart = "${torque}/bin/pbs_sched";
88         PIDFile = "/var/spool/torque/sched_priv/sched.lock";
89       };
90     };
92   };