Skip to content

obsidiansystems/rhyolite

Repository files navigation

Rhyolite

Obelisk Haskell Built with Nix BSD3 License

Rhyolite is a collection of packages used to jump-start web application development using Obelisk and reflex.

Rhyolite provides:

  • a client/server communication framework for both request/response APIs and live-updating queries; and
  • a library of types and components commonly used when building a web application.

Using Rhyolite with an Obelisk project

  1. Within an already initialized Obelisk project, clone Rhyolite into the dep directory, if you haven’t already:

    git clone https://github.com/obsidiansystems/rhyolite dep/rhyolite
  2. Add Rhyolite’s haskellOverrides to default.nix so that your package can access them. This involves adding overrides to the arguments passed to Obelisk’s project function so that it imports Rhyolite’s haskellOverrides. You can base it off of this example:

    { system ? builtins.currentSystem, obelisk ? import ./.obelisk/impl {
      inherit system;
      iosSdkVersion = "13.2";
    
      # You must accept the Android Software Development Kit License Agreement at
      # https://developer.android.com/studio/terms in order to build Android apps.
      # Uncomment and set this to `true` to indicate your acceptance:
      # config.android_sdk.accept_license = false;
    
      # In order to use Let's Encrypt for HTTPS deployments you must accept
      # their terms of service at https://letsencrypt.org/repository/.
      # Uncomment and set this to `true` to indicate your acceptance:
      # terms.security.acme.acceptTerms = false;
    } }:
    with obelisk;
    project ./. ({ pkgs, hackGet, ... }@args: {
    
      overrides = pkgs.lib.composeExtensions
        (pkgs.callPackage (hackGet ./dep/rhyolite) args).haskellOverrides
        (self: super:
          with pkgs.haskell.lib;
          {
            # Your custom overrides go here.
          });
    
      android.applicationId = "systems.obsidian.obelisk.examples.minimal";
      android.displayName = "Obelisk Minimal Example";
      ios.bundleIdentifier = "systems.obsidian.obelisk.examples.minimal";
      ios.bundleName = "Obelisk Minimal Example";
    })
    
  3. You can now add any of Rhyolite’s packages as dependencies to your Obelisk project. The packages Rhyolite provides are listed in cabal.project.

Alternative method

You can also let Rhyolite manage Obelisk directly. This is easier to setup but also means that you are stuck with the Obelisk version used by Rhyolite.

To do this, simply overwrite the .obelisk/impl/github.json file with this Rhyolite thunk:

{
  "owner": "obsidiansystems",
  "repo": "rhyolite",
  "branch": "master",
  "private": false,
  "rev": "9f13d8d8a2233aae54e15c39acf68181893b859a",
  "sha256": "1vhbw9bdqpfddavfjfdrq6kk5wwsd8hbgb8pnna9i2db3x3cmzvy"
}

Hacking

Entering a shell

You can use nix-shell -A proj.shells.ghc to enter a shell from which you can build any of the subprojects in this repository. From that shell you can:

  • Enter a shell using cabal repl /path/to/package
  • Use ghcid by invoking ghcid -c "cabal repl /path/to/package
  • Build a package using cabal build /path/to/package
  • Generate haddock documentation using cabal haddock /path/to/package (e.g., cabal haddock notify-listen/notify-listen-beam)
  • Generate a standalone haddock page for all the packages in this repo by running ./gen-docs.sh

Testing that things build

Because of the inter-related nature of these packages, rhyolite-test-suite tests that all of them can be built against one another. To test, run:

nix-shell -A proj.shells.ghc --run "cabal build test"