Skip to content

activitywatch: init at 0.12.2#202935

Merged
SuperSandro2000 merged 7 commits intoNixOS:masterfrom
huantianad:activitywatch
May 11, 2023
Merged

activitywatch: init at 0.12.2#202935
SuperSandro2000 merged 7 commits intoNixOS:masterfrom
huantianad:activitywatch

Conversation

@huantianad
Copy link
Copy Markdown
Contributor

@huantianad huantianad commented Nov 25, 2022

Description of changes

ActivityWatch is an app that automatically tracks how you spend time on your devices.

It is open source, privacy-first, cross-platform, and a great alternative to services like RescueTime, ManicTime, and WakaTime.

It can be used to keep track of your productivity, time spent on different projects, bad screen habits, or just to understand how you spend your time.

Resolves #97379, ActivityWatch/activitywatch#556.

PR still very WIP and looking for feedback!

Packages 3rd party python modules dependencies under python3Packages, as well as aw-core and aw-client as they're used for making custom watchers. Other parts of the application are packaged normally under all-packages.nix

TODO
  • Further discuss and iterate on package structure
  • Setup and double check tests for each package.
  • NixOS module which should contain a systemd service for autostart
  • Can we run their integration tests as a NixOS test?
Related issues

#59026
ActivityWatch/activitywatch#556

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions Bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 25, 2022
Comment thread pkgs/applications/office/activitywatch/default.nix Outdated
@ofborg ofborg Bot added the 8.has: package (new) This PR adds a new package label Nov 25, 2022
@ofborg ofborg Bot requested a review from jtojnar November 25, 2022 23:39
@ofborg ofborg Bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Nov 25, 2022
@noisersup
Copy link
Copy Markdown
Member

What's the state of activitywatch packaging? Is there anything that I could help with?

@huantianad
Copy link
Copy Markdown
Contributor Author

I was planning to wait for 0.12.2 since it should include some small patches to help with packaging, but that seems like it'll take a bit. I'll continue working on this, the main thing to consider are mostly design choices, like making a single package that combines server + qt + watchers, or a nixos module for autostart.

@ofborg ofborg Bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Feb 21, 2023
@huantianad
Copy link
Copy Markdown
Contributor Author

huantianad commented Feb 26, 2023

I've updated some of the python modules and added some tests, along with general cleanup in this latest change.

I was wondering, is there a good way to combine the individual derivations for each component into one large activitywatch derivation for people to install? I think it'd be more userfriendly than having to add aw-server-rust, aw-qt, aw-watcher-window, and aw-watcher-afk to your packages.

Alternatively, maybe a NixOS module would be a good way to do it to, to allow for autostart?

@ofborg ofborg Bot added 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. and removed 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Feb 26, 2023
@noisersup
Copy link
Copy Markdown
Member

noisersup commented Mar 1, 2023

Alternatively, maybe a NixOS module would be a good way to do it to, to allow for autostart?

Module sound reasonable for that. Not sure if there's something additional that could be done.

EDIT: tested it a little bit and it seems that some basic functionality works! Thank you for work on that.

@huantianad
Copy link
Copy Markdown
Contributor Author

@noisersup I'll work on the systemd unit, lemme know if you find any bugs! I'm also using this on my daily driver machine, so far it's been pretty good but I don't use it super intensively either, so it's nice to have some more bug testers :)

@huantianad huantianad changed the title activitywatch: init at 0.12.1 activitywatch: init at 0.12.2 Mar 25, 2023
@huantianad
Copy link
Copy Markdown
Contributor Author

huantianad commented Mar 29, 2023

Hm, so many random hiccups. I decided to create a wrapper for all the different programs that are a part of activitywatch, that simply symlinkJoins them all. The main purpose of this is to both create a single package for users to install, but also a single package for a NixOS module to use in a systemd service.

However, it seems that using symlinkJoin doesn't work for aw-qt, even though aw-qt should search for executables around it starting with aw- to load, it seems that it uses the location of the aw-qt module, not the executable.

I'm not sure if it's even worth it to create a single derivation combining all the sub-programs. Should we just direct users to use the NixOS module, or manually add each component to their system packages?

In addition, there's still issues on KDE Plasma where aw-qt will fail to start if it's started by systemd or xdg-desktop-autostart before the panel with the system tray is loaded. This might be something requiring an upstream fix though.

