···38383939 pre84 = versionOlder (builtins.parseDrvName postgresql.name).version "8.4";
40404141- # NixOS traditionally used `root` as superuser, most other distros use `postgres`. From 17.09
4242- # we also try to follow this standard
4343- superuser = (if versionAtLeast config.system.stateVersion "17.09" then "postgres" else "root");
44414542in
4643···151148 Contents of the <filename>recovery.conf</filename> file.
152149 '';
153150 };
151151+ superUser = mkOption {
152152+ type = types.str;
153153+ default= if versionAtLeast config.system.stateVersion "17.09" then "postgres" else "root";
154154+ internal = true;
155155+ description = ''
156156+ NixOS traditionally used `root` as superuser, most other distros use `postgres`.
157157+ From 17.09 we also try to follow this standard. Internal since changing this value
158158+ would lead to breakage while setting up databases.
159159+ '';
160160+ };
154161 };
155162156163 };
···215222 ''
216223 # Initialise the database.
217224 if ! test -e ${cfg.dataDir}/PG_VERSION; then
218218- initdb -U ${superuser}
225225+ initdb -U ${cfg.superUser}
219226 # See postStart!
220227 touch "${cfg.dataDir}/.first_startup"
221228 fi
···247254 # Wait for PostgreSQL to be ready to accept connections.
248255 postStart =
249256 ''
250250- while ! ${pkgs.sudo}/bin/sudo -u ${superuser} psql --port=${toString cfg.port} -d postgres -c "" 2> /dev/null; do
257257+ while ! ${pkgs.sudo}/bin/sudo -u ${cfg.superUser} psql --port=${toString cfg.port} -d postgres -c "" 2> /dev/null; do
251258 if ! kill -0 "$MAINPID"; then exit 1; fi
252259 sleep 0.1
253260 done
254261255262 if test -e "${cfg.dataDir}/.first_startup"; then
256263 ${optionalString (cfg.initialScript != null) ''
257257- ${pkgs.sudo}/bin/sudo -u ${superuser} psql -f "${cfg.initialScript}" --port=${toString cfg.port} -d postgres
264264+ ${pkgs.sudo}/bin/sudo -u ${cfg.superUser} psql -f "${cfg.initialScript}" --port=${toString cfg.port} -d postgres
258265 ''}
259266 rm -f "${cfg.dataDir}/.first_startup"
260267 fi
+32
nixos/tests/hydra.nix
···11+import ./make-test.nix ({ pkgs, ...} : {
22+ name = "hydra-init-localdb";
33+ meta = with pkgs.stdenv.lib.maintainers; {
44+ maintainers = [ pstn ];
55+ };
66+77+ machine =
88+ { config, pkgs, ... }:
99+1010+ {
1111+ services.hydra = {
1212+ enable = true;
1313+1414+ #Hydra needs those settings to start up, so we add something not harmfull.
1515+ hydraURL = "example.com";
1616+ notificationSender = "example@example.com";
1717+ };
1818+ };
1919+2020+ testScript =
2121+ ''
2222+ # let the system boot up
2323+ $machine->waitForUnit("multi-user.target");
2424+ # test whether the database is running
2525+ $machine->succeed("systemctl status postgresql.service");
2626+ # test whether the actual hydra daemons are running
2727+ $machine->succeed("systemctl status hydra-queue-runner.service");
2828+ $machine->succeed("systemctl status hydra-init.service");
2929+ $machine->succeed("systemctl status hydra-evaluator.service");
3030+ $machine->succeed("systemctl status hydra-send-stats.service");
3131+ '';
3232+})