Skip to content

Commit acc0f88

Browse files
authored
Merge pull request input-output-hk#54 from andreabedini/more-systems
Rework flake
2 parents 586b692 + 521e397 commit acc0f88

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

flake.nix

+32-15
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,50 @@
1212
};
1313

1414
outputs = { self, nixpkgs, flake-utils, haskell-nix, ... }:
15-
16-
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
15+
flake-utils.lib.eachDefaultSystem (system:
1716
let
1817
pkgs = import nixpkgs {
1918
inherit system;
2019
inherit (haskell-nix) config;
2120
overlays = [ haskell-nix.overlay ];
2221
};
22+
inherit (pkgs) lib;
2323

24-
pkgs-static-where-possible =
25-
if pkgs.stdenv.hostPlatform.isLinux then
26-
if pkgs.stdenv.hostPlatform.isAarch64 then
27-
pkgs.pkgsCross.aarch64-multiplatform-musl
28-
else
29-
pkgs.pkgsCross.musl64
30-
else
31-
pkgs;
32-
33-
project = pkgs-static-where-possible.haskell-nix.cabalProject' {
24+
project = pkgs.haskell-nix.cabalProject' {
3425
src = ./.;
3526
compiler-nix-name = "ghc926";
27+
shell.tools = {
28+
cabal = "latest";
29+
hlint = "latest";
30+
haskell-language-server = "latest";
31+
};
3632
};
3733

38-
flake = project.flake { };
39-
34+
flake = project.flake (
35+
lib.attrsets.optionalAttrs (system == "x86_64-linux")
36+
{ crossPlatforms = p: [ p.musl64 ]; }
37+
);
4038
in
41-
flake // { packages.default = flake.packages."foliage:exe:foliage"; });
39+
40+
flake // {
41+
inherit project;
42+
43+
# This is way too much boilerplate. I only want the default package to
44+
# be the main exe (package or app) and "static" the static version on
45+
# the systems where it is available.
46+
47+
apps = { default = flake.apps."foliage:exe:foliage"; }
48+
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
49+
{ static = flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
50+
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
51+
{ static = flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; };
52+
53+
packages = { default = flake.packages."foliage:exe:foliage"; }
54+
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
55+
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
56+
;
57+
}
58+
);
4259

4360
nixConfig = {
4461
extra-substituters = [

0 commit comments

Comments
 (0)