Skip to content

taskwarrior: make .taskrc writable (attempt nr. 2)#2761

Merged
berbiche merged 3 commits intonix-community:masterfrom
x10an14:make_taskrc_writable
Apr 7, 2022
Merged

taskwarrior: make .taskrc writable (attempt nr. 2)#2761
berbiche merged 3 commits intonix-community:masterfrom
x10an14:make_taskrc_writable

Conversation

@x10an14
Copy link
Copy Markdown
Contributor

@x10an14 x10an14 commented Feb 25, 2022

This is an updated duplicate of #2697, where I attempted to fix/add tests too.

Description

  1. Make the default $HOME/.config/taskrcwriteable for users, so as to e.g. allow task context commands.
  2. Update tests to check for this.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

    • Added myself and the module files to .github/CODEOWNERS.

@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Feb 25, 2022

Made this as draft, since I can't get the formatter or tests to work =/ Not sure how to proceed (as in what I need to read/understand to make the tests/formatter work).

[2022-02-25 19:19:39] 0 x10an14@home-desktop:~/github/home-manager
-> $ git status
On branch make_taskrc_writable
Your branch is up to date with 'fork/make_taskrc_writable'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    flake.lock

no changes added to commit (use "git add" and/or "git commit -a")
[2022-02-25 19:19:41] 0 x10an14@home-desktop:~/github/home-manager
-> $ git rev-parse HEAD
b4ed73ea51cf6e218decc505431364115bfaf992
[2022-02-25 19:19:47] 0 x10an14@home-desktop:~/github/home-manager
-> $ ./format
error: cannot get archive member name: Damaged tar archive
[2022-02-25 19:19:54] 1 x10an14@home-desktop:~/github/home-manager
-> $ nix-shell --pure tests -A run.taskwarrior
taskwarrior: FAILED
Expected home-files/.config/task/taskrc to exist but it was not found.
For further reference please introspect /nix/store/jkf6vp25rxw3a00z3fqyf46lfl2p8sij-nmt-report-taskwarrior
[2022-02-25 19:20:00] 1 x10an14@home-desktop:~/github/home-manager
-> $

@x10an14 x10an14 mentioned this pull request Feb 25, 2022
7 tasks
@x10an14 x10an14 marked this pull request as ready for review February 25, 2022 19:25
@x10an14 x10an14 requested a review from rycee as a code owner February 25, 2022 19:25
@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Feb 25, 2022

Un-doing the draft status so as to let tests run...

Copy link
Copy Markdown
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

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

Thanks for continuing the previous efforts!

The script needs to be fixed because of how the shell parses redirection operators > and other symbols.

Comment thread modules/programs/taskwarrior.nix Outdated
@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Feb 27, 2022

Thanks to @berbiche's edit suggestion, ./format now works! And no diffs =)

The tests still don't run though, and with the same error =/

@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Feb 27, 2022

I can also report that the documentation's recommended home-manager -I home-manager=$HOME/<path to local hm clone with this pr branch checked out> switch didn't produce the desired changes. (See below copy/paste).

Anyone got any tips for what I'm missing/need to understand/write?

[2022-02-27 15:11:49] 0 x10an14@home-desktop:~/github/home-manager
-> $ home-manager -I home-manager=$HOME/github/home-manager switch
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /home/x10an14
No change so reusing latest profile generation 159
Creating home file links in /home/x10an14
Activating onFilesChange
Activating reloadSystemd
[2022-02-27 15:12:13] 0 x10an14@home-desktop:~/github/home-manager
-> $ la ~/.config/task/taskrc
4,0K lrwxrwxrwx 1 x10an14 x10an14 82 feb.  27 15:11 /home/x10an14/.config/task/taskrc -> /nix/store/kygzfc90wrz3i21dspiia2iq1nrdbmy8-home-manager-files/.config/task/taskrc
[2022-02-27 15:12:29] 0 x10an14@home-desktop:~/github/home-manager
-> $ grep -Hn include ~/.config/task/taskrc
/home/x10an14/.config/task/taskrc:2:include dark-gray-blue-256.theme
[2022-02-27 15:12:40] 0 x10an14@home-desktop:~/github/home-manager
-> $

@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Mar 11, 2022

I have spent quite some time (fruitlessly) looking at previous "editable" issues and the official documentation, and I'm no closer to understanding what to read/learn so as to figure out the next step for this PR.

This is my current state [1]
[2022-03-11 22:44:41] 0 x10an14@home-desktop:~/github/home-manager
-> $ nix-shell --pure tests -A run.taskwarrior
building '/nix/store/ala2k6kx7kdd756rm3g65v2zfwi1b4qf-activation-script.drv'...
building '/nix/store/8scgw7082ssqw4y7z6cyf2lbv234dbsa-home-manager-generation.drv'...
building '/nix/store/pwcbzpxr9qqlc8qizs2mx3m8pc653m4v-nmt-report-taskwarrior.drv'...
taskwarrior: FAILED
Expected home-files/.config/task/taskrc to exist but it was not found.
For further reference please introspect /nix/store/yh4m8mcdpcjqfwanjkaj97s96fcvnbw7-nmt-report-taskwarrior
[2022-03-11 22:44:45] 1 x10an14@home-desktop:~/github/home-manager
-> $ la /nix/store/yh4m8mcdpcjqfwanjkaj97s96fcvnbw7-nmt-report-taskwarrior/tested/home-files/.config/task/
total 4,0K
   0 dr-xr-xr-x 1 root root 14 mars  11 20:26 ./
   0 dr-xr-xr-x 1 root root 34 mars  11 20:26 ../
4,0K lrwxrwxrwx 2 root root 58 mars  11 20:26 taskrc_ -> /nix/store/22yrr3cssi47a0g3xc5cv8x9j3bhs2wr-hm_tasktaskrc_
[2022-03-11 22:45:20] 0 x10an14@home-desktop:~/github/home-manager
-> $

1: No change wrt. this either.

Copy link
Copy Markdown
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

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

Sorry, I have been busy.

I left a comment that should hopefully fix the issue.

Comment thread modules/programs/taskwarrior.nix Outdated
@x10an14 x10an14 force-pushed the make_taskrc_writable branch 3 times, most recently from 4916021 to 57ad817 Compare March 18, 2022 20:09
Copy link
Copy Markdown
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

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

Left additional comments.
I think this PR will be good to merge after these last fixes.

Comment thread modules/programs/taskwarrior.nix Outdated
Comment thread modules/programs/taskwarrior.nix Outdated
Comment thread modules/programs/taskwarrior.nix Outdated
Comment thread tests/modules/programs/taskwarrior/taskwarrior.nix Outdated
Comment thread tests/modules/programs/taskwarrior/taskwarrior.nix Outdated
@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Mar 18, 2022

@berbiche: Sorry, I have been busy.

No worries, completely understandable =) Thanks for all your time and efforts spent on this so far!

Just before your latest proposed changes/comments (good ones too, thanks!), I think I got it to work (locally) for me on my computer/setup!
I might sneak in a commit in this PR telling others how to test local repo changes when they're using flakes.

Yell at me once it's visible if you want it moved out of this PR =)


@berbiche: I left a comment that should hopefully fix the issue.

Unfortunately, it's still not passing the tests =/
I am starting to suspect the test harness is not equipped as-is to check for the existence of the include line in a file that HM "doesn't own"...

I extracted the HM activation script from the latest commit, and below are the relevant lines generated in the "resulting" /nix/store/idjxxd8v29wj1ca3mvm3p3rvvvr9xpvh-activation-script:

Relevant lines
#!/nix/store/2kh3c4v2vf6d6xg6c9n8zvfpwf3zzwca-bash-5.1-p12/bin/bash
set -eu
set -o pipefail

cd $HOME

export PATH="/nix/store/2kh3c4v2vf6d6xg6c9n8zvfpwf3zzwca-bash-5.1-p12/bin:/nix/store/vizjhz04x6xl57x2vrpqa52j8q6rkjfh-coreutils-9.0/bin:/nix/store/wa9x5983qing9gifsaf0iln4fcjxssxs-diffutils-3.8/bin:/nix/store/y7iizrf51pgi8vjhiwndajz4ihwm416f-findutils-4.8.0/bin:/nix/store/dgfsb2gr8z7c7fncw7w8igqgskisksgf-gettext-0.21/bin:/nix/store/s6sb3m2312hjw78zg5gyjpky5w0z1cgw-gnugrep-3.7/bin:/nix/store/rg7bpxyqipjgxfc6q5h7p1yrnsgaypsk-gnused-4.8/bin:/nix/store/y332ks5b6xbihvhchs84lq36na9bf4rf-ncurses-6.3/bin${PATH:+:}$PATH"
export TEXTDOMAIN=hm-modules
export TEXTDOMAINDIR=/nix/store/7kj4cymd9jxzwjls0hs0dfbl7v8r6crm-hm-modules-messages
source /nix/store/xc42m2j2znv5n2px2fhy0phgraldhlbc-home-manager.sh


#!/usr/bin/env bash

# snip...

_iNote "Activating %s" "regenDotTaskRc"
$VERBOSE_ECHO "Ensuring generated taskwarrior config included in taskrc"

# Ensure file's existence
if [[ ! -s "/home/hm-user/.config/task/taskrc" ]]; then
  if [[ -v DRY_RUN ]]; then
    $DRY_RUN_CMD echo "include /home/hm-user/.config/task/home-manager-taskrc" ">" "/home/hm-user/.config/task/taskrc"
  else
    echo "include /home/hm-user/.config/task/home-manager-taskrc" > "/home/hm-user/.config/task/taskrc"
  fi
fi

# Add include statement for home-manager generated config
if ! /nix/store/s6sb3m2312hjw78zg5gyjpky5w0z1cgw-gnugrep-3.7/bin/grep -qF "include /home/hm-user/.config/task/home-manager-taskrc" /home/hm-user/.config/task/taskrc; then
  if [[ -v DRY_RUN ]]; then
    $DRY_RUN_CMD /nix/store/rg7bpxyqipjgxfc6q5h7p1yrnsgaypsk-gnused-4.8/bin/sed -i '1i include /home/hm-user/.config/task/home-manager-taskrc' /home/hm-user/.config/task/taskrc
  else
    /nix/store/rg7bpxyqipjgxfc6q5h7p1yrnsgaypsk-gnused-4.8/bin/sed -i '1i include /home/hm-user/.config/task/home-manager-taskrc' /home/hm-user/.config/task/taskrc
  fi
fi


_iNote "Activating %s" "reloadSystemd"

# snip...

It's specifically the lines referencing /home/hm-user/ that makes me wonder - I don't know how to confirm that they're actually executed, ref the error message the tests fail with...

[2022-03-19 00:20:44] 0 x10an14@home-desktop:~/github/home-manager
-> $ nix-shell --pure tests -A run.taskwarrior
taskwarrior: FAILED
Expected home-files/.config/task/taskrc to exist but it was not found.
For further reference please introspect /nix/store/pxfb2jzz91mpy2z7yxkza7sys2g47x08-nmt-report-taskwarrior
[2022-03-19 00:20:50] 1 x10an14@home-desktop:~/github/home-manager
-> $ git status
On branch make_taskrc_writable
Your branch is up to date with 'fork/make_taskrc_writable'.

nothing to commit, working tree clean
[2022-03-19 00:20:56] 0 x10an14@home-desktop:~/github/home-manager
-> $ git rev-parse HEAD
e90a44fe9a12be7444b9d755065dcd0bd670dc5b
[2022-03-19 00:21:00] 0 x10an14@home-desktop:~/github/home-manager
-> $

EDIT: Clarify/improve readability

@berbiche
Copy link
Copy Markdown
Member

@x10an14 hi, if you could try the module on your machine it would be nice!

The standard test environment does not test activation scripts so the last part of the test had to be dropped.

@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Mar 21, 2022

@berbiche: The standard test environment does not test activation scripts so the last part of the test had to be dropped.

Ahh, okay! Thanks for confirming that for me, I've been stuck on that for almost a month now x)


@berbiche: @x10an14 hi, if you could try the module on your machine it would be nice!

Can confirm, with latest squashed&force-pushed commit, it works on my machine =)

@sumnerevans sumnerevans requested a review from berbiche March 21, 2022 23:07
Comment thread modules/programs/taskwarrior.nix Outdated
This is achieved by generating the Home Manager configuration
file as `~/.config/task/home-manager-taskrc`, and including that
file into ~/.config/task/taskrc.

Fixes nix-community#2360

Co-authored-by: Nicolas Berbiche <nic.berbiche@gmail.com>
Co-authored-by: @x10an14 <x10an14@users.noreply.github.com>
@x10an14 x10an14 force-pushed the make_taskrc_writable branch from 5c59b02 to 0f1c437 Compare March 23, 2022 16:35
@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Mar 23, 2022

Rebased on top of master

@x10an14
Copy link
Copy Markdown
Contributor Author

x10an14 commented Mar 24, 2022

In my opinion / understanding (both of which might be lacking) I believe this PR is "complete" as in ready to merge.

Starting to feel a little burnt out on this, so I hope someone else can pick this up now if there's more that should be done.
Thanks a ton to @berbiche for helping me out so much on this, and @mainrs for starting these efforts.

I might have some more capacity in me, but I'm a little fed up with the steep learnong-curve/reverse engineering required for someone with my (in)competence level. If someone wants to ask more of me here, hope its okay to request unambiguous instructions&rationale (and maybe also shorter feedback loop - if possible).

@berbiche
Copy link
Copy Markdown
Member

berbiche commented Apr 7, 2022

Hi again,
I was busy the past two weeks.

Thanks again for your efforts 😃.
I will push to your branch and finish the remaining work if any!

@berbiche berbiche merged commit e361373 into nix-community:master Apr 7, 2022
@x10an14 x10an14 deleted the make_taskrc_writable branch April 7, 2022 22:13
@teto teto mentioned this pull request Aug 22, 2022
7 tasks
teto pushed a commit to teto/home-manager that referenced this pull request Aug 22, 2022
This is achieved by generating the Home Manager configuration
file as `~/.config/task/home-manager-taskrc`, and including that
file into ~/.config/task/taskrc.

Fixes nix-community#2360

Co-authored-by: mainrs <5113257+mainrs@users.noreply.github.com>
Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
spacekookie pushed a commit to spacekookie/home-manager that referenced this pull request Feb 10, 2023
This is achieved by generating the Home Manager configuration
file as `~/.config/task/home-manager-taskrc`, and including that
file into ~/.config/task/taskrc.

Fixes nix-community#2360

Co-authored-by: mainrs <5113257+mainrs@users.noreply.github.com>
Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants