Skip to content
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cc1f30a
PoC: Replace haskell.nix with stacklock2nix
sestrella Mar 24, 2025
f1c8585
Build hapistrano in Linux
fm7-1 Mar 24, 2025
c097625
Upgrade stack.yaml
sestrella Mar 24, 2025
fe6482c
Add missing all-cabal-hashes
sestrella Mar 25, 2025
2cb8394
Fix package boundaries warnings
sestrella Mar 25, 2025
949f07f
Disable tests for hapistrano package
sestrella Mar 25, 2025
0054b44
Override testToolDepends for hapistrano
sestrella Mar 25, 2025
8b064d2
Support all nix default systems
sestrella Mar 25, 2025
3db5094
Add overlay
sestrella Mar 25, 2025
ae95d76
Add devenv example
sestrella Mar 25, 2025
ea1888f
Remove flake-utils
sestrella Mar 25, 2025
27116be
Refactor forAllSystems
sestrella Mar 25, 2025
ac44f4d
Conditional sha256 based on platform
sestrella Mar 25, 2025
e92b432
Extract overlay to a separate file
sestrella Mar 25, 2025
b399411
Building on the CI
sestrella Mar 25, 2025
c4312c6
Setup binary cache
sestrella Mar 25, 2025
f9e8904
Remove `allow-newer` flag from `stack.yaml`
sestrella Mar 25, 2025
a326ae1
Add non-Nix build
sestrella Mar 27, 2025
2ab375b
Install devenv
sestrella Mar 27, 2025
cf2e995
Shorten feedback loop for build job
sestrella Mar 27, 2025
faf199a
Install GHC via Nix
sestrella Mar 27, 2025
f1238ea
Try macos-latest runner
sestrella Mar 27, 2025
9fbc637
Cache dependencies
sestrella Mar 27, 2025
0811fac
Compile and run tests
sestrella Mar 27, 2025
e095cb0
Enable ubuntu-latest runner
sestrella Mar 27, 2025
7ecb77f
Install gmp for Linux
sestrella Mar 27, 2025
cf528f8
Set locale
sestrella Mar 27, 2025
abc8f34
Add missing descriptions to jobs' steps
sestrella Mar 27, 2025
d1f71d3
Remove `devenv` example
sestrella Mar 27, 2025
4651882
Add comments about keeping GHC version in sync
sestrella Mar 27, 2025
b0f77f1
Enable docker job / Remove bin folder
sestrella Mar 27, 2025
c2276d8
Update NIX documentation via claude
sestrella Mar 27, 2025
179ebdd
Update lock files
sestrella Mar 27, 2025
5b39e5c
Revert "Update lock files"
sestrella Mar 27, 2025
0fb41a1
Remove duplicated entries from `.gitignore`
sestrella Mar 27, 2025
abcc21d
Add aarch64-linux and x86_64-darwin runners
sestrella Mar 28, 2025
3fb96c8
Remove macos-13 and ubuntu-24.04-arm runners to reduce storage usage …
sestrella Mar 28, 2025
9a9521a
Print warning for untested systems
sestrella Mar 28, 2025
f48c3e8
Revert changes made to package constraints lower bound to avoid break…
sestrella Mar 28, 2025
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
6 changes: 5 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
use flake
export DIRENV_WARN_TIMEOUT=20s

eval "$(devenv direnvrc)"

