Clean up flake.nix a little

This commit is contained in:
Paul Brinkmeier 2023-04-06 12:35:31 +02:00
parent 7a91c520ee
commit 18946f2d57

View File

@ -13,27 +13,38 @@
haskellPackages = pkgs.haskell.packages."${settings.ghc}"; haskellPackages = pkgs.haskell.packages."${settings.ghc}";
ghc = haskellPackages.ghcWithPackages haskellDeps; ghc = haskellPackages.ghcWithPackages haskellDeps;
# Wrap stack to disable its slow Nix integration.
# Instead, make it use the GHC defined above.
stack = pkgs.stdenv.mkDerivation { stack = pkgs.stdenv.mkDerivation {
name = "stack"; name = "stack";
# The build is simply a call to makeWrapper, so we don't have to
# do any of the typical build steps.
dontUnpack = true; dontUnpack = true;
dontConfigure = true; dontConfigure = true;
dontBuild = true; dontBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];
# makeBinaryWrapper creates a stack executable for us that uses
# the GHC defined in this file.
installPhase = '' installPhase = ''
makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ makeBinaryWrapper ${pkgs.stack}/bin/stack $out/bin/stack \
--prefix PATH : ${ghc}/bin \ --prefix PATH : ${ghc}/bin \
--add-flags '--no-nix --system-ghc --no-install-ghc' --add-flags '--no-nix --system-ghc --no-install-ghc'
''; '';
}; };
utoy' =
{ mkDerivation }: utoy = haskellPackages.callPackage
({ mkDerivation }:
mkDerivation { mkDerivation {
version = "0.5"; version = "0.5";
pname = "utoy"; pname = "utoy";
license = pkgs.lib.licenses.mit; license = pkgs.lib.licenses.mit;
src = src =
# We only need these files for building:
let let
buildFiles = [ whitelist = [
./LICENSE ./LICENSE
./utoy.cabal ./utoy.cabal
./Setup.hs ./Setup.hs
@ -45,17 +56,14 @@
in in
pkgs.lib.sources.cleanSourceWith { pkgs.lib.sources.cleanSourceWith {
src = ./.; src = ./.;
filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) buildFiles; filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) whitelist;
}; };
libraryHaskellDepends = haskellDeps haskellPackages; libraryHaskellDepends = haskellDeps haskellPackages;
}; }) {};
utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy' {});
in { in {
packages.x86_64-linux = { packages.x86_64-linux = {
inherit ghc; inherit ghc;
inherit stack; inherit stack;
inherit utoy;
docker = docker =
pkgs.dockerTools.buildImage { pkgs.dockerTools.buildImage {
@ -64,7 +72,7 @@
config.Cmd = [ "${utoy}/bin/utoy" ]; config.Cmd = [ "${utoy}/bin/utoy" ];
}; };
default = utoy; default = pkgs.haskell.lib.justStaticExecutables utoy;
}; };
devShells.x86_64-linux.default = pkgs.mkShell { devShells.x86_64-linux.default = pkgs.mkShell {