aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.github/workflows/flake-check.yml41
-rw-r--r--.github/workflows/update-flake-lock.yml16
-rw-r--r--.gitignore6
-rw-r--r--.vscode/extensions.json5
-rw-r--r--.vscode/tasks.json78
-rw-r--r--LICENSE21
-rw-r--r--README.md127
-rw-r--r--flake.lock111
-rw-r--r--flake.nix62
-rw-r--r--src/lib.effekt3
-rw-r--r--src/main.effekt5
-rw-r--r--src/test.effekt10
13 files changed, 486 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..af4fe8b
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+flake.lock linguist-generated=true
diff --git a/.github/workflows/flake-check.yml b/.github/workflows/flake-check.yml
new file mode 100644
index 0000000..43a6da2
--- /dev/null
+++ b/.github/workflows/flake-check.yml
@@ -0,0 +1,41 @@
+# Taken with permission from https://github.com/tsandrini/flake-parts-builder/blob/9eda2d9a7bc6949568147acaecb60ef9a7ab4552/flake-parts/gh-actions-check/.github/workflows/flake-check.yml
+name: Check Nix flake
+
+on:
+ workflow_dispatch: # allows manual triggering from the Actions UI
+ push:
+ branches:
+ - main
+ pull_request:
+ types: [opened, reopened, synchronize]
+ repository_dispatch:
+ types: [create-pull-request]
+
+jobs:
+ flake-check:
+ runs-on: "ubuntu-latest"
+ steps:
+ - name: "Checking out repository..."
+ uses: actions/checkout@v4
+
+ - name: "Installing and configuring the nix package manager..."
+ uses: DeterminateSystems/nix-installer-action@main
+ with:
+ extra-conf: |
+ accept-flake-config = true
+
+ - name: "Setting up magic-nix-cache..."
+ uses: DeterminateSystems/magic-nix-cache-action@main
+
+ - name: "Setting up packages..."
+ run: |
+ nix profile install nixpkgs#nix-fast-build # parallel nix builder
+
+ - name: "Running `nix build ...`..."
+ run: nix-fast-build --skip-cached --no-nom --flake ".#packages"
+
+ - name: "Running `nix develop...`..."
+ run: nix-fast-build --skip-cached --no-nom --flake ".#devShells"
+
+ - name: "Checking flake inputs for stale & insecure nixpkgs versions..."
+ uses: DeterminateSystems/flake-checker-action@main
diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml
new file mode 100644
index 0000000..fa5cf61
--- /dev/null
+++ b/.github/workflows/update-flake-lock.yml
@@ -0,0 +1,16 @@
+name: update-flake-lock
+on:
+ workflow_dispatch: # allows manual triggering
+ schedule:
+ - cron: '0 0 * * 2' # runs weekly on Tuesday at 00:00 UTC
+
+jobs:
+ lockfile:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@main
+ - name: Update flake.lock
+ uses: DeterminateSystems/update-flake-lock@main
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..eb54424
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+# Effekt
+out
+
+# Nix
+result
+result-*
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..7b90cd2
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "effekt-lang.effekt"
+ ]
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..7b4112f
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,78 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "Run Effekt Main",
+ "type": "shell",
+ "command": "effekt",
+ "args": [
+ "src/main.effekt"
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ },
+ "problemMatcher": []
+ },
+ {
+ "label": "Run Effekt Tests",
+ "type": "shell",
+ "command": "effekt",
+ "args": [
+ "src/test.effekt"
+ ],
+ "group": "test",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ },
+ "problemMatcher": []
+ },
+ {
+ "label": "Nix Run",
+ "type": "shell",
+ "command": "nix",
+ "args": [
+ "run"
+ ],
+ "group": "none",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ },
+ "problemMatcher": []
+ },
+ {
+ "label": "Nix Build",
+ "type": "shell",
+ "command": "nix",
+ "args": [
+ "build"
+ ],
+ "group": "build",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ },
+ "problemMatcher": []
+ },
+ {
+ "label": "Nix Develop Shell",
+ "type": "shell",
+ "command": "nix",
+ "args": [
+ "develop"
+ ],
+ "group": "none",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ },
+ "problemMatcher": []
+ }
+ ]
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1fa8454
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 The Effekt research team
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c5a52f2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,127 @@
+# Effekt Template
+
+> [!WARNING]
+> This is a work-in-progress, feel free to contribute!
+
+This template provides a starting point for Effekt projects.
+
+## Table of contents
+
+- [First steps](#first-steps)
+- [Useful commands](#useful-commands)
+ - [Effekt commands](#effekt-commands)
+ - [Nix-related commands](#nix-related-commands)
+- [Example projects](#example-projects-using-this-template)
+- [Repository structure](#repository-structure)
+- [CI](#ci)
+
+---
+
+## First steps
+
+After using this template, follow these steps to set up your project:
+
+1. Set up your development environment:
+ - Clone this repository locally.
+ - Open it in VSCode.
+ - Install the Effekt VSCode extension offered in the pop-up in the bottom right.
+
+2. Customize the project:
+ - Open `flake.nix` and update the project name and other relevant values (follow the comments).
+ - Push your `flake.nix` file after the changes and see if the CI agrees.
+
+3. Set-up auto-update CI in order to get weekly PRs on Tuesday which update the Effekt version in CI:
+ - Go to Settings -> Actions -> General:
+ - and set "Workflow permissions" to "Read and write permissions"
+ - and check "Allow GitHub Actions to create and approve pull requests"
+ - See the [CI](#ci) section for more details
+
+3. Replace this `README` with your own!
+
+## Useful commands
+
+### Effekt commands
+
+Run the main file:
+```sh
+effekt src/main.effekt
+```
+This (like many other Effekt commands) uses the JavaScript backend by default.
+To use a different backend, add the `--backend <backend>` flag.
+
+Run the tests:
+```sh
+effekt src/test.effekt
+```
+
+Open the REPL:
+```sh
+effekt
+```
+
+Build the project:
+```sh
+effekt --build src/main.effekt
+```
+This builds the project into the `out/` directory, creating a runnable file `out/main`.
+
+To see all available options and backends, run:
+```sh
+effekt --help
+```
+
+### Nix-related commands
+
+While Nix installation is optional, it provides several benefits:
+
+Update dependencies (also runs automatically in CI):
+```sh
+nix flake update
+```
+
+Open a shell with all necessary dependencies:
+```sh
+nix develop
+```
+
+Run the main entry point:
+```sh
+nix run
+```
+
+Build the project (output in `result/bin/`):
+```sh
+nix build
+```
+
+## Example projects using this template
+
+- [`effekt-stm`](https://github.com/jiribenes/effekt-stm)
+- This very project!
+
+## Repository structure
+
+- `.github/workflows/*.yml`: Contains the [CI](#ci) definitions
+- `src/`: Contains the source code
+ - `main.effekt`: Main entry point
+ - `test.effekt`: Entry point for tests
+ - `lib.effekt`: Library code imported by `main` and `test`
+- `flake.nix`: Package configuration in a Nix flake
+- `flake.lock`: Auto-generated lockfile for dependencies
+- `LICENSE`: Project license
+- `README`: This README file
+
+## CI
+
+Two GitHub Actions are set up:
+
+1. `flake-check`:
+ - Checks the `flake.nix` file, builds and tests the project
+ - Runs on demand, on `main`, and on PRs
+ - To run custom commands, add a step using:
+ - `nix run -- <ARGS>` to run the main entry point with the given arguments
+ - `nix develop -c '<bash command to run>'` to run commands in the correct environment
+
+2. `update-flake-lock`:
+ - Updates package versions in `flake.nix`
+ - Runs on demand and weekly (Tuesdays at 00:00 UTC)
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..828937d
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,111 @@
+{
+ "nodes": {
+ "effekt-nix": {
+ "inputs": {
+ "flake-utils": [
+ "flake-utils"
+ ],
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "sbt-derivation": "sbt-derivation"
+ },
+ "locked": {
+ "lastModified": 1733727952,
+ "narHash": "sha256-wCfbB6U04sc+SDVb3ycql3mKVQaAK6/Ic7Aj6hGUMJI=",
+ "owner": "jiribenes",
+ "repo": "effekt-nix",
+ "rev": "193869f3b608f4793eafddb09bf91ccb2d7fccf6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "jiribenes",
+ "repo": "effekt-nix",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1733656523,
+ "narHash": "sha256-w0FXPfpGhOihoJDiwMsyN1EzpsXi2F8VQ+NVZQSMtys=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "93dc9803a1ee435e590b02cde9589038d5cc3a4e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "effekt-nix": "effekt-nix",
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "sbt-derivation": {
+ "inputs": {
+ "flake-utils": [
+ "effekt-nix",
+ "flake-utils"
+ ],
+ "nixpkgs": [
+ "effekt-nix",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1698464090,
+ "narHash": "sha256-Pnej7WZIPomYWg8f/CZ65sfW85IfIUjYhphMMg7/LT0=",
+ "owner": "zaninime",
+ "repo": "sbt-derivation",
+ "rev": "6762cf2c31de50efd9ff905cbcc87239995a4ef9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "zaninime",
+ "repo": "sbt-derivation",
+ "type": "github"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..fe7c09f
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,62 @@
+{
+ ## TODO: Change to your project's description:
+ description = "Nix template for Effekt projects";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ effekt-nix = {
+ url = "github:jiribenes/effekt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ inputs.flake-utils.follows ="flake-utils";
+ };
+ };
+
+ outputs = { self, nixpkgs, flake-utils, effekt-nix }:
+ ## If you want only some specific systems, do the following instead:
+ # flake-utils.lib.eachSystem ["aarch64-linux" "aarch64-darwin"] (system:
+ flake-utils.lib.eachDefaultSystem (system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ effekt-lib = effekt-nix.lib.${system};
+
+ ## Project configuration
+ # TODO: Change to your project's details:
+ pname = "effekt-template"; # package name
+ version = "0.1.0"; # package version
+ mainFile = "src/main.effekt"; # relative path to entrypoint (as a string)
+ testFiles = [ "src/test.effekt" ]; # relative paths to tests (as a string)
+
+ ## Effekt configuration
+ effektConfig = {
+ ## Uncomment and set a specific version if needed:
+ # version = "0.10.0";
+
+ ## Select the backends that your project works on:
+ backends = with effekt-lib.effektBackends; [ js ];
+ };
+
+ # Chooses the correct Effekt package.
+ effektBuild = effekt-lib.getEffekt effektConfig;
+ in {
+ packages.default = effekt-lib.buildEffektPackage {
+ inherit pname version;
+ src = ./.;
+ main = mainFile;
+ tests = testFiles;
+
+ effekt = effektBuild;
+ inherit (effektConfig) backends;
+ };
+
+ devShells.default = effekt-lib.mkDevShell {
+ effekt = effektBuild;
+ };
+
+ apps.default = flake-utils.lib.mkApp {
+ drv = self.packages.${system}.default;
+ name = pname;
+ };
+ }
+ );
+}
diff --git a/src/lib.effekt b/src/lib.effekt
new file mode 100644
index 0000000..d997f03
--- /dev/null
+++ b/src/lib.effekt
@@ -0,0 +1,3 @@
+module src/lib
+
+def helloWorld(): String = "Hello, world!" \ No newline at end of file
diff --git a/src/main.effekt b/src/main.effekt
new file mode 100644
index 0000000..35e7955
--- /dev/null
+++ b/src/main.effekt
@@ -0,0 +1,5 @@
+module main // must be named same as the file!
+
+import src/lib
+
+def main(): Unit = println(helloWorld()) \ No newline at end of file
diff --git a/src/test.effekt b/src/test.effekt
new file mode 100644
index 0000000..d0244bc
--- /dev/null
+++ b/src/test.effekt
@@ -0,0 +1,10 @@
+module src/test
+
+import test
+import src/lib
+
+def main() = mainSuite("lib") {
+ test("Hello world") {
+ assertEqual(helloWorld(), "Hello, world!")
+ }
+}