Commit 858cf26a authored by Profpatsch's avatar Profpatsch

containers/postgres: factor out prependPrefix

And remove the last of manual localedb generation.
A few vanity fixes.
parent 9372ef33
......@@ -12,8 +12,9 @@ let
sangha = self.callPackage ../packages/sangha {};
helpers = lib.mapAttrs (_: pkg: self.callPackage pkg {}) {
postgresTemplate = ./helpers/postgres-template.nix;
genUtf8Localedb = ./helpers/gen-utf8-localedb.nix;
postgresTemplate = ./helpers/postgres-template.nix;
prependPrefix = ./helpers/prepend-prefix.nix;
};
})];
};
......
{ glibcLocales }:
# generate a localedb for the given UTF-8 locale string
{ glibcLocales }:
# a locale string formatted like `en_US.UTF-8`
locale:
......
{ lib, pkgs }:
# Generates a postgresql template by executing initdb.
# Initialization of the database server (e.g. adding roles
# and databases) can be done by an init script like:
# psql --file=./mocks/projects.sql --username=postgres sangha
{
# template name
name,
......
{ pkgs }:
# prepend folders to a derivations’s contents
# folder prefix
prefix:
# original derivation
drv:
pkgs.runCommand "${drv.name}-prefixed" {} ''
new="$out/${prefix}"
mkdir -p $(dirname "$new")
cp -r ${drv} "$new"
# nix-support folder should remain on the top level
cp -r $new/nix-support $out/
''
......@@ -34,22 +34,6 @@ let
lc_time = l;
};
# localedb, only contains locale used by the database
# used to build the database and added to containers
localeFiles = pkgs.glibcLocales.override {
locales = [ (sanghaDatabaseLocale + "/UTF-8") ];
allLocales = false;
};
# small helper to prepend folders to a derivation’s contents
prependPrefix = prefix: drv: pkgs.runCommand "${drv.name}-prefixed" {} ''
new="$out/${prefix}"
mkdir -p $(dirname "$new")
cp -r ${drv} "$new"
# nix-support folder should remain on the top level
cp -r $new/nix-support $out/
'';
# creates a postgres database folder, complete with sangha
# databases and mock data
sanghaInitDatabase =
......@@ -153,7 +137,8 @@ in {
# the complete postgresql closure with all deps
pkgs.postgresql
# needed locales (localdb)
(prependPrefix "/usr" localeFiles)
(pkgs.helpers.prependPrefix "/usr"
(pkgs.helpers.genUtf8Localedb sanghaDatabaseLocale))
];
# docker config (see docker image spec)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment