80 lines
3.0 KiB
Nix
80 lines
3.0 KiB
Nix
{
|
|
description = "Unicode toy";
|
|
|
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux" "aarch64-darwin"] (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
inherit (pkgs.haskell.lib) compose;
|
|
|
|
# Fix broken unicode-data-names by overriding the version of the unicode-data package.
|
|
haskellPackagesOverrides = self: super: {
|
|
unicode-data = super.unicode-data_0_6_0;
|
|
unicode-data-names = pkgs.haskell.lib.markUnbroken super.unicode-data-names;
|
|
};
|
|
|
|
utoy = pkgs.lib.pipe
|
|
# The basic package
|
|
(pkgs.haskellPackages.developPackage {
|
|
root = ./.;
|
|
overrides = haskellPackagesOverrides;
|
|
})
|
|
# And some build configuration.
|
|
# See https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers.
|
|
[
|
|
# Configurable static build. Set cabal options...
|
|
compose.disableSharedExecutables
|
|
compose.disableSharedLibraries
|
|
# ... and link required static libraries.
|
|
(compose.appendConfigureFlags [
|
|
"--ghc-option=-optl=-static"
|
|
"--ghc-option=-optl=-pthread"
|
|
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
|
|
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
|
|
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
|
|
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
|
|
])
|
|
# Remove all references to the Nix store from the executable.
|
|
# This is important because Nix uses the references for calculating
|
|
# what needs to be in the Docker container.
|
|
# FIXME: Using static linking, these references shouldn't even still be there.
|
|
# Can we somehow make GHC stop emitting them?
|
|
(compose.overrideCabal (drv: {
|
|
postInstall = ''
|
|
${pkgs.nukeReferences}/bin/nuke-refs $out/bin/utoy
|
|
'';
|
|
}))
|
|
# Return only the bin folder to curb image size.
|
|
compose.justStaticExecutables
|
|
];
|
|
in {
|
|
packages = rec {
|
|
docker =
|
|
pkgs.dockerTools.buildImage {
|
|
name = "git.pbrinkmeier.de/paul/utoy";
|
|
tag = utoy.version;
|
|
config.Cmd = [ "${utoy}/bin/utoy" ];
|
|
};
|
|
|
|
default = utoy;
|
|
};
|
|
|
|
devShells.default =
|
|
(pkgs.haskellPackages.developPackage {
|
|
root = ./.;
|
|
overrides = haskellPackagesOverrides;
|
|
modifier = drv:
|
|
pkgs.haskell.lib.addBuildTools drv [
|
|
pkgs.cabal-install
|
|
pkgs.haskellPackages.implicit-hie
|
|
pkgs.haskell-language-server
|
|
];
|
|
cabal2nixOptions = "--benchmark";
|
|
}).env;
|
|
});
|
|
}
|