Skip to content

Commit

Permalink
[FIX] Add wayland-scanner as a dependency (#66)
Browse files Browse the repository at this point in the history
For the nix flake to build properly, we need wayland-scanner as a hard dependency.

And for said project to build inside of nix, we need wayland-scanner to be detected by the CMake build scripts

---------

Co-authored-by: Louis Dalibard <[email protected]>
  • Loading branch information
make-42 and make-42-2 authored Jan 2, 2025
1 parent 621e384 commit 67dceab
Showing 2 changed files with 103 additions and 100 deletions.
196 changes: 99 additions & 97 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,107 +1,109 @@
{
description = "X11 Audio Visualizer for ALSA";

outputs = { self, nixpkgs }:
let
systems =
[ "x86_64-linux" "aarch64-linux" ];
# Need to validate before pushing "x86_64-darwin" "aarch64-darwin"

forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);

nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
in rec {
overlay = final: prev: {
xava = final.stdenv.mkDerivation {
name = "xava";
version = "unstable";
description = "X11 Audio Visualizer for ALSA";

src = self;

cmakeFlags = [
(final.lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
"-DNIX_BUILDER=ON"
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
];

nativeBuildInputs = with final; [
# Compiling and fetching dependencies
gcc
cmake
pkg-config
git # Not sure if it's needed

# For building icons
imagemagick
librsvg
];

buildInputs = with final; [
# Basic
fftwFloat
iniparser

# Input
alsa-lib
libpulseaudio
pipewire
portaudio
sndio

# Output
SDL2
wayland
wayland-protocols
wayland-utils
xorg.libX11
xorg.libXdmcp
xorg.libXfixes
xorg.libXrandr

# Graphics API
cairo
glew

# Misc
curl
dbus
expat # Might be a nixpkgs bug idfk
taglib
zlib
];

#outputs = [ "out" "lib" ];

#postInstall = ''
# moveToOutput "lib" "$lib"
#'';

CARGO_FEATURE_USE_SYSTEM_LIBS = "1";
};
};

packages =
forAllSystems (system: { inherit (nixpkgsFor.${system}) xava; });
outputs = {
self,
nixpkgs,
}: let
systems = ["x86_64-linux" "aarch64-linux"];
# Need to validate before pushing "x86_64-darwin" "aarch64-darwin"

defaultPackage = forAllSystems (system: self.packages.${system}.xava);
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);

apps = forAllSystems (system: {
xava = {
type = "app";
program = "${self.packages.${system}.xava}/bin/xava";
};
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [self.overlay];
});
in rec {
overlay = final: prev: {
xava = final.stdenv.mkDerivation {
name = "xava";
version = "unstable";
description = "X11 Audio Visualizer for ALSA";

src = self;

cmakeFlags = [
(final.lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
"-DNIX_BUILDER=ON"
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
];

nativeBuildInputs = with final; [
# Compiling and fetching dependencies
gcc
cmake
pkg-config
git # Not sure if it's needed

# For building icons
imagemagick
librsvg
];

buildInputs = with final; [
# Basic
fftwFloat
iniparser

# Input
alsa-lib
libpulseaudio
pipewire
portaudio
sndio

# Output
SDL2
wayland
wayland-protocols
wayland-scanner
wayland-utils
xorg.libX11
xorg.libXdmcp
xorg.libXfixes
xorg.libXrandr

# Graphics API
cairo
glew

defaultApp = forAllSystems (system: self.apps.${system}.xava);
# Misc
curl
dbus
expat # Might be a nixpkgs bug idfk
taglib
zlib
];

devShell = forAllSystems (system:
nixpkgs.legacyPackages.${system}.mkShell {
inputsFrom = builtins.attrValues (packages.${system});
});
#outputs = [ "out" "lib" ];

#postInstall = ''
# moveToOutput "lib" "$lib"
#'';

CARGO_FEATURE_USE_SYSTEM_LIBS = "1";
};
};

packages =
forAllSystems (system: {inherit (nixpkgsFor.${system}) xava;});

defaultPackage = forAllSystems (system: self.packages.${system}.xava);

apps = forAllSystems (system: {
xava = {
type = "app";
program = "${self.packages.${system}.xava}/bin/xava";
};
});

defaultApp = forAllSystems (system: self.apps.${system}.xava);

devShell = forAllSystems (system:
nixpkgs.legacyPackages.${system}.mkShell {
inputsFrom = builtins.attrValues (packages.${system});
});
};
}
7 changes: 4 additions & 3 deletions src/output/graphical_wayland/build.cmake
Original file line number Diff line number Diff line change
@@ -4,19 +4,20 @@ pkg_get_variable(WL_PROT_DIR wayland-protocols pkgdatadir)

# Project default
option(WAYLAND "WAYLAND" ON)

IF(WAYLAND_PROTOCOLS_FOUND)
find_program(SCANNER wayland-scanner
REQUIRED)
function(generate_wayland_source input output)
get_filename_component(FILE_EXT "${output}" LAST_EXT)
if(FILE_EXT MATCHES ".c")
add_custom_command(OUTPUT "${XAVA_MODULE_DIR}/gen/${output}"
COMMAND wayland-scanner private-code
COMMAND "${SCANNER}" private-code
"${input}"
"${XAVA_MODULE_DIR}/gen/${output}"
VERBATIM)
elseif(FILE_EXT MATCHES ".h")
add_custom_command(OUTPUT "${XAVA_MODULE_DIR}/gen/${output}"
COMMAND wayland-scanner client-header
COMMAND "${SCANNER}" client-header
"${input}"
"${XAVA_MODULE_DIR}/gen/${output}"
VERBATIM)

0 comments on commit 67dceab

Please sign in to comment.