diff --git a/flake.nix b/flake.nix index 56db12c..80ea68b 100644 --- a/flake.nix +++ b/flake.nix @@ -30,12 +30,6 @@ ) ); libPath = pkgs.lib.makeLibraryPath buildInputs; - #oms = pkgs.haskell.lib.buildStackProject { - # ghc = pkgs.haskell.packages.ghc927.ghc; - # inherit buildInputs; - # inherit name; - # dontUnpack = true; - #}; oms = pkgs.stdenv.mkDerivation { inherit buildInputs; inherit name; @@ -54,18 +48,32 @@ echo "moved" ''; }; + mkDB = builtins.readFile ./mkDB.sh; + killDB = builtins.readFile ./killDB.sh; in { packages.${system} = { ${name} = oms; # nixpkgs.legacyPackages.${system}.${name}; + mkOauth2DB = pkgs.writeScriptBin "mkOauth2DB" '' + #!${pkgs.zsh}/bis/zsh -e + ${mkDB} + ''; + killOauth2DB = pkgs.writeScriptBin "killOauth2DB" '' + #!${pkgs.zsh}/bis/zsh -e + ${killDB} + ''; default = self.packages.${system}.${name}; }; - devShells.${system}.default = pkgs.mkShell { - buildInputs = buildInputs; - LD_LIBRARY_PATH = libPath; - shellHook = builtins.readFile ./mkDB.sh; + devShells.${system}.default = pkgs.mkShell { + buildInputs = buildInputs; + LD_LIBRARY_PATH = libPath; + shellHook = '' + ${mkDB} + zsh + ${killDB} + ''; + }; }; - }; -} + } diff --git a/killDB.sh b/killDB.sh new file mode 100755 index 0000000..dd10275 --- /dev/null +++ b/killDB.sh @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: 2024 UniWorX Systems +# SPDX-FileContributor: David Mosbach +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +pg_ctl stop -D "${OAUTH2_PGDIR}" +rm -rvf "${OAUTH2_PGDIR}" "${OAUTH2_PGHOST}" "${OAUTH2_PGLOG}" + diff --git a/mkDB.sh b/mkDB.sh index 8893f65..bd444ec 100755 --- a/mkDB.sh +++ b/mkDB.sh @@ -26,8 +26,5 @@ printf "Postgres logfile is %s\nPostgres socket directory is %s\n" "${pgLogFile} export OAUTH2_PGHOST="${pgSockDir}" export OAUTH2_PGLOG="${pgLogFile}" +export OAUTH2_PGDIR="${pgDir}" -zsh - -pg_ctl stop -D "${pgDir}" -rm -rvf "${pgDir}" "${pgSockDir}" "${pgLogFile}"