From 18946f2d57ab9ed6f099dda00501c5ab565a94e5 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Thu, 6 Apr 2023 12:35:31 +0200 Subject: [PATCH] Clean up flake.nix a little --- flake.nix | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 48f8ecc..1f0d396 100644 --- a/flake.nix +++ b/flake.nix @@ -13,27 +13,38 @@ haskellPackages = pkgs.haskell.packages."${settings.ghc}"; ghc = haskellPackages.ghcWithPackages haskellDeps; + + # Wrap stack to disable its slow Nix integration. + # Instead, make it use the GHC defined above. stack = pkgs.stdenv.mkDerivation { 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; dontConfigure = true; dontBuild = true; + nativeBuildInputs = [ pkgs.makeWrapper ]; + # makeBinaryWrapper creates a stack executable for us that uses + # the GHC defined in this file. installPhase = '' - makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ + makeBinaryWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ --prefix PATH : ${ghc}/bin \ --add-flags '--no-nix --system-ghc --no-install-ghc' ''; }; - utoy' = - { mkDerivation }: + + utoy = haskellPackages.callPackage + ({ mkDerivation }: mkDerivation { version = "0.5"; pname = "utoy"; license = pkgs.lib.licenses.mit; src = + # We only need these files for building: let - buildFiles = [ + whitelist = [ ./LICENSE ./utoy.cabal ./Setup.hs @@ -45,17 +56,14 @@ in pkgs.lib.sources.cleanSourceWith { 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; - }; - utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy' {}); + }) {}; in { packages.x86_64-linux = { inherit ghc; inherit stack; - inherit utoy; docker = pkgs.dockerTools.buildImage { @@ -64,7 +72,7 @@ config.Cmd = [ "${utoy}/bin/utoy" ]; }; - default = utoy; + default = pkgs.haskell.lib.justStaticExecutables utoy; }; devShells.x86_64-linux.default = pkgs.mkShell {