utoy/flake.nix
2025-07-13 12:06:11 +02:00

64 lines
2.1 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.
[
# Remove warp which pulls GHC into the runtime deps for some reason.
(compose.overrideCabal (drv: {
postInstall = ''
remove-references-to -t ${pkgs.haskellPackages.warp} $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;
});
}