foliage/flake.nix

90 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";
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"
"aarch64-linux"
2023-09-05 11:15:34 +03:00
"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 = ./.;
compiler-nix-name = "ghc94";
2023-04-27 12:59:57 +03:00
shell.tools = {
cabal = "latest";
hlint = "latest";
haskell-language-server = "latest";
fourmolu = "0.14.0.0";
2023-04-27 12:59:57 +03:00
};
modules = [{
# Wrap executables with the needed dependencies in PATH. See #71.
packages.foliage.postInstall = ''
for exe in $(find $out/bin -type f -executable); do
wrapProgram "$exe" \
--prefix PATH : ${with pkgs; lib.makeBinPath [ coreutils curl gnutar gitMinimal patch ]}
done
'';
}];
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 ]; }
);
2023-03-03 07:31:29 +03:00
in
2023-04-27 12:59:57 +03:00
flake // {
inherit project;
apps =
flake.apps
// { default = flake.apps."foliage:exe:foliage"; }
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; }
;
2023-05-03 07:32:07 +03:00
packages =
flake.packages
// { default = flake.packages."foliage:exe:foliage"; }
2023-04-27 12:59:57 +03:00
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.packages."aarch64-multiplatform-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
}