From 658f7bee7ad627859a79b5e99c412c91c41d3f21 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 14 Aug 2025 02:19:08 +1200 Subject: [PATCH 1/2] Add haskell.nix workflow to check windows cross compilation and WINE --- .github/workflows/haskell-nix.yml | 26 +++++++++++++++ flake.nix | 55 +++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/haskell-nix.yml create mode 100644 flake.nix diff --git a/.github/workflows/haskell-nix.yml b/.github/workflows/haskell-nix.yml new file mode 100644 index 00000000..92f10877 --- /dev/null +++ b/.github/workflows/haskell-nix.yml @@ -0,0 +1,26 @@ +name: Haskell.nix CI + +on: + push: + branches: [ 'master', 'ci' ] + pull_request: + branches: [ 'master' ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.iog.io https://cache.zw3rk.com https://cache.nixos.org/ + - name: "Build and run tests with nix" + run: | + nix flake check diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..f6bd961a --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + # Haskell.nix project used by `.github/workflows/haskell-nix.yml` + + inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; + inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils, haskellNix }: + let + supportedSystems = [ + "x86_64-linux" + ]; + in + flake-utils.lib.eachSystem supportedSystems (system: + let + overlays = [ haskellNix.overlay + (final: _prev: { + networkProject = + final.haskell-nix.cabalProject { + name = "network"; + src = ./.; + compiler-nix-name = "ghc9122"; + # Include Windows cross compilation + crossPlatforms = p: [ p.ucrt64 ]; + modules = [{ + # Run autoreconf on the source + packages.network.src = final.lib.mkForce (final.stdenv.mkDerivation { + pname = "network-src"; + version = "1.0"; + src = ./.; + nativeBuildInputs = [ final.autoreconfHook ]; + installPhase = '' + mkdir -p $out + cp -r . $out + ''; + }); + }]; + }; + }) + ]; + pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; + flake = pkgs.networkProject.flake {}; + in flake // { + legacyPackages = pkgs; + }); + + # --- Flake Local Nix Configuration ---------------------------- + nixConfig = { + # This sets the flake to use the IOG nix cache. + # Nix should ask for permission before using it, + # but remove it here if you do not want it to. + extra-substituters = ["https://cache.iog.io" "https://cache.zw3rk.com"]; + extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="]; + allow-import-from-derivation = "true"; + }; +} From ff05fd9ba3640b74570c83cb3f65f5bea9e31081 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 14 Aug 2025 16:52:52 +1200 Subject: [PATCH 2/2] Add --allow-import-from-derivation --- .github/workflows/haskell-nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/haskell-nix.yml b/.github/workflows/haskell-nix.yml index 92f10877..b87cf8f8 100644 --- a/.github/workflows/haskell-nix.yml +++ b/.github/workflows/haskell-nix.yml @@ -23,4 +23,4 @@ jobs: substituters = https://cache.iog.io https://cache.zw3rk.com https://cache.nixos.org/ - name: "Build and run tests with nix" run: | - nix flake check + nix flake check --allow-import-from-derivation