generated from jiribenes/effekt-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7e212a1
Showing
13 changed files
with
486 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flake.lock linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Effekt | ||
out | ||
|
||
# Nix | ||
result | ||
result-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"effekt-lang.effekt" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
- Go to Settings -> Actions -> General and check "Allow GitHub Actions to create and approve pull requests" | ||
in order to get weekly Pull Requests on Tuesday that update the Effekt version in CI. | ||
- See the [CI](#ci) section for more details | ||
|
||
3. Replace this `README` with your own! | ||
- Please link back to this repo if you can :) | ||
|
||
## 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) |
Oops, something went wrong.