foliage/flake.nix

91 lines
2.8 KiB
Nix
Raw Normal View History

2022-04-11 11:48:04 +03:00
{
2022-11-30 06:22:32 +03:00
description =
"Foliage is a tool to create custom Haskell package repositories, in a fully reproducible way.";
2022-04-11 11:48:04 +03:00
inputs = {
2022-05-16 12:54:15 +03:00
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
haskell-nix.url = "github:input-output-hk/haskell.nix";
haskell-nix.inputs.hackage.follows = "hackage-nix";
hackage-nix.url = "github:input-output-hk/hackage.nix";
hackage-nix.flake = false;
2023-09-13 10:11:45 +03:00
flake-utils.url = "github:numtide/flake-utils";
2022-04-11 11:48:04 +03:00
};
2023-09-05 11:15:34 +03:00
outputs = { nixpkgs, flake-utils, haskell-nix, ... }:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
# TODO switch back on when ci.iog.io has builders for aarch64-linux
# "aarch64-linux"
"aarch64-darwin"
];
in
flake-utils.lib.eachSystem systems (system:
2022-11-30 06:22:32 +03:00
let
pkgs = import nixpkgs {
inherit system;
inherit (haskell-nix) config;
overlays = [ haskell-nix.overlay ];
2022-05-16 12:54:15 +03:00
};
2023-04-27 12:59:57 +03:00
inherit (pkgs) lib;
2022-11-30 06:32:17 +03:00
2023-04-27 12:59:57 +03:00
project = pkgs.haskell-nix.cabalProject' {
2023-01-09 06:01:02 +03:00
src = ./.;
2023-03-03 09:48:11 +03:00
compiler-nix-name = "ghc926";
2023-04-27 12:59:57 +03:00
shell.tools = {
cabal = "latest";
hlint = "latest";
haskell-language-server = "latest";
};
2023-01-09 06:01:02 +03:00
};
2022-12-13 05:26:26 +03:00
2023-05-03 07:32:07 +03:00
flake = project.flake (
lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ crossPlatforms = p: [ p.musl64 ]; }
);
# Wrap the foliage executable with the needed dependencies in PATH.
# See #71.
wrapExe = drv:
2023-09-05 11:15:34 +03:00
pkgs.runCommand "foliage"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${drv}/bin/foliage $out/bin/foliage \
--prefix PATH : ${with pkgs; lib.makeBinPath [ curl patch ]}:$out/bin
'';
2023-03-03 07:31:29 +03:00
in
2023-05-03 07:32:07 +03:00
2023-04-27 12:59:57 +03:00
flake // {
inherit project;
2023-05-03 07:32:07 +03:00
# This is way too much boilerplate. I only want the default package to
# be the main exe (package or app) and "static" the static version on
# the systems where it is available.
apps = { default = flake.apps."foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = wrapExe flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
2023-05-03 07:32:07 +03:00
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = wrapExe flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; };
2023-04-27 12:59:57 +03:00
2023-05-03 07:32:07 +03:00
packages = { default = flake.packages."foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
;
2023-05-03 07:32:07 +03:00
}
);
2022-05-16 12:54:15 +03:00
nixConfig = {
2022-12-13 04:37:01 +03:00
extra-substituters = [
"https://cache.iog.io"
2022-12-13 05:26:26 +03:00
];
2022-05-16 12:54:15 +03:00
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
2022-04-11 11:48:04 +03:00
}