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 #97379

Closed
voobscout opened this issue Sep 7, 2020 · 12 comments · Fixed by #202935
Closed

ActivityWatch #97379

voobscout opened this issue Sep 7, 2020 · 12 comments · Fixed by #202935
Labels
0.kind: packaging request Request for a new package to be added

Comments

@voobscout
Copy link
Contributor

Project description

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.

Metadata

Screenshots

@voobscout voobscout added the 0.kind: packaging request Request for a new package to be added label Sep 7, 2020
@cyphase
Copy link

cyphase commented Sep 27, 2020

Docs on installing from source: https://docs.activitywatch.net/en/latest/installing-from-source.html

@AndersonTorres AndersonTorres changed the title Packaging requests: ActivityWatch ActivityWatch Oct 26, 2020
@stale
Copy link

stale bot commented Apr 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 26, 2021
@jtojnar
Copy link
Member

jtojnar commented Apr 29, 2021

I have an expression for the server in my configs repo. jtojnar/nixfiles#2 Unfortunately, it currently depends on unstable rust so it cannot be packaged in nixpkgs easily.

Edit: Now I packaged the rest too: https://github.com/jtojnar/nixfiles/blob/92406b6eda10c4e2c36b5fd7256ef3bcbfbaa085/pkgs/activitywatch/default.nix

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 30, 2021
@skogsbrus
Copy link

@jtojnar Do you know if it should be possible to get this published on nixpkgs if we get a derivation based on the python server working?

@jtojnar
Copy link
Member

jtojnar commented Oct 11, 2021

@skogsbrus It might even be possible to package the Rust server using the RUSTC_BOOTSTRAP = 1 hack. Another concern is the webui, which will require replacing npmlock2nix by something to avoid IFD, which is not allowed in Nixpkgs either.

@skogsbrus
Copy link

skogsbrus commented Nov 1, 2021

Made some progress tonight on this with the python server. I can install all modules and run aw-qt. The flask server responds to requests from the chrome extension, but I get 404s 🤔 Probably some paths that aren't included in the install somehow

Current state: https://github.com/skogsbrus/os/pull/6/files

As for the web ui, I don't think we need to include it? AFAIK it's just the code for the web extensions. The official releases don't even include it.

Copied most of the modules from yours @jtojnar, so really thanks for your work! 🙏

Edit: So I think the 404s are due to me not packaging aw-webui... Guess we'll need it after all. Seems to be included in the official releases under the aw-server* components

@skogsbrus
Copy link

Status update:

Tried adding aw-webui with mkYarnPackage, but have gotten stock on this obscure error (PR above has been updated):

johanan@voidm ~/os/home/pkgs/activitywatch nix-build
these 3 derivations will be built:
  /nix/store/ryj0li9bzcz6ap2k1cl4b2zskv80fbam-aw-webui.drv
  /nix/store/f066h4rcl9jc3xlliw3iqaqk8insgg0x-aw-server-johanan-beta1.drv
  /nix/store/4w12q82p7gfcy4pa06ga3mb27bllmlxf-activitywatch-johanan-beta1.drv
building '/nix/store/ryj0li9bzcz6ap2k1cl4b2zskv80fbam-aw-webui.drv'...
unpacking sources
unpacking source archive /nix/store/a6fjf7fl63qqk7bwssfk8agr50sw09j5-source/aw-server/aw-webui/.
source root is ./
patching sources
configuring
mv: cannot copy a directory, '/build', into itself, '/build/temp'
error: builder for '/nix/store/ryj0li9bzcz6ap2k1cl4b2zskv80fbam-aw-webui.drv' failed with exit code 1;
       last 6 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/a6fjf7fl63qqk7bwssfk8agr50sw09j5-source/aw-server/aw-webui/.
       > source root is ./
       > patching sources
       > configuring
       > mv: cannot copy a directory, '/build', into itself, '/build/temp'
       For full logs, run 'nix log /nix/store/ryj0li9bzcz6ap2k1cl4b2zskv80fbam-aw-webui.drv'.
error: 1 dependencies of derivation '/nix/store/4w12q82p7gfcy4pa06ga3mb27bllmlxf-activitywatch-johanan-beta1.drv' failed to build
johanan@voidm ~/os/home/pkgs/activitywatch

I barely know what I'm doing here so this will take quite a few iterations... :)

@skogsbrus
Copy link

@meain helped me solve the above issue. Now I'm just trying to get the static folder that is built by aw-webui to be installed in the same folder as the aw_server site package, since it's looking for a static folder in the same path as server.py.

@skogsbrus
Copy link

skogsbrus commented May 21, 2022

So, lots of time has past but I've got a local derivation working now. Haven't had the time to look into how to create a service that can be uploaded to nixpkgs, but this works locally with (pkgs.callPackage ./activitywatch {}) (assuming the zip contents exist in ./activitywatch.

Hopefully this is enough for anyone Nix-knowledgeable to package this into something sensible? Otherwise I might be able to do it in a few more months... :)

aw.zip:

  • default.nix
  • yarn.lock
  • yarn.nix

Note: Unlike @jtojnar's derivation, this uses the python server. Uses yarn2nix though - not sure how well that plays with "which will require replacing npmlock2nix by something to avoid IFD".

@voobscout
Copy link
Contributor Author

@skogsbrus Thank you for the derivation, perhaps you could use it like this:

{
  home-manager.sharedModules = [
    ({ config, lib, pkgs, ... }:
      with lib;
      let
        cfg = config.programs.activitywatch;
      in
      {
        options.programs.activitywatch = with types; {
          enable = mkEnableOption "Enable activitywatch";
          package = mkOption { type = package; default = pkgs.activitywatch; };
        };

        config = mkMerge [
          (mkIf cfg.enable {
            systemd.user.services.activitywatch = {
              Unit.Description = "activitywatch tray-icon";
              Service.ExecStart = (pkgs.writeShellScript "activitywatch-start" ''
                export PATH=$PATH:${makeBinPath [cfg.package]}
                aw-qt
              '').outPath;
              Service.Restart = "on-failure";
              Install.WantedBy = [ "graphical-session.target" ];
            };
          })
        ];
      }
    )
  ];
}

@skogsbrus
Copy link

@voobscout nice, I'll try it out. Would that then be a separate MR to the home-manager repo?

@skogsbrus
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants