{
  stdenv,
  lib,
  fetchFromGitHub,
  linux-pam,
  libxcb,
  git,
}:
stdenv.mkDerivation rec {
  pname = "ly";
  version = "0.5.0+";

  src = fetchFromGitHub {
    owner = "fairyglade";
    repo = pname;
    rev = "c64f806a68af225cc95623971b5e464abb55b879";
    sha256 = "sha256-orCqjKlK6U1q7NDoMwxZZE44cyG8yuxdCCk1cQAalP0=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [git];
  buildInputs = [linux-pam libxcb];
  makeFlags = ["FLAGS=-Wno-error=unused-result"];

  preBuildPhase = ''
    mkdir -p ./data
    export DESTDIR="$PWD"
    export DATADIR="$PWD/data"
  '';
  buildPhase = ''
    make -j16
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp bin/ly $out/bin
    mkdir -p $out/etc/ly
    cp -R ./data/* $out/etc/ly
  '';

  meta = with lib; {
    description = "TUI display manager";
    license = licenses.wtfpl;
    homepage = "https://github.com/fairyglade/ly";
    maintainers = [];
  };
}
