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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ananicy-cpp: support wrapped applications #319634

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

diniamo
Copy link
Contributor

@diniamo diniamo commented Jun 13, 2024

Description of changes

Ananicy-cpp now matches wrapped applications with this patch.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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
  • Fits CONTRIBUTING.md.

Add a 馃憤 reaction to pull requests you find important.

@diniamo
Copy link
Contributor Author

diniamo commented Jun 13, 2024

I can't find how to request reviews so: @JohnRTitor @Artturin

Comment on lines 19 to 12
+ if (utils::regex::is_str_matching_regex(name, "^\\..+-wrap(p(ed?)?)?$"))
+ name = name.substr(1, name.find_last_of('-') - 1);
Copy link
Member

Choose a reason for hiding this comment

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

So it matches -wrapped and then removes the -wrapped right?

What's up with the (p(ed?)?)?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, sometimes process names don't fully have "-wrapped" suffix in their name, due to size limitations.

Copy link
Contributor Author

@diniamo diniamo Jun 14, 2024

Choose a reason for hiding this comment

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

It matches

.x-wrap
.x-wrapp
.x-wrappe
.x-wrapped

and removes everything after the last - (the - included).

I choose that regex because I have all of those on my system, and I doubt there are any other patterns

Copy link
Contributor

Choose a reason for hiding this comment

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

Not all process names end like that, as you can see.

https://github.com/CachyOS/ananicy-rules/blob/e3638ebb2320202ede9facfc9657cc8af2098a2d/00-default/Services/gvfs.rules

image

I had to manually add these rules to match .x- .x-w, .x-wra and so on.

All wrapped app's processes have . in the beginning.
I think the rules should run on any process x and \.x.* (regex)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JohnRTitor are you sure that screenshots includes the full process names?

Copy link
Contributor Author

@diniamo diniamo Jun 16, 2024

Choose a reason for hiding this comment

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

Looks like they are, in which case I'll try to come up with a better way of stripping the extra characters. I'm not sure how yet, so ideas are welcome.

Copy link
Contributor Author

@diniamo diniamo Jun 16, 2024

Choose a reason for hiding this comment

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

Never mind, it looks like ps is doing something funky. If you check the nixpkgs makeWrapper implementation, you can see that wrapers always start with a . and end with -wrapped. You can also confirm this by check the store paths for programs, eg.: ls -a $(dirname $(realpath $(which firefox))). And fortunately the process names in ananicy-cpp are also correct, which I confirmed by logging:

tmp ElXKWq8NkR

(The right side is ps, the left side is a log line from ananicy-cpp)

@diniamo diniamo force-pushed the ananicy-cpp-patch-for-wrappers branch from c1077a8 to d45e0f1 Compare June 14, 2024 06:07
@ofborg ofborg bot requested a review from Artturin June 14, 2024 06:36
@diniamo diniamo force-pushed the ananicy-cpp-patch-for-wrappers branch from d45e0f1 to 3565fd8 Compare June 16, 2024 13:27
@diniamo
Copy link
Contributor Author

diniamo commented Jun 18, 2024

@JohnRTitor @Artturin could we finish this up?

@VeilSilence
Copy link

Is there anything need to do to merge this?

@JohnRTitor
Copy link
Contributor

@JohnRTitor @Artturin could we finish this up?

Looks good, let me do a quick check before I approve.

Comment on lines +11 to +13
+ if (name.starts_with('.') && name.ends_with("-wrapped"))
+ name = name.substr(1, name.find_last_of('-') - 1);
+ const auto &rule = rules->get_rule(name);
Copy link
Member

Choose a reason for hiding this comment

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

Does the . have to be removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think . at the beginning should be removed, because the rules don't necessarily conform to .process-wrapped but rather process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does. Both the . and the -wrapped are appended by the wrapper script, so we want the part between them for matching.

Copy link
Member

Choose a reason for hiding this comment

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

I meant is the . being removed, I guess the (1 is doing that? Not familiar with cpp

@JohnRTitor
Copy link
Contributor

JohnRTitor commented Jun 19, 2024

By the way, is there a reason we are not using ananicy-cpp as the default in services.ananicy?

package = mkPackageOption pkgs "ananicy" {

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

LGTM based on my testing, approved

@diniamo
Copy link
Contributor Author

diniamo commented Jun 19, 2024

By the way, is there a reason we are not using ananicy-cpp as the default in services.ananicy?

package = mkPackageOption pkgs "ananicy" {

Good point, open a pr for it I think

@JohnRTitor JohnRTitor requested a review from Artturin June 19, 2024 17:09
@Artturin Artturin merged commit 65b6bae into NixOS:master Jun 20, 2024
26 checks passed
@diniamo
Copy link
Contributor Author

diniamo commented Jun 20, 2024

@JohnRTitor can you make a pr to remove all the now reduant rules in the cachyos rules repo?

@JohnRTitor
Copy link
Contributor

I think those can stay, for those using just ananicy (non cpp) and who are not on the version with the patch.

Future rules to the repo, won't need to account for wrapped processes.

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.

None yet

5 participants