attempt nix packaging
This commit is contained in:
parent
25d48d79af
commit
2eafe4b950
7 changed files with 145 additions and 26 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -76,4 +76,4 @@ cmake-build-debug
|
|||
*.dll
|
||||
*.exe
|
||||
build
|
||||
|
||||
result
|
||||
|
|
|
@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON)
|
|||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
|
||||
set(TS_FILES swaymux_en_US.ts)
|
||||
|
||||
|
@ -52,7 +52,6 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
||||
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
|
||||
|
||||
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||
else()
|
||||
if(ANDROID)
|
||||
add_library(swaymux SHARED
|
||||
|
@ -65,8 +64,6 @@ else()
|
|||
${PROJECT_SOURCES}
|
||||
)
|
||||
endif()
|
||||
|
||||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||
endif()
|
||||
|
||||
target_link_libraries(swaymux PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
|
11
LICENSE
Normal file
11
LICENSE
Normal file
|
@ -0,0 +1,11 @@
|
|||
Copyright 2024 Grimmauld
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
flake.lock
Normal file
26
flake.lock
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1709905912,
|
||||
"narHash": "sha256-TofHtnlrOBCxtSZ9nnlsTybDnQXUmQrlIleXF1RQAwQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a343533bccc62400e8a9560423486a3b6c11a23b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
59
flake.nix
Normal file
59
flake.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
{
|
||||
description = "Swaymux: sway workspace/output/container navigation";
|
||||
|
||||
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||
# forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: forSystem system fn);
|
||||
in {
|
||||
checks = forAllSystems ({
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
alejandra = pkgs.runCommand "check-alejandra" {} ''
|
||||
${lib.getExe pkgs.alejandra} --check ${./.}
|
||||
touch $out
|
||||
'';
|
||||
});
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
# base toolchain
|
||||
gcc
|
||||
qt6.full
|
||||
qtcreator
|
||||
cmake
|
||||
nlohmann_json
|
||||
qtwayland
|
||||
|
||||
# nix utils
|
||||
self.formatter.${pkgs.system}
|
||||
nil
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
formatter = forAllSystems (pkgs: pkgs.alejandra);
|
||||
|
||||
packages = forAllSystems (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
swaymux-pkg = (pkgs.qt6Packages.callPackage ./nix/default.nix {});
|
||||
in {
|
||||
swaymux = swaymux-pkg;
|
||||
default = swaymux-pkg;
|
||||
});
|
||||
};
|
||||
}
|
20
main.cpp
20
main.cpp
|
@ -1,17 +1,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "sway_bindings/Sway.h"
|
||||
#include "tree/swaytree.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QScreen>
|
||||
#include <QTreeView>
|
||||
#include<iostream>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
|
@ -31,15 +20,6 @@ int main(int argc, char *argv[])
|
|||
QCoreApplication::setOrganizationName("Grimmauld");
|
||||
QCoreApplication::setApplicationName("SwayMux");
|
||||
|
||||
QTranslator translator;
|
||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||
for (const QString &locale : uiLanguages) {
|
||||
const QString baseName = "swaymux_" + QLocale(locale).name();
|
||||
if (translator.load(":/i18n/" + baseName)) {
|
||||
a.installTranslator(&translator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MainWindow w;
|
||||
w.showMaximized();
|
||||
return a.exec();
|
||||
|
|
46
nix/default.nix
Normal file
46
nix/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
lib,
|
||||
nlohmann_json,
|
||||
cmake,
|
||||
stdenv,
|
||||
qt6,
|
||||
qtbase,
|
||||
wrapQtAppsHook,
|
||||
qtwayland
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "swaymux";
|
||||
version = "0.1";
|
||||
|
||||
src = lib.cleanSource ../.;
|
||||
|
||||
configurePhase = ''
|
||||
cmake .
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
make
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv swaymux $out/bin
|
||||
'';
|
||||
|
||||
buildInputs = [ qtbase qtwayland cmake nlohmann_json ];
|
||||
nativeBuildInputs = [ wrapQtAppsHook ];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A program to quickly navigate sway";
|
||||
longDescription = ''
|
||||
Swaymux allows the user to quickly navigate and administrate outputs, workspaces and containers in a tmux-style approach.
|
||||
'';
|
||||
homepage = "https://git.grimmauld.de/Grimmauld/swaymux";
|
||||
changelog = "https://git.grimmauld.de/Grimmauld/swaymux/commits/branch/main";
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = [ maintainers.grimmauld ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue