From 87def41367511b97bbce9a25601f70a0b427cc50 Mon Sep 17 00:00:00 2001 From: Aron Novak Date: Fri, 17 Nov 2023 09:49:42 +0000 Subject: [PATCH 1/2] Update deployment.markdown --- Guide/deployment.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/Guide/deployment.markdown b/Guide/deployment.markdown index f67ac5007..d18d7eb2f 100644 --- a/Guide/deployment.markdown +++ b/Guide/deployment.markdown @@ -67,6 +67,7 @@ flake.nixosConfigurations."ihp-app" = nixpkgs.lib.nixosSystem { ``` In the first line the `"ihp-app"` needs to be the same as your SSH name from the previous section. +Make sure you put this into the `flake-parts.lib.mkFlake` block. ### Deploying the App From 174075dd1e9ed5ec920290301d703ce1575140ec Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Fri, 17 Nov 2023 11:16:48 -0800 Subject: [PATCH 2/2] Added more specific example --- Guide/deployment.markdown | 70 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/Guide/deployment.markdown b/Guide/deployment.markdown index d18d7eb2f..f755c8148 100644 --- a/Guide/deployment.markdown +++ b/Guide/deployment.markdown @@ -67,7 +67,75 @@ flake.nixosConfigurations."ihp-app" = nixpkgs.lib.nixosSystem { ``` In the first line the `"ihp-app"` needs to be the same as your SSH name from the previous section. -Make sure you put this into the `flake-parts.lib.mkFlake` block. + +Make sure you put this into the `flake-parts.lib.mkFlake` block. The final `flake.nix` should look like this: + +```diff +{ + inputs = { + ihp.url = "github:digitallyinduced/ihp/v1.2"; + 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 + ]; + }; + }; + ++ flake.nixosConfigurations."ihp-app" = nixpkgs.lib.nixosSystem { ++ system = "x86_64-linux"; ++ specialArgs = inputs; ++ modules = [ ++ "${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix" ++ ihp.nixosModules.appWithPostgres ++ ({ ... }: { ++ security.acme.defaults.email = "me@example.com"; ++ ++ services.ihp = { ++ domain = "myihpapp.com"; ++ migrations = ./Application/Migration; ++ schema = ./Application/Schema.sql; ++ fixtures = ./Application/Fixtures.sql; ++ sessionSecret = "xxx"; ++ }; ++ ++ # Add swap to avoid running out of memory during builds ++ # Useful if your server have less than 4GB memory ++ swapDevices = [ { device = "/swapfile"; size = 8192; } ]; ++ ++ # This should reflect the nixos version from the NixOS AMI initally installed ++ # After the initial install, it should not be changed. Otherwise e.g. the postgres ++ # server might need a manual data migration if NixOS changes the default postgres version ++ system.stateVersion = "23.05"; ++ }) ++ ]; ++ }; + + }; +} +``` ### Deploying the App