diff --git a/.gitignore b/.gitignore index 9ef034d..1c46f91 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ matabas-db/ +artifacts/ \ No newline at end of file diff --git a/buildScripts/build.sh b/buildScripts/build.sh new file mode 100755 index 0000000..fbbb5eb --- /dev/null +++ b/buildScripts/build.sh @@ -0,0 +1,14 @@ +set -e + +mkdir -p artifacts + +log "Kompilerar backend..." +find backend -type f -and -name '*.hs' -print0 \ + | xargs -0 ghc -o artifacts/Main \ + -odir artifacts \ + -hidir artifacts \ + -tmpdir artifacts + +log "Klar" "!" + +set +e diff --git a/build/devShellHook.sh b/buildScripts/devShellHook.sh similarity index 89% rename from build/devShellHook.sh rename to buildScripts/devShellHook.sh index 96f0042..6ab2985 100644 --- a/build/devShellHook.sh +++ b/buildScripts/devShellHook.sh @@ -35,6 +35,16 @@ createdb -p "$PGPORT" matabas 2>>./matabas-db/matabas.log || log "Matabasen finn log "Ställer in schema.sql" psql -p "$PGPORT" "$PBDATABASE" < schema.sql +P="$PWD" +clean() { + log "Rensar byggnad" + rm -rf artifacts +} + +build() { + source "$P/buildScripts/build.sh" +} + log "Redo" "!" set +e diff --git a/flake.nix b/flake.nix index a4c9aec..472f588 100644 --- a/flake.nix +++ b/flake.nix @@ -14,8 +14,12 @@ default = pkgs.hello; }; devShells.default = pkgs.mkShell { - packages = [ packages.default pkgs.postgresql_15_jit pkgs.cargo ]; - shellHook = builtins.readFile ./build/devShellHook.sh ; + packages = [ + packages.default + pkgs.postgresql_15_jit + ( pkgs.ghc.withPackages (ps: with ps; [ scotty postgresql-typed ]) ) + ]; + shellHook = builtins.readFile ./buildScripts/devShellHook.sh ; }; } ) // {