| 1 | { |
| 2 | lib, |
| 3 | rustPlatform, |
| 4 | pkg-config, |
| 5 | makeBinaryWrapper, |
| 6 | ncurses, |
| 7 | scdoc, |
| 8 | installShellFiles, |
| 9 | wayland, |
| 10 | libxkbcommon, |
| 11 | freetype, |
| 12 | fontconfig, |
| 13 | }: |
| 14 | rustPlatform.buildRustPackage (finalAttrs: { |
| 15 | pname = "beer"; |
| 16 | version = "0.0.1"; |
| 17 | |
| 18 | src = let |
| 19 | fs = lib.fileset; |
| 20 | s = ../.; |
| 21 | in |
| 22 | fs.toSource { |
| 23 | root = s; |
| 24 | fileset = fs.unions [ |
| 25 | (fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /src)) |
| 26 | (s + /Cargo.lock) |
| 27 | (s + /Cargo.toml) |
| 28 | (s + /terminfo) |
| 29 | (s + /doc) |
| 30 | ]; |
| 31 | }; |
| 32 | |
| 33 | cargoLock.lockFile = "${finalAttrs.src}Cargo.lock"; |
| 34 | enableParallelBuilding = true; |
| 35 | |
| 36 | strictDeps = true; |
| 37 | nativeBuildInputs = [ |
| 38 | pkg-config |
| 39 | makeBinaryWrapper |
| 40 | ncurses # tic |
| 41 | scdoc # man page generation |
| 42 | installShellFiles # installManPage |
| 43 | ]; |
| 44 | |
| 45 | buildInputs = [ |
| 46 | wayland |
| 47 | libxkbcommon |
| 48 | freetype |
| 49 | fontconfig |
| 50 | ]; |
| 51 | |
| 52 | # Install the terminfo entry, and make the Wayland/xkb libraries (loaded via |
| 53 | # dlopen, so not captured by rpath) discoverable at runtime. |
| 54 | postInstall = '' |
| 55 | mkdir -p "$out/share/terminfo" |
| 56 | tic -x -o "$out/share/terminfo" terminfo/beer.info |
| 57 | |
| 58 | # Generate the man pages from their scdoc sources. |
| 59 | scdoc < doc/beer.1.scd > beer.1 |
| 60 | scdoc < doc/beer.toml.5.scd > beer.toml.5 |
| 61 | installManPage beer.1 beer.toml.5 |
| 62 | |
| 63 | wrapProgram "$out/bin/beer" \ |
| 64 | --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [wayland libxkbcommon]} |
| 65 | ''; |
| 66 | |
| 67 | meta = { |
| 68 | description = "A fast, software-rendered, Wayland-native terminal emulator"; |
| 69 | homepage = "https://github.com/NotAShelf/beer"; |
| 70 | license = lib.licenses.eupl12; |
| 71 | maintainers = with lib.maintainers; [NotAShelf]; |
| 72 | mainProgram = "beer"; |
| 73 | platforms = lib.platforms.linux; |
| 74 | }; |
| 75 | }) |