Basic Usage
Before you start, note that you can give Glistix a try in your browser without installing anything! You can try it out in the playground at https://glistix.github.io/playground. Read the book page about the playground for more information.
Once you're ready, make sure to install the Glistix compiler to your computer. Afterwards, here's how you can start working on a new Glistix project straight away:
-
Use the
glistix new NAMEcommand to create a new Glistix project.-
This command will set (almost) everything up for you, including initialize a Git repository, initialize the project structure (
gleam.toml,src/,test/etc.), prepare essential*.nixfiles, and even clone Glistix's standard library toexternal/stdlibas a Git submodule (this is a workaround which is currently needed while we don't have Git dependencies!). -
We also generate a default GitHub Actions CI workflow file which tries to build your project through
flake.nix. You can add--skip-githubtoglistix newto opt out of the creation of this file (or just delete it).
-
-
You can edit
srcto customize the Gleam code, as well as editgleam.tomlto your liking.-
You can use
glistix add nameto add a dependency from Hex. For instance, you may want to use theglistix_nixpackage to easily access certain Nix built-in types from Gleam, which can be done withglistix add glistix_nix.- If your desired dependency doesn't support Nix, you will have to use a fork patched for Nix support. Check "Overriding incompatible packages" for more information.
-
Note that Git dependencies are not yet supported by Glistix. If you need those, you'll have to clone them as submodules and use as local dependencies. See Limitations for more information.
-
-
Run
glistix buildat least once, not only to make sure everything is working, but also to generate themanifest.toml(which should be checked into your repository). -
Afterwards, to complete the Nix side of your setup, ensure you have Nix with flakes support available (the
nixcommand), as well as rungit add .so all relevant files are checked in, and then run the command below to generate yourflake.lock.nix flake update
Nice! Your project is now ready to be used by both Nix users (which will use your Gleam code compiled to Nix) and also other Glistix users.
To import a Gleam module in your project from within Nix, the default.nix and flake.nix files in your new project export a lib.loadGlistixPackage { module = "module/name"; } function, which, when used, will give you an attribute set with all names exported by that module, so you can use its record constructors, constants and functions from within Nix. See "Import a Gleam package in Nix" for more information.