From afe8b44544a78b5d4730422f3107d4cc5285cf4d Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 18:54:34 +0100 Subject: [PATCH 1/7] Update haskellNix --- nix/sources.json | 6 +++--- nix/sources.nix | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 584bd82..7783bb8 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://input-output-hk.github.io/haskell.nix", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "9bc8625f18ed1aa633f5f3a52ee03d1718eaeebe", - "sha256": "0mm4z0wc7vic1185id912lfmrm2vy8ky25qa2ivf8fphi4ls5qb8", + "rev": "a6825537df7c0834a4410f652b6659e07ec5bde3", + "sha256": "1nqm48clz0739l11gzyfacs3mfs4rygiyhdcac9kynjk0mqb0xyn", "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/9bc8625f18ed1aa633f5f3a52ee03d1718eaeebe.tar.gz", + "url": "https://github.com/input-output-hk/haskell.nix/archive/a6825537df7c0834a4410f652b6659e07ec5bde3.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { diff --git a/nix/sources.nix b/nix/sources.nix index 1938409..9a01c8a 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -31,8 +31,28 @@ let if spec ? branch then "refs/heads/${spec.branch}" else if spec ? tag then "refs/tags/${spec.tag}" else abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + submodules = if spec ? submodules then spec.submodules else false; + submoduleArg = + let + nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; + emptyArgWithWarning = + if submodules == true + then + builtins.trace + ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) + {} + else {}; + in + if nixSupportsSubmodules + then { inherit submodules; } + else emptyArgWithWarning; in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + builtins.fetchGit + ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); fetch_local = spec: spec.path; From ae6e34d62f4ccb89fdebf68ed1183ae3fb6ff54f Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 18:57:19 +0100 Subject: [PATCH 2/7] Fix makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 399c72a..e9e3d3e 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ test: cabal test OpenSCAD .PHONY: bench -test: +bench: cabal bench .PHONY: nix-build @@ -40,6 +40,6 @@ hlint: ci-cd: act $(ACT_ARGS) -.PHONY: make check +.PHONY: check check: format-check hlint cabal check From e5236cc657fb8f177649d9d5f07574d14eee3627 Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 19:00:31 +0100 Subject: [PATCH 3/7] Add `haddock` to makefile --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index e9e3d3e..418295e 100644 --- a/Makefile +++ b/Makefile @@ -43,3 +43,7 @@ ci-cd: .PHONY: check check: format-check hlint cabal check + +.PHONY: haddock +haddock: + cabal haddock From 714f1819bb409d3867ad64a7a6caf2670883657d Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 19:03:22 +0100 Subject: [PATCH 4/7] Add doctest to makefile --- Makefile | 4 ++++ shell.nix | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 418295e..2c70863 100644 --- a/Makefile +++ b/Makefile @@ -47,3 +47,7 @@ check: format-check hlint .PHONY: haddock haddock: cabal haddock + +.PHONY: doctest +doctest: + doctest diff --git a/shell.nix b/shell.nix index bbd9261..3001c29 100644 --- a/shell.nix +++ b/shell.nix @@ -23,6 +23,8 @@ in project.shellFor { cmake bash openscad + # not available from haskell.nix? + pkgs.haskellPackages.doctest ]; exactDeps = true; From 584ca319a51a1f6076023107551e0a27acabd25c Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 19:05:33 +0100 Subject: [PATCH 5/7] Support fewer GHC versions --- OpenSCAD.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSCAD.cabal b/OpenSCAD.cabal index 38089dc..445e758 100644 --- a/OpenSCAD.cabal +++ b/OpenSCAD.cabal @@ -19,7 +19,7 @@ description: functions for rendering an ADT into an OpenSCAD program. category: Graphics -tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.2 +tested-with: GHC ==8.10.7 || ==9.0.2 || ==9.2.2 extra-doc-files: README.md library From 857186708f8b5e0d61f0ec19909dbc67434d317f Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 19:07:27 +0100 Subject: [PATCH 6/7] Add support for multiple stackage sets --- Makefile | 10 +++++++++- default.nix | 9 ++++++++- shell.nix | 22 +++++++++++++++++++--- stack-lts-18.yaml | 5 +++++ stack-lts-19.yaml | 5 +++++ 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 stack-lts-18.yaml create mode 100644 stack-lts-19.yaml diff --git a/Makefile b/Makefile index 2c70863..c3f4fe0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,13 @@ SHELL := /usr/bin/env bash +ifdef PACKAGE_SET + NIX_ARGS += --argstr packageSet $(PACKAGE_SET) +endif + +.PHONY: info +info: + echo "NIX_ARGS: '$(NIX_ARGS)'" + .PHONY: clean clean: rm -rf dist-newstyle result result-* bench/out/* @@ -18,7 +26,7 @@ bench: .PHONY: nix-build nix-build: - nix-build --no-out-link default.nix -A OpenSCAD.components + nix-build $(NIX_ARGS) --no-out-link default.nix -A OpenSCAD.components .PHONY: format format: diff --git a/default.nix b/default.nix index 7dedfff..484d39e 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,14 @@ +{ packageSet ? null }: let pkgs = import ./nix/pkgs.nix; cleanSource = pkgs.haskell-nix.haskellLib.cleanGit; -in pkgs.haskell-nix.project { +in pkgs.haskell-nix.stackProject { + stackYaml = if isNull packageSet || packageSet == "lts-20" then + "stack.yaml" + else if builtins.elem packageSet [ "lts-19" "lts-18" ] then + "stack-${toString packageSet}.yaml" + else + abort "packageSet must be one of , lts-19 or lts-18"; src = cleanSource { name = "OpenSCAD"; src = ./.; diff --git a/shell.nix b/shell.nix index 3001c29..f8c8d12 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,6 @@ +args@{ packageSet ? null }: let - project = import ./default.nix; + project = import ./default.nix args; pkgs = import ./nix/pkgs.nix; sources = import ./nix/sources.nix { }; in project.shellFor { @@ -7,7 +8,7 @@ in project.shellFor { withHoogle = true; - tools = { + tools = if isNull packageSet || packageSet == "lts-20" then { cabal = "3.6.2.0"; hlint = "3.5"; ghcid = "0.8.7"; @@ -15,7 +16,16 @@ in project.shellFor { haskell-ci = "0.14.3"; haskell-language-server = "1.9.1.0"; cabal-fmt = "0.1.6"; - }; + } else if packageSet == "lts-19" then { + cabal = "3.4.1.0"; + ghcid = "0.8.7"; + haskell-language-server = "1.9.0.0"; + } else if packageSet == "lts-18" then { + cabal = "3.2.0.0"; + ghcid = "0.8.7"; + haskell-language-server = "1.8.0.0"; + } else + abort "packageSet must be one of , lts-19 or lts-18"; buildInputs = with pkgs; [ nixfmt @@ -28,4 +38,10 @@ in project.shellFor { ]; exactDeps = true; + + shellHook = if isNull packageSet then + "" + else '' + export PACKAGE_SET=${packageSet} + ''; } diff --git a/stack-lts-18.yaml b/stack-lts-18.yaml new file mode 100644 index 0000000..a7a9e29 --- /dev/null +++ b/stack-lts-18.yaml @@ -0,0 +1,5 @@ +flags: {} +packages: +- '.' +extra-deps: [] +resolver: lts-18.28 diff --git a/stack-lts-19.yaml b/stack-lts-19.yaml new file mode 100644 index 0000000..786fa82 --- /dev/null +++ b/stack-lts-19.yaml @@ -0,0 +1,5 @@ +flags: {} +packages: +- '.' +extra-deps: [] +resolver: lts-19.33 From 136862c5a0d88399412af21ea9caa93be8b85436 Mon Sep 17 00:00:00 2001 From: Brecht Serckx Date: Tue, 14 Mar 2023 19:09:08 +0100 Subject: [PATCH 7/7] Build multiple package sets in GA matrix --- .github/workflows/cachix.yaml | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cachix.yaml b/.github/workflows/cachix.yaml index e67eb4f..1ecf070 100644 --- a/.github/workflows/cachix.yaml +++ b/.github/workflows/cachix.yaml @@ -4,9 +4,37 @@ on: push: branches: [master] jobs: - Nix-CI: - name: + + # Nix builds + Nix-Build: runs-on: ubuntu-latest + # Build for 3 latest Stackage package sets + strategy: + matrix: + package-set: [lts-20, lts-19, lts-18] + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v17 + with: + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://cache.nixos.org/ + - uses: cachix/cachix-action@v10 + with: + name: brechtserckx-openscad + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + # Nix build + - run: make nix-build PACKAGE_SET=${{matrix.package-set}} + + # Cabal build in nix-shell + - run: nix-shell --argstr packageSet ${{matrix.package-set}} --run "make build" + + # Additional package checking using nix + Nix-Check: + runs-on: ubuntu-latest + # Only run after build completed, to re-use caching + needs: Nix-Build steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v17 @@ -18,6 +46,4 @@ jobs: with: name: brechtserckx-openscad authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - run: make nix-build - - run: nix-shell --run "echo 'Shell ok'" - run: nix-shell --run "make check"