feat: db-tool: update hook realization
This commit is contained in:
@@ -210,15 +210,13 @@ directly against the paths exposed by `self.lib.hectic.*.path`:
|
||||
|
||||
```nix
|
||||
services.postgresql.initialScript = pkgs.writeText "hectic-init.sql" ''
|
||||
\i ${self.lib.hectic.version.path}
|
||||
\i ${self.lib.hectic.secret.path}
|
||||
\i ${self.lib.hectic.migration.path}
|
||||
\i ${self.lib.hectic.inheritance.path}
|
||||
'';
|
||||
```
|
||||
|
||||
The version file (`self.lib.hectic.version`) is templated and only exposes
|
||||
`.sql` (a string). Materialize it with `pkgs.writeText` if a path is needed.
|
||||
|
||||
## Exit Codes
|
||||
|
||||
| Code | Meaning |
|
||||
|
||||
@@ -1,30 +1,12 @@
|
||||
{ dash, hectic, postgresql_17, neovim, openssh, coreutils, gawk, lib, runCommand, self }:
|
||||
let
|
||||
shell = "${dash}/bin/dash";
|
||||
|
||||
hecticInheritanceSqlPath = ../../lib/hook/sql/hectic-inheritance.sql;
|
||||
|
||||
hecticInheritance = runCommand "hectic-inheritance" { } ''
|
||||
mkdir -p "$out/share/hectic"
|
||||
cp ${hecticInheritanceSqlPath} "$out/share/hectic/hectic-inheritance.sql"
|
||||
cp ${self.lib.hectic.inheritance.path} "$out/share/hectic/hectic-inheritance.sql"
|
||||
'';
|
||||
|
||||
# Materialize the templated version SQL into the Nix store as a real file
|
||||
# so it can be passed by path to psql -f (alongside the static siblings).
|
||||
hecticVersionSqlFile = pkgs-writeText "hectic-version.sql" self.lib.hectic.version.sql;
|
||||
pkgs-writeText = name: text: runCommand name { inherit text; passAsFile = [ "text" ]; } ''
|
||||
cp "$textPath" "$out"
|
||||
'';
|
||||
|
||||
hecticEnv = ''
|
||||
HECTIC_VERSION_SQL=${hecticVersionSqlFile}
|
||||
HECTIC_SECRET_SQL=${self.lib.hectic.secret.path}
|
||||
HECTIC_MIGRATION_SQL=${self.lib.hectic.migration.path}
|
||||
HECTIC_INHERITANCE_SQL=${self.lib.hectic.inheritance.path}
|
||||
export HECTIC_VERSION_SQL HECTIC_SECRET_SQL HECTIC_MIGRATION_SQL HECTIC_INHERITANCE_SQL
|
||||
'';
|
||||
|
||||
applyBundle = builtins.readFile self.lib.hectic.applyBundleScript;
|
||||
applyBundle = self.lib.hectic.applyBundleScript;
|
||||
|
||||
mkDatabase =
|
||||
{ postgresql ? postgresql_17 }:
|
||||
@@ -44,7 +26,6 @@ let
|
||||
${builtins.readFile hectic.helpers.posix-shell.quote}
|
||||
${builtins.readFile hectic.helpers.posix-shell.pager_or_cat}
|
||||
${builtins.readFile hectic.helpers.posix-shell.with_closed_fds}
|
||||
${hecticEnv}
|
||||
${applyBundle}
|
||||
${builtins.readFile ./database.sh}
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user