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

activitywatch: init at 0.12.2 #202935

Merged
merged 7 commits into from
May 11, 2023
Merged

Conversation

huantianad
Copy link
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.

@noisersup
Copy link
Member

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

@huantianad
Copy link
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.

@huantianad
Copy link
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?

@noisersup
Copy link
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
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
@Oro
Copy link
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
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
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

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

pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/timeslot/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/timeslot/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/aw-core/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/TakeTheTime/default.nix Outdated Show resolved Hide resolved
pkgs/applications/office/activitywatch/default.nix Outdated Show resolved Hide resolved
pkgs/applications/office/activitywatch/default.nix Outdated Show resolved Hide resolved
pkgs/applications/office/activitywatch/default.nix Outdated Show resolved Hide resolved
@huantianad
Copy link
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
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
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!

@huantianad huantianad force-pushed the activitywatch branch 3 times, most recently from c75d511 to 6ec91d0 Compare April 28, 2023 02:07
Copy link
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
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

Awesome job, thanks @huantianad! ❤️

@not-matthias
Copy link

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActivityWatch
8 participants