diff --git a/.gitignore b/.gitignore index eeb0d2ec..2fc15547 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # build files +/result /build/ compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index c0da8169..facd98c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ option(WAYLAND_WLR_LAYERSHELL "Support the zwlr_layer_shell_v1 wayland protocol" option(WAYLAND_SESSION_LOCK "Support the ext_session_lock_v1 wayland protocol" ON) message(STATUS "Quickshell configuration") -message(STATUS " Build tests: ${TESTS}") +message(STATUS " Build tests: ${BUILD_TESTING}") message(STATUS " Sockets: ${SOCKETS}") message(STATUS " Wayland: ${WAYLAND}") if (WAYLAND) @@ -36,7 +36,7 @@ endif() set(QT_DEPS Qt6::Gui Qt6::Qml Qt6::Quick Qt6::QuickControls2) set(QT_FPDEPS Gui Qml Quick QuickControls2) -if (TESTS) +if (BUILD_TESTING) enable_testing() list(APPEND QT_FPDEPS Test) endif() @@ -61,3 +61,5 @@ add_subdirectory(src/io) if (WAYLAND) add_subdirectory(src/wayland) endif () + +install(TARGETS quickshell RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Justfile b/Justfile index 3de65e90..f37a1ecd 100644 --- a/Justfile +++ b/Justfile @@ -27,4 +27,7 @@ run *ARGS='': build {{builddir}}/src/core/quickshell {{ARGS}} test *ARGS='': build - ctest --test-dir build --output-on-failure {{ARGS}} + ctest --test-dir {{builddir}} --output-on-failure {{ARGS}} + +install *ARGS='': clean (configure "release") build + cmake --install {{builddir}} {{ARGS}} diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..01a88b47 --- /dev/null +++ b/default.nix @@ -0,0 +1,58 @@ +{ + lib, + nix-gitignore, + pkgs, + keepDebugInfo, + stdenv ? (keepDebugInfo pkgs.stdenv), + + cmake, + ninja, + qt6, + wayland, + wayland-protocols, + + debug ? false, + enableWayland ? true, +}: stdenv.mkDerivation { + pname = "quickshell${lib.optionalString debug "-debug"}"; + version = "0.1"; + src = nix-gitignore.gitignoreSource [] ./.; + + nativeBuildInputs = with pkgs; [ + cmake + ninja + qt6.wrapQtAppsHook + ] ++ (lib.optionals enableWayland [ + pkg-config + wayland-protocols + wayland-scanner + ]); + + buildInputs = with pkgs; [ + qt6.qtbase + qt6.qtdeclarative + ] ++ (lib.optionals enableWayland [ qt6.qtwayland wayland ]); + + QTWAYLANDSCANNER = lib.optionalString enableWayland "${qt6.qtwayland}/libexec/qtwaylandscanner"; + + configurePhase = let + cmakeBuildType = if debug + then "Debug" + else "RelWithDebInfo"; + in '' + cmakeBuildType=${cmakeBuildType} # qt6 setup hook resets this for some godforsaken reason + cmakeConfigurePhase + ''; + + cmakeFlags = lib.optional (!enableWayland) "-DWAYLAND=OFF"; + + buildPhase = "ninjaBuildPhase"; + enableParallelBuilding = true; + dontStrip = true; + + meta = with lib; { + homepage = "https://git.outfoxxed.me/outfoxxed/quickshell"; + description = "Simple and flexbile QtQuick based desktop shell toolkit"; + platforms = platforms.linux; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..1527f635 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..b9ba8d1f --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: let + forEachSystem = fn: nixpkgs.lib.genAttrs + [ "x86_64-linux" "aarch64-linux" ] + (system: fn system nixpkgs.legacyPackages.${system}); + in { + packages = forEachSystem (system: pkgs: rec { + quickshell = import ./package.nix { inherit pkgs; }; + default = quickshell; + }); + + devShells = forEachSystem (system: pkgs: rec { + default = import ./shell.nix { + inherit pkgs; + inherit (self.packages.${system}) quickshell; + }; + }); + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 00000000..a3e6249e --- /dev/null +++ b/package.nix @@ -0,0 +1 @@ +{ pkgs ? import {}, ... }: pkgs.callPackage ./default.nix {} diff --git a/shell.nix b/shell.nix index 3d71bfb4..484bf70a 100644 --- a/shell.nix +++ b/shell.nix @@ -1,36 +1,27 @@ -{ pkgs ? import {} }: let +{ + pkgs ? import {}, + quickshell ? pkgs.callPackage ./default.nix {}, + ... +}: let tidyfox = import (pkgs.fetchFromGitea { domain = "git.outfoxxed.me"; owner = "outfoxxed"; repo = "tidyfox"; rev = "1f062cc198d1112d13e5128fa1f2ee3dbffe613b"; sha256 = "kbt0Zc1qHE5fhqBkKz8iue+B+ZANjF1AR/RdgmX1r0I="; - }) {}; + }) { inherit pkgs; }; in pkgs.mkShell { + inputsFrom = [ quickshell ]; + nativeBuildInputs = with pkgs; [ just clang-tools_17 parallel - cmake - ninja - - pkg-config - wayland-scanner - - qt6.wrapQtAppsHook makeWrapper ]; - buildInputs = with pkgs; [ - qt6.qtbase - qt6.qtdeclarative - qt6.qtwayland - wayland - wayland-protocols - ]; - - QTWAYLANDSCANNER = "${pkgs.qt6.qtwayland}/libexec/qtwaylandscanner"; TIDYFOX = "${tidyfox}/lib/libtidyfox.so"; + QTWAYLANDSCANNER = quickshell.QTWAYLANDSCANNER; shellHook = '' export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) @@ -39,7 +30,7 @@ in pkgs.mkShell { # https://discourse.nixos.org/t/qt-development-environment-on-a-flake-system/23707/5 setQtEnvironment=$(mktemp) random=$(openssl rand -base64 20 | sed "s/[^a-zA-Z0-9]//g") - makeWrapper "$(type -p sh)" "$setQtEnvironment" "''${qtWrapperArgs[@]}" --argv0 "$random" + makeShellWrapper "$(type -p sh)" "$setQtEnvironment" "''${qtWrapperArgs[@]}" --argv0 "$random" sed "/$random/d" -i "$setQtEnvironment" source "$setQtEnvironment" diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index db697763..75783830 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -16,6 +16,6 @@ target_link_libraries(quickshell-io-init PRIVATE ${QT_DEPS}) target_link_libraries(quickshell PRIVATE quickshell-ioplugin quickshell-io-init) -if (TESTS) +if (BUILD_TESTING) add_subdirectory(test) endif()