Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,73 @@ jobs:
run: |
.ci/test_whitespace.sh

packages:
name: Push package to local cache
runs-on: self-hosted
strategy:
matrix:
ghc-version: [ "ghc9101", "ghc982", "ghc964" ]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build & test
run: |
# The -L flag outputs build logs to stderr
nix build -L .#${{ matrix.ghc-version }}.clash-protocols-base
nix build -L .#${{ matrix.ghc-version }}.clash-protocols
- name: Push package to cache
env:
ATTIC_TOKEN: ${{ secrets.ATTIC_SECRET }}
run: |
attic login --set-default public http://192.168.102.136:9200/ "$ATTIC_TOKEN"
attic push public $(nix path-info .#${{ matrix.ghc-version }}.clash-protocols-base)
attic push public $(nix path-info .#${{ matrix.ghc-version }}.clash-protocols)
- name: Push package to cachix
env:
CACHIX_TOKEN: ${{ secrets.CACHIX_SECRET }}
run: |
cachix authtoken $CACHIX_TOKEN
nix path-info .#${{ matrix.ghc-version }}.clash-protocols-base | cachix push clash-lang
nix path-info .#${{ matrix.ghc-version }}.clash-protocols | cachix push clash-lang

devshells:
name: Push Nix developer shell to local cache
runs-on: self-hosted
strategy:
matrix:
ghc-version: [ "ghc9101", "ghc982", "ghc964" ]
if: github.ref == 'refs/heads/main'
steps:
# There's no need to configure Nix, the dockerfile handling the GHA has it done for us!
# If a dependencies are already cached, we can simply re-use them!

- name: Checkout
uses: actions/checkout@v4

- name: Build devshell
run: |
# Since the server is x86_64-linux, we can only build the devshell
# for that
nix build .#devShells.x86_64-linux.${{ matrix.ghc-version }}-full
# Pushes the binaries to the local network
# url: http://192.168.102.136:9200/public
# public key: public:PGGlJMx1gGmU069blMqve8tS1ndzBuriUAwGBHGOo4g=
- name: Push devshell to cache
env:
ATTIC_TOKEN: ${{ secrets.ATTIC_SECRET }}
run: |
attic login --set-default public http://192.168.102.136:9200/ "$ATTIC_TOKEN"
attic push public $(nix path-info .#devShells.x86_64-linux.${{ matrix.ghc-version }}-full)
# Pushes the binaries to Cachix
- name: Push devshell to cachix
env:
CACHIX_TOKEN: ${{ secrets.CACHIX_SECRET }}
run: |
cachix authtoken $CACHIX_TOKEN
nix path-info .#devShells.x86_64-linux.${{ matrix.ghc-version }}-full | cachix push clash-lang

# Mandatory check on GitHub
all:
name: All jobs finished
Expand All @@ -185,6 +252,8 @@ jobs:
fourmolu,
linting,
stack,
packages,
devshells,
]
runs-on: ubuntu-22.04
steps:
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,33 @@ This project exposes several Nix flake outputs. Most notibly the `clash-protocol

Contributing to `clash-protocols` can be done via the developer shell exposed by the Nix flake. Open a terminal and typing: `nix develop`. Optionally a specific GHC version can be selected as well as a `-minimal` or `-full` version. The `-minimal` shell does **NOT** contain the Haskell Language Server, whilst the `-full` shell does. When using the developer shell, do not forget to remove the `cabal.project` file. This file contains a package source and Cabal prioritizes local package sources over Nix sources. Removing the `cabal.project` file should work fine when developing with Nix.

Compiling Clash and all dependencies related to it may take a long time. To remidy long compilation times, you can make use of the publically available cache on Cachix:

## Cachix (binary cache)

Cachix contains all commits on the main branch of `clash-cores` since the cache has been setup. It is recommended to add the publically available cachix cache to your project/computer to minimize the amount of time manually compiling Clash related dependencies.

You can either add user-wide on your local system via `nix.conf` (usually located under `~/.config/nix`, create it if it does not exist):
```conf
extra-substituters = https://clash-lang.cachix.org
extra-trusted-public-keys = clash-lang.cachix.org-1:/2N1uka38B/heaOAC+Ztd/EWLmF0RLfizWgC5tamCBg=
```

Or as part of your `flake.nix` in your local project:
```nix
{
nixConfig = {
extra-substituters = [ "https://clash-lang.cachix.org" ];
extra-trusted-public-keys = [ "clash-lang.cachix.org-1:/2N1uka38B/heaOAC+Ztd/EWLmF0RLfizWgC5tamCBg=" ];
};
description = ...;
inputs = ...;
outputs = ...;
}
```

## As a dependency

You can also add this project as a Nix-dependency. This project depends on `clash-compiler`, the recommended way to add this to your project as a Nix dependency is as follows:

First add `clash-compiler` and `clash-protocols` to your flake inputs:
Expand Down