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
12 changes: 12 additions & 0 deletions .ci/attic-auth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -uo pipefail

mkdir -p ~/.config/attic
cat <<EOF > ~/.config/attic/config.toml
default-server = "public"

[servers.public]
endpoint = "http://192.168.102.136:9200"
token = "$ATTIC_AUTH_TOKEN"
EOF
82 changes: 80 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
jobs:
stack:
name: Stack tests
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -142,6 +142,82 @@ jobs:
run: |
.ci/test_whitespace.sh

packages:
name: Push package to cache
runs-on: self-hosted
strategy:
matrix:
ghc-version: [ "ghc9101", "ghc982", "ghc964" ]
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

# Pushes the binaries to the local network
# url: http://192.168.102.136:9200/public
# public key: public:PGGlJMx1gGmU069blMqve8tS1ndzBuriUAwGBHGOo4g=
- name: Push package to cache
env:
ATTIC_AUTH_TOKEN: ${{ secrets.ATTIC_SECRET }}
run: |
.ci/attic-auth.sh
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
if: github.ref == 'refs/heads/main'
env:
# Having the variable be named `CACHIX_AUTH_TOKEN` authenticates cachix
# https://docs.cachix.org/getting-started#authenticating
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_SECRET }}
run: |
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 cache
runs-on: self-hosted
strategy:
matrix:
ghc-version: [ "ghc9101", "ghc982", "ghc964" ]
steps:
# There's no need to configure Nix, the dockerfile handling the GHA has it done for us!
# If dependencies are already cached, we can simply reuse 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 -L .#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_AUTH_TOKEN: ${{ secrets.ATTIC_SECRET }}
run: |
.ci/attic-auth.sh
attic push public $(nix path-info .#devShells.x86_64-linux.${{ matrix.ghc-version }}-full)

# Pushes the binaries to Cachix
- name: Push devshell to cachix
if: github.ref == 'refs/heads/main'
env:
# Having the variable be named `CACHIX_AUTH_TOKEN` authenticates cachix
# https://docs.cachix.org/getting-started#authenticating
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_SECRET }}
run: |
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 @@ -151,8 +227,10 @@ jobs:
fourmolu,
linting,
stack,
packages,
devshells,
]
runs-on: ubuntu-22.04
runs-on: self-hosted
Comment on lines -155 to +233
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another tiny job I think is best run on GitHub-hosted runners.

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,36 @@ in

And that's it!

### Cache

Compiling Clash can take quite some time. To remedy the situation, we maintain a Cachix cache which can be used to speed up compilation. To add the cache, first (temporarily) install cachix:

`nix shell nixpkgs#cachix`

And then run:

`cachix use clash-lang`

And that's it! The cache is now set up and you no longer need cachix installed.

Alternatively you can add the cache manually to your `nix.conf` file. Simply add the following two configurations:
```conf
extra-substituters = https://clash-lang.cachix.org
extra-trusted-public-keys = clash-lang.cachix.org-1:/2N1uka38B/heaOAC+Ztd/EWLmF0RLfizWgC5tamCBg=
```
If a project specific cache is preferred, using a `flake.nix` with the following will only make the cache active for the specific project of the flake:
```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 = ...;
}
```

# TODO

0.1
Expand Down