diff --git a/lib.nix b/lib.nix index 7f3ffa9..42b284d 100644 --- a/lib.nix +++ b/lib.nix @@ -11,17 +11,17 @@ in modules ? [ ], }: let - merged_config = lib.foldl' (acc: elem: acc // elem.config) config modules; - checks = lib.concatStringsSep "\n" ( - lib.concatMap ( - attrs: - lib.mapAttrsToList (k: v: '' - echo "Running ${k}" - ${v}/bin/check - echo "Passed ${k}" - '') attrs.checks - ) modules - ); + merged_config = lib.foldl' (acc: elem: lib.recursiveUpdate acc elem) config modules; + # checks = lib.concatStringsSep "\n" ( + # lib.concatMap ( + # attrs: + # lib.mapAttrsToList (k: v: '' + # echo "Running ${k}" + # ${v}/bin/check + # echo "Passed ${k}" + # '') attrs.checks + # ) modules + # ); removeNullAndEmptyAttrs = attrs: let @@ -48,15 +48,18 @@ in ) ); in - pkgs.writeShellApplication { - inherit name; - text = - checks - + '' - PC_CONFIG_FILES=${configFile} ${pkgs.process-compose}/bin/process-compose "$@" - - ''; + { + inherit configFile merged_config; }; + # pkgs.writeShellApplication { + # inherit name; + # text = + # checks + # + '' + # PC_CONFIG_FILES=${configFile} ${pkgs.process-compose}/bin/process-compose "$@" + # + # ''; + # }; mkPostgres = { name, @@ -64,6 +67,7 @@ in config ? { }, extra_config ? '''', package ? pkgs.postgresql, + data_dir ? ".data/", ... }: let @@ -92,23 +96,22 @@ in "'${lib.replaceStrings [ "'" ] [ "''" ] value}'" else builtins.toString value; - configFile = pkgs.writeTextDir "postgresql.conf" ( - lib.concatStringsSep "\n" ( + configFile = pkgs.writeTextFile { + name = "postgresql.conf"; + text = lib.concatStringsSep "\n" ( lib.mapAttrsToList (n: v: "${n} = ${toStr v}") ( lib.filterAttrs (lib.const (x: x != null)) merged_config ) - ) - ); - configFileCheck = pkgs.writeShellApplication { - name = "check"; - text = '' - ${package}/bin/postgres -D${configFile} -C config_file - ''; + ); }; in + # configFileCheck = pkgs.runCommand {} '' + # ${package}/bin/postgres -D${configFile} -C config_file + # touch $out + # ''; { - config.processes."${name}" = { + processes."${name}" = { + command = "${package}/bin/postgresql -D ${data_dir} --config-file ${configFile}"; }; - checks."postgresql${name}" = configFileCheck; }; }