build: nix packaging

This commit is contained in:
outfoxxed 2024-03-04 05:04:29 -08:00
parent dfeb02e50b
commit 28087c182e
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 128 additions and 23 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
# build files
/result
/build/
compile_commands.json

View file

@ -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})

View file

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

58
default.nix Normal file
View file

@ -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;
};
}

26
flake.lock Normal file
View file

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

23
flake.nix Normal file
View file

@ -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;
};
});
};
}

1
package.nix Normal file
View file

@ -0,0 +1 @@
{ pkgs ? import <nixpkgs> {}, ... }: pkgs.callPackage ./default.nix {}

View file

@ -1,36 +1,27 @@
{ pkgs ? import <nixpkgs> {} }: let
{
pkgs ? import <nixpkgs> {},
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"

View file

@ -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()