nix: default.nix

This commit is contained in:
Jari Vetoniemi 2023-08-30 00:04:02 +09:00
parent 5e5f7c58d2
commit 200f545283
2 changed files with 32 additions and 11 deletions

View File

@ -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.

View File

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {}, 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;
};
}