# For a HTML/CSS/JS website in Haskell, do I really need a Nix within Nix?

**URL:** <https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909>\
**Category:** Uncategorized\
**Created:** [February 27, 2024, 7:50pm UTC](https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909 "2024-02-27T19:50:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GengisHaskell004](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/gengishaskell004/32/3760_2.png) [@GengisHaskell004](https://discourse.haskell.org/u/GengisHaskell004)\
**Post date:** [February 27, 2024, 7:50pm UTC](https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909/1 "2024-02-27T19:50:17Z")

</div>

I have an existing cabal project that successfully does Lucid → HTML and Clay → CSS. It uses GHC. Its `flake.nix` is based on the `pkgs.haskell.packages.ghc8107` package set.

How should I add GHCJS (JavaScript) features to this project? Here is the issue:

- The haskell4nix ecosystem seems somehow “hardwired” for a single GHC (or GHCJS) at the same time. I can’t somehow magically “mix” `pkgs.haskell.packages.ghc8107` with `pkgs.haskell.packages.ghcjs` in the same environment (AFAIK).

If I’m right, what are my options? My current ideas:

- Create two separate targets in my `flake.nix`: One for the HTML/CSS stuff (the one I already have) and another one for the JavaScript stuff. I could access those environments like this: `nix develop .#htmlcss` and `nix develop .#javascript`. (And similar for `nix build`.)
- This is a problem: Since they’re two separate targets, they’ll end up in two separate `/store/*` paths, so how should I package them into a single directory/package for deployment? (Ideally the `.js` files should simply end up in the same place as the `.css` and other static files.)
- I can think of one solution: Those two Nix targets would go into an outer Nix project, and the outer Nix project would have a `postBuild` hook to merge those two inner Nix results into a single directory/package for deployment. (I could get this deployable directory/package by just running `nix build` on the outer Nix.)

Am I on the wrong path?

---

<div class="post-metadata">

**Author:** ![tristanC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tristanc/32/827_2.png) [@tristanC](https://discourse.haskell.org/u/tristanC)\
**Post date:** [February 27, 2024, 8:20pm UTC](https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909/2 "2024-02-27T20:20:39Z")

</div>

It should be fine to compose two target into a final build output. For what it’s worth, I am doing this for a rust/wasm project to create a container image with both results: [logjuicer/flake.nix](https://github.com/logjuicer/logjuicer/blob/e56c90c9e02340a55eb25bfec56cf83344e6faa8/flake.nix#L145-L157)

---

<div class="post-metadata">

**Author:** ![GengisHaskell004](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/gengishaskell004/32/3760_2.png) [@GengisHaskell004](https://discourse.haskell.org/u/GengisHaskell004)\
**Post date:** [March 3, 2024, 8:51pm UTC](https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909/3 "2024-03-03T20:51:48Z")

</div>

> [@tristanC](#):
>
> It should be fine to compose two target into a final build output.

Thanks, this is working well for me. Your logjuicer flake helped (I believe you linked to the wrong thing in your post).

I’m becoming amazed at how… versatile/general Nix is and because of this, there have to be countless ways of doing any given thing!

---

<div class="post-metadata">

**Author:** ![tristanC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tristanc/32/827_2.png) [@tristanC](https://discourse.haskell.org/u/tristanC)\
**Post date:** [March 3, 2024, 11:46pm UTC](https://discourse.haskell.org/t/for-a-html-css-js-website-in-haskell-do-i-really-need-a-nix-within-nix/8909/4 "2024-03-03T23:46:29Z")

</div>

Oops, I fixed the link. Glad to hear it helped!
