From b648477b91e3cb1aefd5b6b8fdd94ffbbd79fcb1 Mon Sep 17 00:00:00 2001 From: Davi Ribeiro <104164579+Markus328@users.noreply.github.com> Date: Fri, 29 Aug 2025 01:07:47 -0300 Subject: nix: better nix develop + refactor (#490) --- CMakeLists.txt | 9 +++++++-- assets/cpp/CMakeLists.txt | 1 + flake.nix | 13 ++++++++++--- nix/default.nix | 35 +++++++++++++++++++++++++++++------ plugin/CMakeLists.txt | 1 + 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a29625f..513e9de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,13 @@ set(INSTALL_QSCONFDIR "etc/xdg/quickshell/caelestia" CACHE STRING "Quickshell co add_compile_options(-Wall -Wextra) -add_subdirectory(assets/cpp) -add_subdirectory(plugin) +if(NOT DONT_BUILD_ASSETS) + add_subdirectory(assets/cpp) +endif() + +if(NOT DONT_BUILD_PLUGIN) + add_subdirectory(plugin) +endif() foreach(dir assets components config modules services utils) install(DIRECTORY ${dir} DESTINATION "${INSTALL_QSCONFDIR}") diff --git a/assets/cpp/CMakeLists.txt b/assets/cpp/CMakeLists.txt index a836850..ef12370 100644 --- a/assets/cpp/CMakeLists.txt +++ b/assets/cpp/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.19) find_package(PkgConfig REQUIRED) pkg_check_modules(PIPEWIRE REQUIRED libpipewire-0.3) pkg_check_modules(AUBIO REQUIRED aubio) diff --git a/flake.nix b/flake.nix index edb46bd..493723a 100644 --- a/flake.nix +++ b/flake.nix @@ -45,10 +45,17 @@ default = let shell = self.packages.${pkgs.system}.caelestia-shell; in - pkgs.mkShellNoCC { - inputsFrom = [shell]; + pkgs.mkShell { + inputsFrom = [shell shell.plugin shell.assets]; packages = with pkgs; [material-symbols rubik nerd-fonts.caskaydia-cove]; - CAELESTIA_LIB_DIR = "${shell}/lib"; + + CAELESTIA_XKB_RULES_PATH = "${pkgs.xkeyboard-config}/share/xkeyboard-config-2/rules/base.lst"; + shellHook = '' + cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --build build + export CAELESTIA_LIB_DIR="$PWD/build/assets/cpp"; + export QML2_IMPORT_PATH="$PWD/build/qml"; + ''; }; }); diff --git a/nix/default.nix b/nix/default.nix index dc1c9ac..11ea33d 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -63,25 +63,44 @@ fontconfig = makeFontsConf { fontDirectories = [material-symbols rubik nerd-fonts.caskaydia-cove]; }; + + assets = stdenv.mkDerivation { + name = "caelestia-assets"; + src = ./../assets/cpp; + + nativeBuildInputs = [cmake pkg-config]; + buildInputs = [aubio pipewire]; + + cmakeFlags = [(lib.cmakeFeature "INSTALL_LIBDIR" "${placeholder "out"}/lib")]; + }; + + plugin = stdenv.mkDerivation { + name = "caelestia-qml-plugin"; + src = ./../plugin; + nativeBuildInputs = [cmake]; + buildInputs = [qt6.qtbase qt6.qtdeclarative]; + dontWrapQtApps = true; + cmakeFlags = [(lib.cmakeFeature "INSTALL_QMLDIR" qt6.qtbase.qtQmlPrefix)]; + }; in stdenv.mkDerivation { inherit version; pname = "caelestia-shell"; src = ./..; - nativeBuildInputs = [cmake ninja pkg-config makeWrapper qt6.wrapQtAppsHook]; - buildInputs = [quickshell aubio pipewire xkeyboard-config qt6.qtbase qt6.qtdeclarative]; + nativeBuildInputs = [cmake ninja makeWrapper qt6.wrapQtAppsHook]; + buildInputs = [quickshell assets plugin xkeyboard-config qt6.qtbase]; propagatedBuildInputs = runtimeDeps; cmakeBuildType = "Release"; cmakeFlags = [ (lib.cmakeFeature "VERSION" version) - (lib.cmakeFeature "INSTALL_LIBDIR" "${placeholder "out"}/lib") - (lib.cmakeFeature "INSTALL_QMLDIR" qt6.qtbase.qtQmlPrefix) + (lib.cmakeFeature "DONT_BUILD_PLUGIN" "ON") + (lib.cmakeFeature "DONT_BUILD_ASSETS" "ON") (lib.cmakeFeature "INSTALL_QSCONFDIR" "${placeholder "out"}/share/caelestia-shell") ]; - patchPhase = '' + prePatch = '' substituteInPlace assets/pam.d/fprint \ --replace-fail pam_fprintd.so /run/current-system/sw/lib/security/pam_fprintd.so ''; @@ -90,11 +109,15 @@ in makeWrapper ${quickshell}/bin/qs $out/bin/caelestia-shell \ --prefix PATH : "${lib.makeBinPath runtimeDeps}" \ --set FONTCONFIG_FILE "${fontconfig}" \ - --set CAELESTIA_LIB_DIR $out/lib \ + --set CAELESTIA_LIB_DIR ${assets}/lib \ --set CAELESTIA_XKB_RULES_PATH ${xkeyboard-config}/share/xkeyboard-config-2/rules/base.lst \ --add-flags "-p $out/share/caelestia-shell" ''; + passthru = { + inherit plugin assets; + }; + meta = { description = "A very segsy desktop shell"; homepage = "https://github.com/caelestia-dots/shell"; diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index a493c32..a7b176b 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.19) find_package(Qt6 REQUIRED COMPONENTS Core Qml) if(QT_KNOWN_POLICY_QTP0001) -- cgit v1.2.3-freya