|
1 | 1 | {
|
2 |
| - # This is a template created by `hix init` |
| 2 | + inputs.nixpkgs.follows = "haskellNix/nixpkgs"; |
3 | 3 | inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
|
4 |
| - inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; |
5 |
| - inputs.flake-utils.follows = "haskellNix/flake-utils"; |
6 |
| - outputs = { self, nixpkgs, flake-utils, haskellNix }: |
| 4 | + |
| 5 | + outputs = { nixpkgs, haskellNix, ... }: |
7 | 6 | let
|
8 |
| - ci = (builtins.fromTOML (__readFile ./ci.toml)).dimensions; |
| 7 | + systems = [ |
| 8 | + "x86_64-linux" |
| 9 | + "x86_64-darwin" |
| 10 | + # TODO switch back on when ci.iog.io has builders for aarch64-linux |
| 11 | + # "aarch64-linux" |
| 12 | + "aarch64-darwin" |
| 13 | + ]; |
| 14 | + |
| 15 | + inherit (nixpkgs) lib; |
| 16 | + |
| 17 | + # A simple thing but hard to do without screwing up lazyness. |
| 18 | + # We don't want packages.x to trigger evaluation of packages.y |
| 19 | + forEachSystem = f: |
| 20 | + let |
| 21 | + perSystem = lib.genAttrs systems f; |
| 22 | + in |
| 23 | + lib.genAttrs |
| 24 | + [ "apps" "checks" "ciJobs" "devShells" "hydraJobs" "packages" ] |
| 25 | + (attrName: lib.genAttrs systems (system: perSystem.${system}.${attrName})) |
| 26 | + ; |
9 | 27 | in
|
10 |
| - flake-utils.lib.eachSystem ci.os (system: |
| 28 | + forEachSystem (system: |
11 | 29 | let
|
12 |
| - compilers = builtins.filter |
13 |
| - (x: !__elem "${system}.${x}" ci.disable) |
14 |
| - (ci.compiler); |
15 |
| - overlays = [ haskellNix.overlay |
16 |
| - (final: prev: { |
17 |
| - hixProject = |
18 |
| - final.haskell-nix.hix.project { |
19 |
| - src = ./.; |
20 |
| - compiler-nix-name = __head compilers; |
21 |
| - }; |
22 |
| - }) |
23 |
| - ]; |
24 |
| - pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; |
25 |
| - flake = pkgs.hixProject.flake { |
26 |
| - variants = pkgs.lib.genAttrs (__tail compilers) |
27 |
| - (x: { compiler-nix-name = pkgs.lib.mkForce x; }); |
| 30 | + pkgs = haskellNix.legacyPackages.${system}; |
| 31 | + |
| 32 | + project = pkgs.haskell-nix.cabalProject' { |
| 33 | + src = ./.; |
| 34 | + compiler-nix-name = "ghc928"; |
28 | 35 | };
|
29 |
| - in flake // { |
30 |
| - legacyPackages = pkgs; |
31 |
| - }); |
32 | 36 |
|
33 |
| - # --- Flake Local Nix Configuration ---------------------------- |
| 37 | + mkTarball = package: |
| 38 | + let |
| 39 | + name = "${package.identifier.name}-${package.identifier.version}"; |
| 40 | + paths = builtins.attrValues package.components.exes; |
| 41 | + in |
| 42 | + pkgs.runCommand name |
| 43 | + { preferLocalBuild = true; } |
| 44 | + '' |
| 45 | + mkdir -p ${name} |
| 46 | + cp --verbose --target-directory ${name} \ |
| 47 | + ${pkgs.lib.concatMapStringsSep " \\\n " (p: "${p}/bin/*") paths} |
| 48 | +
|
| 49 | + mkdir -p $out |
| 50 | + tar cvzf $out/${name}.tar.gz ${name} |
| 51 | +
|
| 52 | + mkdir -p $out/nix-support |
| 53 | + echo "file binary-dist $out/${name}.tar.gz" >> $out/nix-support/hydra-build-products |
| 54 | + # Propagate the release name of the source tarball. This is |
| 55 | + # to get nice package names in channels. |
| 56 | + echo "${name}" >> $out/nix-support/hydra-release-name |
| 57 | + ''; |
| 58 | + in |
| 59 | + lib.recursiveUpdate |
| 60 | + project.flake' |
| 61 | + ( |
| 62 | + lib.optionalAttrs (system == "x86_64-linux") |
| 63 | + { |
| 64 | + hydraJobs.binary-tarball = mkTarball |
| 65 | + project.projectCross.musl64.hsPkgs.nix-tools; |
| 66 | + } |
| 67 | + // |
| 68 | + lib.optionalAttrs (system == "aarch64-linux") |
| 69 | + { |
| 70 | + hydraJobs.binary-tarball = mkTarball |
| 71 | + project.projectCross.aarch64-multiplatform-musl.hsPkgs.nix-tools; |
| 72 | + } |
| 73 | + ) |
| 74 | + ); |
| 75 | + |
34 | 76 | nixConfig = {
|
35 |
| - # This sets the flake to use the IOG nix cache. |
36 |
| - # Nix should ask for permission before using it, |
37 |
| - # but remove it here if you do not want it to. |
38 |
| - extra-substituters = ["https://cache.iog.io"]; |
39 |
| - extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; |
| 77 | + extra-substituters = [ |
| 78 | + "https://cache.iog.io" |
| 79 | + "https://cache.zw3rk.com" |
| 80 | + ]; |
| 81 | + extra-trusted-public-keys = [ |
| 82 | + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" |
| 83 | + "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=" |
| 84 | + ]; |
40 | 85 | allow-import-from-derivation = "true";
|
41 | 86 | };
|
42 | 87 | }
|
0 commit comments