use devenv
77 changes: 61 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,76 @@ on:
types:
- opened
- synchronize

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
haskell:
build:
strategy:
matrix:
runner:
- macos-latest
- ubuntu-latest
runs-on: ${{ matrix.runner }}
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Setup Cachix
uses: cachix/cachix-action@v16
with:
name: devenv
- name: Install devenv
run: nix profile install nixpkgs#devenv
- name: Setup cache for `~/.stack`
uses: actions/cache@v4
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('hapistrano.cabal') }}
restore-keys: |
${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-
${{ runner.os }}-stack-global-
- name: Install dependencies
run: devenv shell -- stack build --only-dependencies --test
- name: Setup cache for `.stack-work`
uses: actions/cache@v4
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('hapistrano.cabal') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('hapistrano.cabal') }}-
${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-
${{ runner.os }}-stack-work-
- name: Compile code
run: devenv shell -- stack build --test --no-run-tests
- name: Run tests
run: devenv shell -- stack test

nix-build:
strategy:
matrix:
os:
- macos-13 # x86_64-darwin
- macos-latest # aarch64-darwin
- ubuntu-latest # x86_64-linux
fail-fast: true
runs-on: ${{ matrix.os }}
timeout-minutes: 30
runner:
- macos-latest
- ubuntu-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v12
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Setup Cachix
uses: cachix/cachix-action@v16
Comment on lines +75 to +76
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

with:
extra-conf: accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@v7
- name: Compile code ${{ matrix.ghc }}
run: nix build .#test
- name: Run tests ${{ matrix.ghc }}
run: nix run .#test
name: stackbuilders
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build `default` package
run: nix build

docker:
uses: ./.github/workflows/reusable-docker.yml
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ cabal.sandbox.config
.stack-work/
dist-newstyle
result
nix/
.ghc.environment.*
.tmuxinator.yml
# Devenv
Expand Down
2 changes: 0 additions & 2 deletions bin/ghc810

This file was deleted.

2 changes: 0 additions & 2 deletions bin/ghc90

This file was deleted.

73 changes: 28 additions & 45 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
Expand All @@ -33,10 +32,31 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1742649964,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"git-hooks",
"nixpkgs"
]
},
Expand All @@ -45,7 +65,6 @@
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9",
"type": "github"
},
"original": {
Expand All @@ -70,50 +89,14 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1718811006,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "03d771e513ce90147b65fe922d87d3a0356fc125",
"treeHash": "ab837eb82b2b0afbb6568f2b27f214324699af3d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1718879355,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "8cd35b9496d21a6c55164d8547d9d5280162b07a",
"treeHash": "246f2197feb48979ccc58af4cab0cfd0f5738645",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs, lib, ... }:

{
packages =
[
pkgs.git
pkgs.stack
pkgs.zsh
]
++ lib.optionals pkgs.stdenv.isLinux [
pkgs.gmp
];
}
4 changes: 4 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
56 changes: 30 additions & 26 deletions docs/NIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,50 @@
## Requirements

- Install [Nix](https://nixos.org/download.html)
- Enable Flakes [permanently](https://nixos.wiki/wiki/Flakes#Permanent)
- Enable [Flakes](https://nixos.wiki/wiki/Flakes#Permanent) permanently
- Install [devenv](https://devenv.sh/getting-started/):

**For macOS users**
## Project Structure

Add the following lines to configuration file located at `/etc/nix/nix.conf`:
The project uses:
- Nix Flakes for reproducible builds and development environments
- `stacklock2nix` for deriving Nix packages from stack.yaml.lock
- `devenv` for creating consistent development environments

```
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://cache.nixos.org
```
### Flake.nix

Restart the `nix-daemon` service:
The flake.nix file has the following inputs:
- `nixpkgs`: Standard Nix packages repository
- `stacklock2nix`: A tool for generating Nix packages from stack.yaml.lock files

```
sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon
```
The flake outputs:
- `packages.default`: The Hapistrano package for each supported system
- `overlays.default`: An overlay for integrating Hapistrano into other Nix
systems

If the following messages appear running the scripts detailed in the section
below, it means that Nix is not picking up the substituters we described
earlier and is unable to use them as a derivation cache:
## Development Environments

```
warning: ignoring untrusted substituter 'https://cache.iog.io'
```
in which case
it is recommended to go over the steps detailed in this section again, or look for alternative ways to add extra substituters in [nix.conf](https://nix.dev/manual/nix/2.18/command-ref/conf-file).

## Enabling the development environment
The project includes a `devenv.nix` configuration that provides a consistent
development environment with all necessary dependencies.

To enable the development environment exposed by the project's [Nix flake](../flake.nix), you can start a development shell by running the following command from within the project's root:
To use devenv:

```
nix develop
devenv shell
```

Alternatively, if you are using [nix-direnv](https://github.com/nix-community/nix-direnv) (recommended), you can run:
The devenv configuration includes:
- Essential tools like git, stack, and zsh
- System-specific dependencies (e.g., gmp for Linux systems)

### Using nix-direnv

If you are using [nix-direnv](https://github.com/nix-community/nix-direnv), run:

```
direnv allow
```

that will enable the development shell according to the contents of [.envrc](../.envrc). It is advisable not to run `direnv allow` blindly and always check the contents of [.envrc](../.envrc) files first to ensure nothing malicious is executed.
This will enable the development shell according to the contents of
[.envrc](../.envrc). Always check the contents of [.envrc](../.envrc) files
before running `direnv allow` to ensure nothing malicious is executed.
Loading