Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix-shell and test it on CI #390

Merged
merged 3 commits into from
Jan 23, 2025
Merged
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
14 changes: 13 additions & 1 deletion .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
- 'agda2hs.cabal'
- 'cabal.project'
- 'Makefile'
- 'flake.*'
- 'nix/*'
- '.github/workflows/**.yml'
branches: [master]

Expand All @@ -32,4 +34,14 @@ jobs:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build .#${{ matrix.derivation }} --print-build-logs
- run: nix build .#${{ matrix.derivation }} --print-build-logs

nix-shell:
name: "Test building inside a nix shell"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- uses: DeterminateSystems/magic-nix-cache-action@v2
# for some reason this doesn't work without update, even though it doesn't download anything
- run: nix develop -Lv -c bash -c "cabal update; cabal v1-build"
18 changes: 9 additions & 9 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ let
lib = import ./lib.nix { inherit pkgs; };
version = "1.3";
agdalib = pkgs.agdaPackages.mkDerivation {
pname = "agda2hs";
meta = { };
version = version;
preBuild = ''
echo "{-# OPTIONS --sized-types #-}" > Everything.agda
echo "module Everything where" >> Everything.agda
find lib -name '*.agda' | sed -e 's/lib\///;s/\//./g;s/\.agda$//;s/^/import /' >> Everything.agda
'';
src = ../.;
pname = "agda2hs";
meta = { };
version = version;
preBuild = ''
echo "{-# OPTIONS --sized-types #-}" > Everything.agda
echo "module Everything where" >> Everything.agda
find lib -name '*.agda' | sed -e 's/lib\///;s/\//./g;s/\.agda$//;s/^/import /' >> Everything.agda
'';
src = ../.;
};
in
{
Expand Down
22 changes: 19 additions & 3 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
{ pkgs, agda2hs-hs }:
{
pkgs ? import <nixpkgs> { },
agda2hs-hs ? (import ./lib.nix { inherit pkgs; }).agda2hs-hs,
}:
pkgs.haskellPackages.shellFor {
# This doesn't result in a shell where you can use cabal (v2-)build,
# due to build-tool-depends in Agda's .cabal file, so for now only v1-build works
# Making cabal re-install alex and happy from Hackage can work,
# which will be done if the user runs `cabal update` and `cabal build`.
# relevant issues listed in:
# https://gist.github.com/ScottFreeCode/ef9f254e2dd91544bba4a068852fc81f
# main ones are:
# https://github.com/haskell/cabal/issues/8434
# https://github.com/NixOS/nixpkgs/issues/130556
# https://github.com/NixOS/nixpkgs/issues/176887
packages = p: [ agda2hs-hs ];
buildInputs = with pkgs.haskellPackages; [
nativeBuildInputs = with pkgs.haskellPackages; [
# related to haskell
cabal-install
cabal2nix
haskell-language-server
# general goodies
pkgs.agda
pkgs.nixfmt-rfc-style
cabal2nix
];
}
Loading