utoy/flake.nix

90 lines
2.5 KiB
Nix

{
description = "Unicode toy";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
overlay = import ./nix/overlay.nix;
settings = import ./nix/settings.nix;
haskellDeps = import ./nix/haskell-deps.nix;
pkgs = nixpkgs.legacyPackages.x86_64-linux.extend overlay;
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.
phases = [ "installPhase" ];
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 \
--prefix PATH : ${ghc}/bin \
--add-flags '--no-nix --system-ghc --no-install-ghc'
'';
};
utoy = haskellPackages.callPackage
({ mkDerivation }:
mkDerivation {
version = "0.5";
pname = "utoy";
license = pkgs.lib.licenses.mit;
src =
# We only need these files for building:
let
whitelist = [
./LICENSE
./utoy.cabal
./Setup.hs
./app
./src
./static
./test
];
in
pkgs.lib.sources.cleanSourceWith {
src = ./.;
filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) whitelist;
};
libraryHaskellDepends = haskellDeps haskellPackages;
}) {};
in {
packages.x86_64-linux = {
inherit ghc;
inherit stack;
docker =
pkgs.dockerTools.buildImage {
name = "git.pbrinkmeier.de/paul/utoy";
tag = utoy.version;
config.Cmd = [ "${utoy}/bin/utoy" ];
};
default = pkgs.haskell.lib.justStaticExecutables utoy;
};
devShells.x86_64-linux.default = pkgs.mkShell {
packages = [
stack
ghc
haskellPackages.haskell-language-server
haskellPackages.implicit-hie
];
shellHook = ''
PS1+="(utoy) ";
'';
};
};
}