https://github.com/jiribenes/effekt-nix
Nix package for the Effekt programming language
https://github.com/jiribenes/effekt-nix
effekt effekt-lang nix nix-flake
Last synced: 5 months ago
JSON representation
Nix package for the Effekt programming language
- Host: GitHub
- URL: https://github.com/jiribenes/effekt-nix
- Owner: jiribenes
- Created: 2022-09-26T14:51:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-01-12T07:31:56.000Z (6 months ago)
- Last Synced: 2026-01-12T17:39:06.095Z (6 months ago)
- Topics: effekt, effekt-lang, nix, nix-flake
- Language: Nix
- Homepage:
- Size: 223 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# effekt-nix
> [!NOTE]
> Contributions are very welcome, see Contributing section below! :)
A comprehensive Nix flake for the [Effekt programming language](https://github.com/effekt-lang/effekt).
## Features
- pre-packaged Effekt compiler releases for all platforms supported by Nixpkgs, and for any subset of Effekt's backends
- building the Effekt compiler from source or from a GitHub Release
- pre-made development shells with Effekt compiler releases and for Effekt compiler development
- Nix toolchain to build, test, and package apps written in Effekt
## Quick Start
I want to quickly run Effekt!
Great! Here's how you run the latest released version of Effekt:
```sh
# run Effekt REPL
nix run github:jiribenes/effekt-nix
# run the latest version of the Effekt compiler on a file (with default backend)
nix run github:jiribenes/effekt-nix -- file.effekt
# run the latest version of the Effekt compiler on a file with the LLVM backend
nix run github:jiribenes/effekt-nix -- --backend llvm file.effekt
# run a specific version of the Effekt compiler
nix run github:jiribenes/effekt-nix#effekt_0_3_0 -- --help
```
---
I want to quickly play with Effekt!
Sure, let's get you a devshell in which you can just call `effekt` then:
```sh
# a shell with the latest Effekt version
nix develop github:jiribenes/effekt-nix
# a shell with a specific Effekt version
nix develop github:jiribenes/effekt-nix#effekt_0_3_0
# ADVANCED: a shell for developing the Effekt compiler
nix develop github:jiribenes/effekt-nix#compilerDev
```
You can use this -- for example -- for benchmarking or for working with LSP support in VSCode.
---
I want to quickly install Effekt on my machine!
Alright, let's install Effekt on your machine so that you can call `effekt` at any time:
```sh
# install latest version of Effekt
nix profile install github:jiribenes/effekt-nix
```
---
I want to quickly build Effekt on my machine!
_... okay, I guess? ..._
```sh
# builds the latest version of Effekt
nix build github:jiribenes/effekt-nix
```
The result of the build is in the `result/` folder (the binary is in `result/bin/`).
---
I want to create a new Effekt project!
You can use this Nix flake directly, but there's also a full template with CI available in [`jiribenes/effekt-template`](https://github.com/jiribenes/effekt-template).
## Example: packaging an app written in Effekt
```nix
{
inputs.effekt-nix.url = "github:jiribenes/effekt-nix";
outputs = { self, nixpkgs, effekt-nix }:
let
system = "x86_64-linux"; # or "aarch64-darwin" if you're on a M1
pkgs = nixpkgs.legacyPackages.${system};
effekt-lib = effekt-nix.lib.${system};
# You can set a fixed Effekt version and your supported backends here:
effektVersion = "0.3.0";
backends = with effekt-lib.effektBackends; [ js llvm ];
in {
# A package for your Effekt project
packages.${system}.default = effekt-lib.buildEffektPackage {
pname = "my-effekt-project";
version = "1.0.0";
src = ./.; # Path to your Effekt project
main = "./main.effekt"; # the main Effekt file to run
inherit effektVersion backends;
};
# Development shell for your project
devShell.${system}.default = effekt-lib.mkDevShell {
inherit effektVersion backends;
};
};
}
```
Here's a breakdown of `buildEffektPackage`'s arguments:
- `pname`: The name of your package.
- `version`: The version of your package.
- `src`: The source directory of your Effekt project.
- `main`: The main Effekt file to compile.
- `tests`: (Optional) A list of test files to run during the build process.
- `effekt`: (Optional) A specific Effekt derivation to use. If not provided, it uses the version specified by `effektVersion`.
- `effektVersion`: The version of Effekt to use (defaults to the latest version).
- `backends`: A list of backends to compile your project with. The first backend in the list is considered the default.
- `buildInputs`: (Optional) Additional build inputs required for your package.
The function will compile your project with all specified backends and create a binary for each.
It also sets up a symbolic link to the default backend's binary under the `pname`.
`effekt-nix` also supports multiple platforms. Use `flake-utils` and its `flake-utils.lib.eachDefaultSystem` (or alternatives)
to define outputs for multiple systems at the same time.
### Using a custom Effekt compiler build for your app
```nix
{
inputs.effekt-nix.url = "github:jiribenes/effekt-nix";
outputs = { self, nixpkgs, effekt-nix }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
effekt-lib = effekt-nix.lib.${system};
# Define your own Effekt build from source:
myCustomEffekt = effekt-lib.buildEffektFromSource {
# ... by defining the path to your compiler source here:
src = ./path/to/effekt/compiler/source;
backends = with effekt-lib.effektBackends; [ js llvm ];
};
in {
packages.${system}.default = effekt-lib.buildEffektPackage {
pname = "my-custom-effekt-project";
version = "1.0.0";
src = ./.; # Path to your Effekt project
main = "./src/main.effekt"; # path to the entrypoint
tests = [ "./src/mytest.effekt" ]; # path to the tests
effekt = myCustomEffekt;
};
devShell.${system}.default = effekt-lib.mkDevShell {
effekt = myCustomEffekt;
};
};
}
```
## Contributing
Contributions of all kinds are very welcome, feel free to just create a PR.
We would especially welcome contributions fixing the various [issues](https://github.com/jiribenes/effekt-nix/issues) this project has
and/or with the [WIP PRs](https://github.com/jiribenes/effekt-nix/pulls) that aren't done yet.