P.S. Am I correct in using qt6Packages.callPackage here, instead of taking qt6 as an argument?

@Oro
Copy link
Copy Markdown
Contributor

Oro commented Apr 17, 2023

FYI, in case it's relevant: I cannot seem to build aw-server-rust on nix run nixpkgs#nixpkgs-review pr 202935, dunno though if that's just me and I'm doing something wrong, if that's the case please feel free to ignore

$ git -c fetch.prune=false fetch --no-tags --force https://github.com/NixOS/nixpkgs master:refs/nixpkgs-review/0 pull/202935/head:refs/nixpkgs-review/1
remote: Enumerating objects: 4835, done.
remote: Counting objects: 100% (2508/2508), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 4835 (delta 2494), reused 2504 (delta 2493), pack-reused 2327
Receiving objects: 100% (4835/4835), 3.99 MiB | 7.24 MiB/s, done.
Resolving deltas: 100% (3295/3295), completed with 766 local objects.
From https://github.com/NixOS/nixpkgs
   060e8eee747..93f1a51c1d0  master     -> refs/nixpkgs-review/0
$ git worktree add /home/oro/.cache/nixpkgs-review/pr-202935-2/nixpkgs 93f1a51c1d0ab5697eab9dd4515186bda9da771b
Preparing worktree (detached HEAD 93f1a51c1d0)
Updating files: 100% (34544/34544), done.
HEAD is now at 93f1a51c1d0 Merge pull request #226636 from MatthewCroughan/mc/fix-nixos-shell
$ git merge --no-commit --no-ff f86ddc0e288d54037430daaa599d0c1a01230a82
Auto-merging pkgs/top-level/all-packages.nix
Auto-merging pkgs/top-level/python-packages.nix
Automatic merge went well; stopped before committing as requested
$ nix build --extra-experimental-features nix-command no-url-literals --no-link --keep-going --no-allow-import-from-derivation --option build-use-sandbox relaxed -f /home/oro/.cache/nixpkgs-review/pr-202935-2/build.nix
error: builder for '/nix/store/fr10rwzr6ybwfsr6nqb3sx2bqswxzbbm-aw-server-rust-0.12.2-vendor.tar.gz.drv' failed with exit code 1;
       last 10 log lines:
       > configuring
       > no configure script, doing nothing
       > building
       > source = "git+https://github.com/lawliet89/rocket_cors?rev=54fae07#54fae0701dffbe5df686465780218644ee3fae5f"
       >
       > ERROR: The Cargo.lock contains git dependencies
       >
       > This is currently not supported in the fixed-output derivation fetcher.
       > Use cargoLock.lockFile / importCargoLock instead.
       >
       For full logs, run 'nix log /nix/store/fr10rwzr6ybwfsr6nqb3sx2bqswxzbbm-aw-server-rust-0.12.2-vendor.tar.gz.drv'.
error: 1 dependencies of derivation '/nix/store/ql2a7mkshqyx4igwyi1zafjasy5v15rs-aw-server-rust-0.12.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bv9hvsnw82hp1irsm60aqgqgm60i11rv-activitywatch-0.12.2.drv' failed to build
error: 2 dependencies of derivation '/nix/store/cibkb6f0d6m2f2gnxqs3lid8wcxagzm8-review-shell.drv' failed to build

Link to currently reviewing PR:
https://github.com/NixOS/nixpkgs/pull/202935

2 packages failed to build:
activitywatch aw-server-rust

26 packages built:
aw-qt aw-qt.dist aw-watcher-afk aw-watcher-afk.dist aw-watcher-window aw-watcher-window.dist python310Packages.TakeTheTime python310Packages.TakeTheTime.dist python310Packages.aw-client python310Packages.aw-client.dist python310Packages.aw-core python310Packages.aw-core.dist python310Packages.persist-queue python310Packages.persist-queue.dist python310Packages.timeslot python310Packages.timeslot.dist python311Packages.TakeTheTime python311Packages.TakeTheTime.dist python311Packages.aw-client python311Packages.aw-client.dist python311Packages.aw-core python311Packages.aw-core.dist python311Packages.persist-queue python311Packages.persist-queue.dist python311Packages.timeslot python311Packages.timeslot.dist

