|
909 | 909 | wal-g-3 |
910 | 910 | ; |
911 | 911 | devShell = self'.devShells.default; |
| 912 | + site = |
| 913 | + let |
| 914 | + system = pkgs.pkgsLinux.stdenv.hostPlatform.system; |
| 915 | + site-env-17 = self.packages.${system}."site-env-17"; |
| 916 | + psql_17 = self.legacyPackages.${system}."psql_17".bin; |
| 917 | + psql_17_slim = self.legacyPackages.${system}."psql_17_slim".bin; |
| 918 | + pgConf = pkgs.writeText "postgresql-test.conf" '' |
| 919 | + dynamic_library_path = '/nix/var/nix/profiles/site/pg-extensions:$libdir' |
| 920 | + session_preload_libraries = 'supautils' |
| 921 | + unix_socket_directories = '/tmp' |
| 922 | + ''; |
| 923 | + in |
| 924 | + pkgs.testers.runNixOSTest { |
| 925 | + name = "site"; |
| 926 | + nodes.machine = |
| 927 | + { ... }: |
| 928 | + { |
| 929 | + environment.systemPackages = [ site-env-17 ]; |
| 930 | + users.users.postgres = { |
| 931 | + isSystemUser = true; |
| 932 | + group = "postgres"; |
| 933 | + shell = pkgs.bash; |
| 934 | + }; |
| 935 | + users.groups.postgres = { }; |
| 936 | + }; |
| 937 | + testScript = '' |
| 938 | + # site profile absent: supautils loads from $libdir |
| 939 | + machine.succeed("install -d -o postgres -g postgres /tmp/pgdata-slim") |
| 940 | + machine.succeed("su postgres -c '${psql_17_slim}/bin/initdb -D /tmp/pgdata-slim'") |
| 941 | + machine.succeed("install -o postgres -g postgres ${pgConf} /tmp/pgdata-slim/postgresql.conf") |
| 942 | + machine.succeed("su postgres -c '${psql_17_slim}/bin/pg_ctl -D /tmp/pgdata-slim -l /tmp/pg-slim.log start'") |
| 943 | + machine.succeed("su postgres -c '${psql_17_slim}/bin/psql -h /tmp -d postgres -c \"select 1\"'") |
| 944 | + machine.succeed("su postgres -c '${psql_17_slim}/bin/pg_ctl -D /tmp/pgdata-slim stop'") |
| 945 | +
|
| 946 | + machine.succeed("${site-env-17}/bin/update-profile /nix/var/nix/profiles/site ${site-env-17}") |
| 947 | +
|
| 948 | + # postgres can load supautils via the site profile's dynamic_library_path |
| 949 | + machine.succeed("install -d -o postgres -g postgres /tmp/pgdata") |
| 950 | + machine.succeed("su postgres -c '${psql_17}/bin/initdb -D /tmp/pgdata'") |
| 951 | + machine.succeed("install -o postgres -g postgres ${pgConf} /tmp/pgdata/postgresql.conf") |
| 952 | + machine.succeed("su postgres -c '${psql_17}/bin/pg_ctl -D /tmp/pgdata -l /tmp/pg.log start'") |
| 953 | + machine.succeed("su postgres -c '${psql_17}/bin/psql -h /tmp -d postgres -c \"select 1\"'") |
| 954 | + machine.succeed("su postgres -c '${psql_17}/bin/pg_ctl -D /tmp/pgdata stop'") |
| 955 | +
|
| 956 | + # activate starts the gc |
| 957 | + machine.succeed("mkdir -p /nix/var/nix/profiles/default") |
| 958 | + machine.succeed("ln -sfn /run/current-system/sw/bin /nix/var/nix/profiles/default/bin") |
| 959 | + machine.succeed("${site-env-17}/bin/activate") |
| 960 | + machine.succeed("systemctl is-active site-nix-gc") |
| 961 | + machine.succeed("systemctl stop site-nix-gc") |
| 962 | + ''; |
| 963 | + }; |
912 | 964 | } |
913 | 965 | // (import ./ext/tests { |
914 | 966 | inherit self; |
|
0 commit comments