diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..33b7d18 --- /dev/null +++ b/.envrc @@ -0,0 +1,16 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" +fi + +use flake . --impure --accept-flake-config + +# Include .env file if it exists locally. Use the .env file to load env vars that you don't want to commit to git +if [ -f .env ] +then + set -o allexport + source .env + set +o allexport +fi +# Add your env vars here +# +# E.g. export AWS_ACCESS_KEY_ID="XXXXX" \ No newline at end of file diff --git a/.ghci b/.ghci index 01a4ea9..48ee12a 100644 --- a/.ghci +++ b/.ghci @@ -1,4 +1,4 @@ :set -XNoImplicitPrelude -:def source readFile -:source build/ihp-lib/applicationGhciConfig -import IHP.Prelude +:def loadFromIHP \file -> (System.Environment.getEnv "IHP_LIB") >>= (\ihpLib -> readFile (ihpLib <> "/" <> file)) +:loadFromIHP applicationGhciConfig +import IHP.Prelude \ No newline at end of file diff --git a/.gitignore b/.gitignore index 06f03b5..d2ba403 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .DS_Store -.envrc .idea tmp result @@ -21,3 +20,8 @@ Config/client_session_key.aes # Ignore locally checked out IHP version IHP + +.devenv* +devenv.local.nix +.direnv +.env \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4089a83 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Example for Multi Record Forms + +Announced on https://github.com/digitallyinduced/ihp/releases/tag/v1.1.0 + +## Installation + +```bash +direnv allow +devenv up +``` \ No newline at end of file diff --git a/default.nix b/default.nix index f529d4b..ed98ca3 100644 --- a/default.nix +++ b/default.nix @@ -1,22 +1,9 @@ -let - ihp = builtins.fetchGit { - url = "https://github.com/digitallyinduced/ihp.git"; - rev = "c049d0e3f0f1c7fcc80f275b8307446ece00bcf0"; - }; - haskellEnv = import "${ihp}/NixSupport/default.nix" { - ihp = ihp; - haskellDeps = p: with p; [ - cabal-install - base - wai - text - hlint - p.ihp - ]; - otherDeps = p: with p; [ - # Native dependencies, e.g. imagemagick - ]; - projectPath = ./.; - }; -in - haskellEnv +# For backwards compatibility using flake.nix +(import + ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9.tar.gz"; + sha256 = "sha256:1prd9b1xx8c0sfwnyzkspplh30m613j42l1k789s521f4kv4c2z2"; + } + ) +{ src = ./.; }).defaultNix \ No newline at end of file diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a594acd --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + inputs = { + # Here you can adjust the IHP version of your project + # You can find new releases at https://github.com/digitallyinduced/ihp/releases + ihp.url = "github:digitallyinduced/ihp/v1.1"; + nixpkgs.follows = "ihp/nixpkgs"; + flake-parts.follows = "ihp/flake-parts"; + devenv.follows = "ihp/devenv"; + systems.follows = "ihp/systems"; + }; + + outputs = inputs@{ ihp, flake-parts, systems, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + + systems = import systems; + imports = [ ihp.flakeModules.default ]; + + perSystem = { pkgs, ... }: { + ihp = { + enable = true; + projectPath = ./.; + packages = with pkgs; [ + # Native dependencies, e.g. imagemagick + ]; + haskellPackages = p: with p; [ + # Haskell dependencies go here + p.ihp + cabal-install + base + wai + text + hlint + ]; + }; + }; + + }; +} \ No newline at end of file diff --git a/start b/start deleted file mode 100755 index 679a691..0000000 --- a/start +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -# Script to start the local dev server - -set -e - -# On macOS the default max count of open files is 256. IHP needs atleast 1024 to run well. -# -# The wai-static-middleware sometimes doesn't close it's file handles directly (likely because of it's use of lazy bytestrings) -# and then we usually hit the file limit of 256 at some point. With 1024 the limit is usually never hit as the GC kicks in earlier -# and will close the remaining lazy bytestring handles. -if [[ $OSTYPE == 'darwin'* ]]; then - ulimit -n 4096 -fi - -# Unless the RunDevServer binary is available, we rebuild the .envrc cache with nix-shell -# and config cachix for using our binary cache -command -v RunDevServer >/dev/null 2>&1 \ - || { echo "PATH_add $(nix-shell -j auto --cores 0 --run 'printf %q $PATH')" > .envrc; } - -# Now we have to load the PATH variable from the .envrc cache -direnv allow -eval "$(direnv hook bash)" -eval "$(direnv export bash)" - -# You can define custom env vars here: -# export CUSTOM_ENV_VAR=".." - -# Finally start the dev server -RunDevServer