error: build log of '/nix/store/bv9hvsnw82hp1irsm60aqgqgm60i11rv-activitywatch-0.12.2.drv!*' is not available
error: build log of '/nix/store/a629ypyqp14xaf61pxyd127f56imadm8-activitywatch-0.12.2' is not available
error: build log of '/nix/store/ql2a7mkshqyx4igwyi1zafjasy5v15rs-aw-server-rust-0.12.2.drv!*' is not available
error: build log of '/nix/store/dkgldxyp9inq3v5qyh7sipqqqinyjlbg-aw-server-rust-0.12.2' is not available
$ /nix/store/0rn3w6lr8fn3y502xdzbjkm9vchizkza-nix-2.13.3/bin/nix-shell /home/oro/.cache/nixpkgs-review/pr-202935-2/shell.nix

@huantianad
Copy link
Copy Markdown
Contributor Author

Ah, this should be due to 4329de1, I'll rebase on master then make a fix for it. Thanks for the catch!

@huantianad
Copy link
Copy Markdown
Contributor Author

I've decided that the activitywatch symlinkJoin wrapper is worth keeping even if aw-qt uses PATH to find it's modules.

I also think that this package is in a state that's ready to be merged. The two main features that I'd like to add would be NixOS module and running integration tests with NixOS test. However, neither are priority and I think it's fine if we add them later.

PS is there anything I should do regarding the mainProgram for a symlinkJoin? Or any other metadata?

@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/2137

Comment thread pkgs/top-level/python-packages.nix Outdated
Comment thread pkgs/development/python-modules/timeslot/default.nix Outdated
Comment thread pkgs/development/python-modules/timeslot/default.nix Outdated
Comment thread pkgs/development/python-modules/persist-queue/default.nix Outdated
Comment thread pkgs/development/python-modules/aw-core/default.nix Outdated
Comment thread pkgs/development/python-modules/TakeTheTime/default.nix Outdated
Comment thread pkgs/applications/office/activitywatch/wrapper.nix Outdated
Comment thread pkgs/applications/office/activitywatch/default.nix Outdated
Comment thread pkgs/applications/office/activitywatch/default.nix Outdated
Comment thread pkgs/applications/office/activitywatch/default.nix Outdated
@huantianad
Copy link
Copy Markdown
Contributor Author

huantianad commented Apr 26, 2023

@SuperSandro2000 thanks for the review! I've left some comments regarding tests and the symlink join. I haven't squashed the changes yet, hopefully that's fine.

Copy link
Copy Markdown
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if possible, but it would be nice to add Cargo.lock as a patch. It's considered best practice for executables in rust to version control their lock file.

Please follow CONTRIBUTING.md and manual#submitting-changes-making-patches and squash the fix-up commits.

git rebase -i is a powerful command which achieves this, I created a small video demonstrating it's use here. A more indepth text tutorial can be found here

@huantianad
Copy link
Copy Markdown
Contributor Author

Regarding the Cargo.lock file, it is indeed already version controlled upstream, and I was previously using it. However, 4329de1 breaks it due to there being a single git dependency, so I switched to putting the Cargo.lock file in nixpkgs a la #221716. I haven't read up on all of this yet though, if there's been a better way introduced please let me know and I'll fix it!

I'll go ahead and rebase, I wasn't sure if I should squash the fixes before they were approved or not, so I erred on the side of doing less. I'll just squash any changes immediately instead of pushing them in the future, thanks for the resources!

Copy link
Copy Markdown
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a pythonImportsCheck to all packages. I think the rest is looking good.

@huantianad
Copy link
Copy Markdown
Contributor Author

@SuperSandro2000 done! Let me know if there's anything I can do to get pytest working for persist-queue, and if the symlinkJoin wrapper is correct (is there anything I need to do in terms of metadata for it?). Thanks for all the help!

@SuperSandro2000 SuperSandro2000 merged commit bc71eca into NixOS:master May 11, 2023
@ErikBjare
Copy link
Copy Markdown

Awesome job, thanks @huantianad! ❤️

@not-matthias
Copy link
Copy Markdown

Been waiting a while for this. Thank you! ❤️

@unode unode mentioned this pull request May 30, 2023
13 tasks
@huantianad huantianad deleted the activitywatch branch June 7, 2023 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActivityWatch

8 participants