From d40b7d85f54656fdebe3479568424028e18ab017 Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Tue, 26 Nov 2024 10:05:34 +0100 Subject: [PATCH] Add dbeaver pkgs for latest updates --- flake.nix | 41 +---------- home-mods/desktop/default.nix | 2 + pkgs/dbeaver.nix | 129 ++++++++++++++++++++++++++++++++++ pkgs/default.nix | 25 +++++++ pkgs/kexec-pkgs | 0 5 files changed, 158 insertions(+), 39 deletions(-) create mode 100644 pkgs/dbeaver.nix create mode 100644 pkgs/default.nix create mode 100644 pkgs/kexec-pkgs diff --git a/flake.nix b/flake.nix index ece0c2b..1b6595c 100644 --- a/flake.nix +++ b/flake.nix @@ -165,6 +165,7 @@ pkgs = import nixpkgs { inherit config system overlays; }; + lib = pkgs.lib; hmModules = [ nix-index-database.hmModules.nix-index nur.hmModules.nur @@ -190,45 +191,7 @@ formatter = { ${system} = pkgs.nixpkgs-fmt; }; - packages."${system}" = - let - # list paths - pkgs-paths-list = pkgs.lib.fileset.toList (pkgs.lib.fileset.fromSource (pkgs.lib.sources.sourceFilesBySuffices ./pkgs [ ".nix" ])); - # filename-extension parsed out - pkgs-paths = - builtins.map - (path: { - name = pkgs.lib.strings.removeSuffix ".nix" (builtins.baseNameOf path); - path = path; - }) - pkgs-paths-list; - # import each path - imported-pkgs = pkgs.lib.attrsets.mergeAttrsList (builtins.map - (pkg: { - "${pkg.name}" = pkgs.callPackage pkg.path { }; - }) - pkgs-paths); - # kexec-installer-path = ./systems/rescue-kexec; - kexec-installer-path = builtins.toPath "${inputs.nixos-images}/nix/kexec-installer/module.nix"; - kexec-installer-fn = nixpkgs: module: (nixpkgs.legacyPackages.${system}.nixos [ module kexec-installer-path ]).config.system.build.kexecTarball; - # rescue-kexec-fn = ./systems/rescue-kexec; - kexec-pkgs = { - # build: - # nix build ".#packages.x86_64-linux.rescue-kexec-pkg" - # - # copy over single files: - # tar -xvf result/nixos-kexec-installer-x86_64-linux.tar.gz - # ssh root@176.9.242.147 "mkdir /root/kexec/" - # for file in (ls ./kexec/); echo Transferring $file; cat ./kexec/$file | ssh root@176.9.242.147 "cat > /root/kexec/$file" ; end - # ssh root@176.9.242.147 "/root/kexec/run" - rescue-kexec-pkg = kexec-installer-fn nixpkgs { - imports = [ ./systems/rescue-kexec ]; - # imports = [ ]; - _module.args = { inherit inputs; }; - }; - }; - in - imported-pkgs // kexec-pkgs; + packages."${system}" = import ./pkgs { inherit pkgs lib; }; diskoConfigurations = { nixos-desk = import ./systems/nixos-desk/disko.nix; nixos-pulse = import ./systems/nixos-pulse/disko.nix; diff --git a/home-mods/desktop/default.nix b/home-mods/desktop/default.nix index eb15741..13a0df3 100644 --- a/home-mods/desktop/default.nix +++ b/home-mods/desktop/default.nix @@ -118,6 +118,8 @@ pcsx2 xdelta winetricks + my.dbeaver + # dbeaver-bin # blender # miraclecast # rustdesk diff --git a/pkgs/dbeaver.nix b/pkgs/dbeaver.nix new file mode 100644 index 0000000..9c3931b --- /dev/null +++ b/pkgs/dbeaver.nix @@ -0,0 +1,129 @@ +{ lib +, stdenvNoCC +, fetchurl +, undmg +, makeWrapper +, openjdk17 +, gnused +, autoPatchelfHook +, wrapGAppsHook3 +, gtk3 +, glib +, webkitgtk_4_0 +, glib-networking +, override_xmx ? "1024m" +, +}: +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "dbeaver-bin"; + version = "24.2.5"; + + src = + let + inherit (stdenvNoCC.hostPlatform) system; + selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}"); + suffix = selectSystem { + x86_64-linux = "linux.gtk.x86_64-nojdk.tar.gz"; + aarch64-linux = "linux.gtk.aarch64-nojdk.tar.gz"; + x86_64-darwin = "macos-x86_64.dmg"; + aarch64-darwin = "macos-aarch64.dmg"; + }; + hash = selectSystem { + x86_64-linux = "sha256-LnJq23o60c+Ys0V46esP1bIkcnzj26hQUBu3Ut9bMJM="; + aarch64-linux = ""; + x86_64-darwin = ""; + aarch64-darwin = ""; + }; + in + fetchurl { + url = "https://github.com/dbeaver/dbeaver/releases/download/${finalAttrs.version}/dbeaver-ce-${finalAttrs.version}-${suffix}"; + inherit hash; + }; + + sourceRoot = lib.optional stdenvNoCC.hostPlatform.isDarwin "DBeaver.app"; + + nativeBuildInputs = + [ makeWrapper ] + ++ lib.optionals (!stdenvNoCC.hostPlatform.isDarwin) [ + gnused + wrapGAppsHook3 + autoPatchelfHook + ] + ++ lib.optionals stdenvNoCC.hostPlatform.isDarwin [ undmg ]; + + dontConfigure = true; + dontBuild = true; + + prePatch = '' + substituteInPlace ${lib.optionalString stdenvNoCC.hostPlatform.isDarwin "Contents/Eclipse/"}dbeaver.ini \ + --replace-fail '-Xmx1024m' '-Xmx${override_xmx}' + ''; + + installPhase = + if !stdenvNoCC.hostPlatform.isDarwin + then '' + runHook preInstall + + mkdir -p $out/opt/dbeaver $out/bin + cp -r * $out/opt/dbeaver + makeWrapper $out/opt/dbeaver/dbeaver $out/bin/dbeaver \ + --prefix PATH : "${openjdk17}/bin" \ + --set JAVA_HOME "${openjdk17.home}" \ + --prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules" \ + --prefix LD_LIBRARY_PATH : "$out/lib:${ + lib.makeLibraryPath [ + gtk3 + glib + webkitgtk_4_0 + glib-networking + ] + }" + + mkdir -p $out/share/icons/hicolor/256x256/apps + ln -s $out/opt/dbeaver/dbeaver.png $out/share/icons/hicolor/256x256/apps/dbeaver.png + + mkdir -p $out/share/applications + ln -s $out/opt/dbeaver/dbeaver-ce.desktop $out/share/applications/dbeaver.desktop + + substituteInPlace $out/opt/dbeaver/dbeaver-ce.desktop \ + --replace-fail "/usr/share/dbeaver-ce/dbeaver.png" "dbeaver" \ + --replace-fail "/usr/share/dbeaver-ce/dbeaver" "$out/bin/dbeaver" + + sed -i '/^Path=/d' $out/share/applications/dbeaver.desktop + + runHook postInstall + '' + else '' + runHook preInstall + + mkdir -p $out/{Applications/dbeaver.app,bin} + cp -R . $out/Applications/dbeaver.app + makeWrapper $out/{Applications/dbeaver.app/Contents/MacOS,bin}/dbeaver \ + --prefix PATH : "${openjdk17}/bin" \ + --set JAVA_HOME "${openjdk17.home}" + + runHook postInstall + ''; + + passthru.updateScript = ./update.sh; + + meta = with lib; { + homepage = "https://dbeaver.io/"; + description = "Universal SQL Client for developers, DBA and analysts. Supports MySQL, PostgreSQL, MariaDB, SQLite, and more"; + longDescription = '' + Free multi-platform database tool for developers, SQL programmers, database + administrators and analysts. Supports all popular databases: MySQL, + PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access, + Teradata, Firebird, Derby, etc. + ''; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + license = licenses.asl20; + platforms = platforms.linux ++ platforms.darwin; + maintainers = with maintainers; [ + gepbird + mkg20001 + yzx9 + ]; + mainProgram = "dbeaver"; + }; +}) diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..dfebd0b --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,25 @@ +{ pkgs +, lib +, ... +}: +let + # list paths + pkgs-paths-list = pkgs.lib.fileset.toList (pkgs.lib.fileset.fromSource (pkgs.lib.sources.sourceFilesBySuffices ./. [ ".nix" ])); + # no default.nix + filtered-paths-list = builtins.filter (path: builtins.baseNameOf path != "default.nix") pkgs-paths-list; + # filename-extension parsed out + pkgs-paths = + builtins.map + (path: { + name = pkgs.lib.strings.removeSuffix ".nix" (builtins.baseNameOf path); + path = path; + }) + filtered-paths-list; + # import each path + imported-pkgs = pkgs.lib.attrsets.mergeAttrsList (builtins.map + (pkg: { + "${pkg.name}" = pkgs.callPackage pkg.path { }; + }) + pkgs-paths); +in +imported-pkgs diff --git a/pkgs/kexec-pkgs b/pkgs/kexec-pkgs new file mode 100644 index 0000000..e69de29