-
-
Save grahamc/170fe7496d1a706e697b61451ed51065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
let | |
ROOT = builtins.toString ./.; | |
postgres = (import <nixpkgs/nixos> { | |
configuration = { | |
services.postgresql = { | |
enable = true; | |
dataDir = "${ROOT}/.nix/postgres"; | |
superUser = builtins.getEnv "USER"; | |
initialScript = pkgs.writeText "initial.sql" '' | |
CREATE USER postgres WITH SUPERUSER PASSWORD 'Postgres1234'; | |
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; | |
DROP DATABASE template1; | |
CREATE DATABASE template1 WITH ENCODING = 'UTF8' TEMPLATE template0; | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; | |
''; | |
}; | |
systemd.services.postgresql.preStart = '' | |
chown() { | |
echo "Skipping chown: " "$@" | |
} | |
''; | |
systemd.services.postgresql.postStart = '' | |
function ${pkgs.sudo}/bin/sudo() { | |
echo "Skipping sudo... " | |
shift | |
shift | |
echo "Will call: " "$@" | |
"$@" | |
} | |
''; | |
}; | |
}).config.systemd.services.postgresql.runner; | |
in pkgs.stdenv.mkDerivation { | |
name = "bors-ng-shell"; | |
buildInputs = with pkgs; [ elixir rebar ]; | |
inherit postgres; | |
shellHook = '' | |
echo "Start postgresql via:" | |
echo ' $ $postgres' | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment