Skip to content

Commit

Permalink
#3061 nix: try to add build system for older Qt5 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Aug 3, 2024
1 parent 5cb8d97 commit 0bfbc37
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
81 changes: 81 additions & 0 deletions build-systems/nix/default-qt5.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{ lib
, stdenv
, fetchurl
, qmake
, qttools
, qtbase
, qtdeclarative
, qtsvg
, qtwayland
, qtwebsockets
, qt5compat
, makeWrapper
, wrapQtAppsHook
, botan2
, pkg-config
, xvfb-run
, installShellFiles
}:

let
pname = "qownnotes";
appname = "QOwnNotes";
# version = builtins.head (builtins.match "#define VERSION \"([0-9.]+)\"" (builtins.readFile ./src/version.h));
version = "local-build";
in
stdenv.mkDerivation {
inherit pname appname version;

src = builtins.path { path = ./src; name = "qownnotes"; };

nativeBuildInputs = [
qmake
qttools
wrapQtAppsHook
pkg-config
installShellFiles
xvfb-run
] ++ lib.optionals stdenv.isDarwin [ makeWrapper ];

buildInputs = [
qtbase
qtdeclarative
qtsvg
qtwebsockets
qt5compat
botan2
] ++ lib.optionals stdenv.isLinux [ qtwayland ];

qmakeFlags = [
"USE_SYSTEM_BOTAN=1"
];

postInstall = ''
installShellCompletion --cmd ${appname} \
--bash <(xvfb-run $out/bin/${appname} --completion bash) \
--fish <(xvfb-run $out/bin/${appname} --completion fish)
installShellCompletion --cmd ${pname} \
--bash <(xvfb-run $out/bin/${appname} --completion bash) \
--fish <(xvfb-run $out/bin/${appname} --completion fish)
''
# Create a lowercase symlink for Linux
+ lib.optionalString stdenv.isLinux ''
ln -s $out/bin/${appname} $out/bin/${pname}
''
# Wrap application for macOS as lowercase binary
+ lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications
mv $out/bin/${appname}.app $out/Applications
makeWrapper $out/Applications/${appname}.app/Contents/MacOS/${appname} $out/bin/${pname}
'';

meta = with lib; {
description = "Plain-text file notepad and todo-list manager with Markdown support and Nextcloud/ownCloud integration";
homepage = "https://www.qownnotes.org/";
changelog = "https://www.qownnotes.org/changelog.html";
downloadPage = "https://github.com/pbek/QOwnNotes/releases/tag/v${version}";
license = licenses.gpl2Only;
maintainers = with maintainers; [ pbek totoroot ];
platforms = platforms.unix;
};
}
16 changes: 15 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-qt515.url = "github:nixos/nixpkgs/72bbea9db7d727ed044e60b5f5febc60a3c5c955";
systems.url = "github:nix-systems/default";
};

outputs = { self, nixpkgs }: {
outputs = {
self,
nixpkgs,
nixpkgs-qt515,
# systems,
}: let
systems = [ "x86_64-linux" ];
eachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = eachSystem (system: {
qownnotes-qt5 = nixpkgs.${system}.legacyPackages.libsForQt5.callPackage (import ./build-systems/nix/default-qt5.nix) { };
qownnotes-qt515 = nixpkgs-qt515.${system}.legacyPackages.libsForQt5.callPackage (import ./build-systems/nix/default-qt5.nix) { };
});

devShell.x86_64-linux =
with import nixpkgs {
Expand Down

0 comments on commit 0bfbc37

Please sign in to comment.