Skip to content

Instantly share code, notes, and snippets.

@alexpeits
Created November 20, 2019 14:20
Show Gist options
  • Save alexpeits/5e0cf2af6917ccdc0fd73196ecf04663 to your computer and use it in GitHub Desktop.
Save alexpeits/5e0cf2af6917ccdc0fd73196ecf04663 to your computer and use it in GitHub Desktop.
XMonad nix derivation
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, containers, data-default, directory
, extensible-exceptions, filepath, mtl, process, QuickCheck
, setlocale, stdenv, unix, utf8-string, X11
}:
mkDerivation {
pname = "xmonad";
version = "0.15";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
base containers data-default directory extensible-exceptions
filepath mtl process setlocale unix utf8-string X11
];
executableHaskellDepends = [ base mtl unix X11 ];
executableSystemDepends = with nixpkgs.xorg; [
libX11 libXinerama libXext libXrandr libXScrnSaver
];
testHaskellDepends = [
base containers extensible-exceptions QuickCheck X11
];
postInstall = ''
install -D man/xmonad.1 ''${!outputDoc}/share/man/man1/xmonad.1
install -D man/xmonad.hs ''${!outputDoc}/share/doc/$name/sample-xmonad.hs
'';
homepage = "http://xmonad.org";
description = "A tiling window manager";
license = stdenv.lib.licenses.bsd3;
};
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
drv = variant (haskellPackages.callPackage f {});
in
if pkgs.lib.inNixShell then drv.env else drv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment