zacwood9 / zacwood.me-comments

Comments on zacwood.me -- provided by utterances
1 stars 0 forks source link

posts/deploying-ihp/ #5

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Deploying IHP on a NixOS Server | Zac Wood

A step by step guide on deploying a production Haskell application on a budget!

https://zacwood.me/posts/deploying-ihp/

layeddie commented 2 years ago

Hello, Step 1: Setup IHP Project

To organize things, I create a Nix subfolder in my IHP project that contains

The code block under this section is blank when viewing with Firefox.

I am mainly interested in elixir on nix but very interested in trying IHP and running it on a vps running NixOS. Forked some of your repos to help. Trying elixir with nix on Catalina at the moment.

zacwood9 commented 2 years ago

Hey, thanks for letting me know. I've updated the page with the information needed there. Sorry about that!

layeddie commented 2 years ago

Hello Zachary,

Yes, I got it now - thanks.

Eddie Southampton UK

On Wed, Feb 9, 2022 at 3:24 PM Zachary Wood @.***> wrote:

Hey, thanks for letting me know. I've updated the page with the information needed there. Sorry about that!

— Reply to this email directly, view it on GitHub https://github.com/zacwood9/zacwood.me-comments/issues/5#issuecomment-1033878829, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHTGIEUGIQ35A33OUXM7ELU2KBK7ANCNFSM5N5PWP2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: <zacwood9/zacwood .@.***>

nomeata commented 2 years ago

Nice post! I'm surprised that there is docker in the mix - shouldn't it be possible to deploy IHP apps using only nix?

zacwood9 commented 2 years ago

@nomeata yes it is! I wrote this when I was less comfortable with nix and found working with docker easier, but I have since moved to deploying with pure nix. Works great :) would like to make another post but haven't yet gotten around to it.

nomeata commented 2 years ago

I’d be very curious about this. I am in a similar situation than you, with a small non-comercial site where I am too cheap to shell out for IHP cloud hosting, and I am running into odd things: https://github.com/digitallyinduced/ihp/discussions/1456

zacwood9 commented 2 years ago

There's a couple ways to go about it:

  1. Try replacing the haskellEnv that gets returned at the end of default.nix with

    haskellEnv.overrideAttrs (oldAttrs: {
        installPhase = oldAttrs.installPhase + ''
            ln -s "$out/lib/build/ihp-lib" "$out/IHP"
            ln -s "$out/lib/static" "$out/static"
        '';
    })

    IIRC, this was needed as the IHP build scripts make some assumptions on where to find things based on the IHP directory.

  2. Convert your project to use Cabal/Stack, and just build like a normal Haskell project. You can follow my post here: https://zacwood.me/posts/2021-12-29-ihp-cabal/

IHP purposefully ditches the traditional Haskell project setup and tooling, but for some cases I find things are much easier to work with and reason about if you go back and use everything that's been build for Cabal/Stack.

You'll have to modify the NixOS config as well to just start the executables instead of docker but that is fairly straightforward. Let me know if either of those end up working!