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
34 changes: 30 additions & 4 deletions .github/workflows/cachix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/*
Expand All @@ -13,12 +21,12 @@ test:
cabal test OpenSCAD

.PHONY: bench
test:
bench:
cabal 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:
Expand All @@ -40,6 +48,14 @@ hlint:
ci-cd:
act $(ACT_ARGS)

.PHONY: make check
.PHONY: check
check: format-check hlint
cabal check

.PHONY: haddock
haddock:
cabal haddock

.PHONY: doctest
doctest:
doctest
2 changes: 1 addition & 1 deletion OpenSCAD.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -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 <null>, lts-19 or lts-18";
src = cleanSource {
name = "OpenSCAD";
src = ./.;
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
Expand Down
22 changes: 21 additions & 1 deletion nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
24 changes: 21 additions & 3 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
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 {
packages = ps: with ps; [ OpenSCAD ];

withHoogle = true;

tools = {
tools = if isNull packageSet || packageSet == "lts-20" then {
cabal = "3.6.2.0";
hlint = "3.5";
ghcid = "0.8.7";
ormolu = "0.5.0.1";
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 <null>, lts-19 or lts-18";

buildInputs = with pkgs; [
nixfmt
(import sources.nixpkgs-act { }).act
cmake
bash
openscad
# not available from haskell.nix?
pkgs.haskellPackages.doctest
];

exactDeps = true;

shellHook = if isNull packageSet then
""
else ''
export PACKAGE_SET=${packageSet}
'';
}
5 changes: 5 additions & 0 deletions stack-lts-18.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flags: {}
packages:
- '.'
extra-deps: []
resolver: lts-18.28
5 changes: 5 additions & 0 deletions stack-lts-19.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flags: {}
packages:
- '.'
extra-deps: []
resolver: lts-19.33