Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

super-productivity: build from source #334933

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 108 additions & 27 deletions pkgs/by-name/su/super-productivity/package.nix
Original file line number Diff line number Diff line change
@@ -1,51 +1,132 @@
{ stdenv , lib , fetchurl , appimageTools , makeWrapper , electron }:
{
buildNpmPackage,
copyDesktopItems,
electron,
fetchFromGitHub,
lib,
makeDesktopItem,
nix-update-script,
npm-lockfile-fix,
stdenv,
}:

stdenv.mkDerivation rec {
buildNpmPackage rec {
pname = "super-productivity";
version = "10.0.11";
version = "11.0.3";

src = fetchurl {
url = "https://github.com/johannesjo/super-productivity/releases/download/v${version}/superProductivity-${version}.AppImage";
sha256 = "sha256-sYHfzqP/Vla0DEReVjaPvo8fe1wNdZnNDhefqPrPFPE=";
name = "${pname}-${version}.AppImage";
src = fetchFromGitHub {
owner = "johannesjo";
repo = "super-productivity";
tag = "v${version}";
hash = "sha256-o7Vr8g8Nh8kfW+/9RBwDBlV5cKQLemGy7qM1BrQdsUw";

postFetch = ''
${lib.getExe npm-lockfile-fix} -r $out/package-lock.json
'';
};

appimageContents = appimageTools.extractType2 {
inherit pname version src;
npmDepsHash = "sha256-YWX90SmWBnb4WwCls4Bqk5Nt9Zeff91zt00IWmi8gNM";
npmFlags = [ "--legacy-peer-deps" ];
makeCacheWritable = true;

env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
CHROMEDRIVER_SKIP_DOWNLOAD = "true";
CSC_IDENTITY_AUTO_DISCOVERY = "false";
};

dontUnpack = true;
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ copyDesktopItems ];

# package.json does not include `core-js` and the comment suggests
# it is only needed on some mobile platforms
postPatch = ''
substituteInPlace electron-builder.yaml \
--replace-fail "notarize: true" "notarize: false"
substituteInPlace src/polyfills.ts \
--replace-fail "import 'core-js/es/object';" ""
'';

buildPhase = ''
runHook preBuild

nativeBuildInputs = [ makeWrapper ];
# electronDist needs to be modifiable on Darwin
cp -r ${electron.dist} electron-dist
chmod -R u+w electron-dist

npm run buildFrontend:prod:es6
npm run electron:build
npm exec electron-builder -- --dir \
-c.electronDist=electron-dist \
-c.electronVersion=${electron.version}

runHook postBuild
'';

installPhase = ''
runHook preInstall

mkdir -p $out/bin $out/share/${pname} $out/share/applications
${
if stdenv.hostPlatform.isDarwin then
''
mkdir -p $out/Applications
cp -r "app-builds/mac"*"/Super Productivity.app" "$out/Applications"
makeWrapper "$out/Applications/Super Productivity.app/Contents/MacOS/Super Productivity" "$out/bin/super-productivity"
''
else
''
mkdir -p $out/share/super-productivity/{app,defaults,static/plugins,static/resources/plugins}
cp -r app-builds/*-unpacked/{locales,resources{,.pak}} "$out/share/super-productivity/app"

cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
cp -a ${appimageContents}/superproductivity.desktop $out/share/applications/${pname}.desktop
cp -a ${appimageContents}/usr/share/icons $out/share
for size in 16 32 48 64 128 256 512 1024; do
local sizexsize="''${size}x''${size}"
mkdir -p $out/share/icons/hicolor/$sizexsize/apps
cp -v build/icons/$sizexsize.png \
$out/share/icons/hicolor/$sizexsize/apps/super-productivity.png
done

substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
makeWrapper '${lib.getExe electron}' "$out/bin/super-productivity" \
--add-flags "$out/share/super-productivity/app/resources/app.asar" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
--inherit-argv0
''
}

runHook postInstall
'';

postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
--add-flags $out/share/${pname}/resources/app.asar
'';
# copied from deb file
desktopItems = [
(makeDesktopItem {
name = "super-productivity";
desktopName = "superProductivity";
exec = "super-productivity %u";
terminal = false;
type = "Application";
icon = "super-productivity";
startupWMClass = "superProductivity";
comment = builtins.replaceStrings [ "\n" ] [ " " ] meta.longDescription;
categories = [ "Utility" ];
})
];

passthru.updateScript = nix-update-script { };

meta = with lib; {
meta = {
description = "To Do List / Time Tracker with Jira Integration";
longDescription = ''
Experience the best ToDo app for digital professionals and get more done!
Super Productivity comes with integrated time-boxing and time tracking capabilities
and you can load your task from your calendars and from
Jira, Gitlab, GitHub, Open Project and others all into a single ToDo list.
'';
homepage = "https://super-productivity.com";
license = licenses.mit;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ offline ];
license = lib.licenses.mit;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [
offline
pineapplehunter
];
mainProgram = "super-productivity";
};
}
Loading