Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
OriginalCpp authored Dec 4, 2024
0 parents commit 7e212a1
Show file tree
Hide file tree
Showing 13 changed files with 486 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock linguist-generated=true
41 changes: 41 additions & 0 deletions .github/workflows/flake-check.yml
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
16 changes: 16 additions & 0 deletions .github/workflows/update-flake-lock.yml
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Effekt
out

# Nix
result
result-*
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"effekt-lang.effekt"
]
}
78 changes: 78 additions & 0 deletions .vscode/tasks.json
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": []
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
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.
127 changes: 127 additions & 0 deletions README.md
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)
Loading

0 comments on commit 7e212a1

Please sign in to comment.