Skip to content

Commit

Permalink
nix: default.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Aug 29, 2023
1 parent 5e5f7c5 commit 200f545
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 30 additions & 9 deletions darwin.nix → default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {}, lib ? pkgs.lib, stdenv ? pkgs.stdenv }:

let
src = pkgs.copyPathToStore ./.;
semver = builtins.readFile "${src}/VERSION";
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
Expand All @@ -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;
};
}

0 comments on commit 200f545

Please sign in to comment.