diff --git a/README.md b/README.md index 48f49014..19d1b166 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,9 @@ PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig" sh build-osx.sh curses ### Nix -There is darwin.nix provided in this repo, you can install bemenu with it by running +There is default.nix provided in this repo, you can install bemenu with it by running ```sh -nix-env -i -f darwin.nix +nix-env -i -f default.nix ``` This installs only the curses backend. diff --git a/darwin.nix b/default.nix similarity index 51% rename from darwin.nix rename to default.nix index 9b1f2832..e8532389 100644 --- a/darwin.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} }: +{ pkgs ? import {}, lib ? pkgs.lib, stdenv ? pkgs.stdenv }: let src = pkgs.copyPathToStore ./.; @@ -6,23 +6,44 @@ let revision = builtins.readFile (pkgs.runCommand "get-rev" { nativeBuildInputs = with pkgs; [ git ]; } "GIT_DIR=${src}/.git git rev-parse --short HEAD | tr -d '\n' > $out"); -in pkgs.stdenv.mkDerivation rec { +in stdenv.mkDerivation { inherit src; pname = "bemenu"; version = "${semver}${revision}"; - nativeBuildInputs = with pkgs; [ pkg-config scdoc ]; - buildInputs = with pkgs; [ ncurses ]; - postPatch = '' + strictDeps = true; + nativeBuildInputs = with pkgs; [ + pkg-config + scdoc + ] ++ lib.optionals (stdenv.isLinux) [ + wayland-scanner + ]; + + buildInputs = with pkgs; [ + ncurses + ] ++ lib.optionals (stdenv.isLinux) [ + cairo + fribidi + harfbuzz + libxkbcommon + pango + # Wayland + wayland wayland-protocols + # X11 + xorg.libX11 xorg.libXinerama xorg.libXft + xorg.libXdmcp xorg.libpthreadstubs xorg.libxcb + ]; + + postPatch = "" + lib.optionalString (stdenv.isDarwin) '' substituteInPlace GNUmakefile --replace '-soname' '-install_name' ''; - makeFlags = ["PREFIX=$(out)"]; - buildFlags = ["PREFIX=$(out)" "clients" "curses"]; + makeFlags = [ "PREFIX=$(out)" ]; + buildFlags = [ "PREFIX=$(out)" "clients" "curses" ] ++ lib.optionals (stdenv.isLinux) [ "wayland" "x11" ]; # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh # ^ does not handle .so files - postInstall = '' + postInstall = "" + lib.optionalString (stdenv.isDarwin) '' so="$(find "$out/lib" -name "libbemenu.so.[0-9]" -print -quit)" for f in "$out/bin/"*; do install_name_tool -change "$(basename $so)" "$so" $f @@ -33,6 +54,6 @@ in pkgs.stdenv.mkDerivation rec { homepage = "https://github.com/Cloudef/bemenu"; description = "Dynamic menu library and client program inspired by dmenu"; license = licenses.gpl3Plus; - platforms = with platforms; darwin; + platforms = with platforms; darwin ++ linux; }; }