quickstart
the general flow goes like:
- use the
gleam2nixtool to generate agleam.nixfile from your gleam project’smanifest.toml - call
buildGleamApplicationto produce a derivation for your project
initial setup
Section titled “initial setup”to get gleam2nix imported, pick one of the following based on your project structure:
first, pull in this repo through whatever dependency management mechanism you prefer, such as npins, niv or just a plain ol’ fetchTarball. from the repo, you can import one of the following, based on how you want to use gleam2nix:
default.nix(recommended): contains all the packages and functions you’ll neednix/overlay.nix: an overlay function that can be added to nixpkgs.
both options will define the following:
gleam2nix: thegleam2nixcli toolbuildGleamApplication: function for building a gleam applicationbuildGleam: low-level function to compile a single gleam packagegleam-tool: helper tool used bybuildGleamandbuildGleamApplication
first, add this repo as a flake input:
inputs = { gleam2nix.url = "git+https://git.isincredibly.gay/srxl/gleam2nix"; gleam2nix.inputs.nixpkgs.follows = "nixpkgs"; # optional}the flake will have the following relevant outputs:
packages.<system>.gleam2nix: thegleam2nixcli toollib.<system>.buildGleamApplication: function for building a gleam applicationlib.<system>.buildGleam: low-level function to compile a single gleam packagegleam-tool: helper tool used bybuildGleamandbuildGleamApplicationoverlays.gleam2nix: a nixpkgs overlay that adds all of the above topkgs.
once setup, you can add gleam2nix whereever you need it. for example, in a nix shell:
pkgs.mkShell { name = "devshell"; packages = [ gleam2nix ]}run gleam2nix in the root of your project (ie. the folder containing your manifest.toml) to get a gleam.nix file. you can then pass it to a buildGleamApplication call to get your derivation:
buildGleamApplication { pname = "my_gleam_application"; version = "1.0.0"; src = ./.; gleamNix = import ./gleam.nix;}