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

auto-epp: init at 1.2.1 #261378

Merged
merged 3 commits into from
Nov 30, 2023
Merged

auto-epp: init at 1.2.1 #261378

merged 3 commits into from
Nov 30, 2023

Conversation

lamarios
Copy link
Contributor

@lamarios lamarios commented Oct 16, 2023

nixos/services/hardware/auto-epp-go: init

module to set up auto-epp-go with its kernel parameter, systemd service and config file

Description of changes

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/)
  • 23.11 Release Notes (or backporting 23.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.

Copy link
Member

@h7x4 h7x4 left a comment

Choose a reason for hiding this comment

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

You'll have to split up your changes into three commits:

maintainers: add lamarios
auto-epp: init at 1.2.1
nixos/auto-epp: init

I'm not entirely convinced that the packaging is correct, but I'll leave that to other reviewers who might know better than me.

let

cfg = config.services.auto-epp;
package = pkgs.auto-epp;
Copy link
Member

Choose a reason for hiding this comment

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

Consider making this an mkPackageOption

nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Show resolved Hide resolved

systemd.services.auto-epp = {
enable = true;
after = [ "network.target" "network-online.target" ];
Copy link
Member

Choose a reason for hiding this comment

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

Does this service really need networking in order to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most likely not, i was following upstream. Will change accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

Cool. Maybe we should notify upstream

description = "auto-epp - Automatic EPP Changer for amd-pstate-epp";
serviceConfig = {
Type = "simple";
User = "root";
Copy link
Member

Choose a reason for hiding this comment

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

Does this service need to run as root? Maybe we could make it DynamicUser and give it the permissions it needs through CapabilityBoundingSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll need to research on this as i have no idea on how those work.

Copy link
Contributor Author

@lamarios lamarios Oct 17, 2023

Choose a reason for hiding this comment

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

After some check, it requires to run as root, logs from journalctl:

Oct 17 12:02:01 yoga7 auto-epp[53340]: auto-epp must be run with root privileges.

see upstream

pkgs/tools/system/auto-epp/default.nix Outdated Show resolved Hide resolved
pkgs/tools/system/auto-epp/default.nix Outdated Show resolved Hide resolved
pkgs/tools/system/auto-epp/default.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
@@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:
with lib;
Copy link
Member

Choose a reason for hiding this comment

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

There are ongoing efforts to avoid with lib; statements. I won't block the PR on this, but would you mind changing it out for an inherit (lib) ...; for the most commonly used items, and just prepending lib. to everything that's only used once or twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, all addressed except commit splitting, let's see if it's good to go first then i'll split

@lamarios lamarios force-pushed the auto-epp branch 6 times, most recently from fff1c60 to de72325 Compare October 18, 2023 08:52
Copy link
Member

@h7x4 h7x4 left a comment

Choose a reason for hiding this comment

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

Okay, just a few more comments

nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
'';

meta = with lib; {
mainProgram = pname;
Copy link
Member

Choose a reason for hiding this comment

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

nit: while i understand the intent here, it's semantically wrong. The executable doesn't necessarily have the same name as the package - it just happens to be the case here (and for many other packages as well).

Copy link
Contributor Author

@lamarios lamarios Oct 20, 2023

Choose a reason for hiding this comment

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

sure, i'll create a variable for it

@@ -0,0 +1,31 @@
{ lib, stdenv, fetchFromGitHub, python3 }:
Copy link
Member

Choose a reason for hiding this comment

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

Would you be willing to move your package to the new by-name set by the way? AFAIK it's not obligatory just yet, but many new packages are shifting towards using this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, any docs or example i can read ?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if i understand properly, i just need to move my default.nix file to pkgs/by-name/au/auto-epp/package.nix and remove it from the top-level/all-packages.nix ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, done

nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
systemd.packages = [ cfg.package ];

systemd.services.auto-epp = lib.mkIf cfg.enable {
enable = true;
Copy link
Member

Choose a reason for hiding this comment

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

@h7x4
Copy link
Member

h7x4 commented Oct 20, 2023

This is looking pretty good. You'll have to rebase your commits into

maintainers: add lamarios
auto-epp: init at 1.2.1
nixos/auto-epp: init

But apart from that, this is ready to merge as far as I'm concerned

@lamarios lamarios force-pushed the auto-epp branch 2 times, most recently from 0afbf62 to eeb99ca Compare October 21, 2023 07:56
@lamarios
Copy link
Contributor Author

@h7x4 all done ! Thanks for the review

Settings = {
epp_state_for_AC = mkOption {
type = types.str;
default = "balance_performance";
Copy link
Contributor Author

@lamarios lamarios Oct 26, 2023

Choose a reason for hiding this comment

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

@h7x4, I had to make changes, i realized i inverted the defaults for battery and ac modes... This was power before.


epp_state_for_BAT = mkOption {
type = types.str;
default = "power";
Copy link
Contributor Author

@lamarios lamarios Oct 26, 2023

Choose a reason for hiding this comment

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

@h7x4, I had to make changes, i realized i inverted the defaults for battery and ac modes... This was balance_performance before

Copy link
Member

@h7x4 h7x4 left a comment

Choose a reason for hiding this comment

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

Some final comments

pkgs/by-name/au/auto-epp/package.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
@lamarios
Copy link
Contributor Author

Some final comments

all done, thanks

Copy link
Contributor

@pbsds pbsds left a comment

Choose a reason for hiding this comment

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

Result of nixpkgs-review pr 261378 run on x86_64-linux 1

2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
1 package built:
  • auto-epp

I also built the manual with nix build github:nixos/nixpkgs/refs/pull/261378/head#htmlDocs.nixosManual.
Couple of nits, yet to test building the module.

nixos/modules/services/hardware/auto-epp.nix Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
pkgs/by-name/au/auto-epp/package.nix Outdated Show resolved Hide resolved
nixos/modules/services/hardware/auto-epp.nix Outdated Show resolved Hide resolved
@lamarios
Copy link
Contributor Author

Result of nixpkgs-review pr 261378 run on x86_64-linux 1
2 packages blacklisted:

* nixos-install-tools

* tests.nixos-functions.nixos-test

1 package built:

* auto-epp

I also built the manual with nix build github:nixos/nixpkgs/refs/pull/261378/head#htmlDocs.nixosManual. Couple of nits, yet to test building the module.

After committing the suggestions, there's an issue with build manual:

    3| let
       >             4|   cfg = config.services.auto-epp;
       >              |         ^
       >             5|   format = pkgs.formats.ini {};
       > Cacheable portion of option doc build failed.
       > Usually this means that an option attribute that ends up in documentation (eg `default` or `description`) depends on the restricted module arguments `config` or `pkgs`.

Looks like we can't use config.xxx in the docs. Should we hardcode the url to point to the github repo instead ?

@h7x4
Copy link
Member

h7x4 commented Nov 28, 2023

Should we hardcode the url to point to the github repo instead ?

Yes, I think that would be good. Most module docs point to the projects main branch, so maybe https://github.com/jothi-prasath/auto-epp/blob/master/sample-auto-epp.conf?

@lamarios
Copy link
Contributor Author

Should we hardcode the url to point to the github repo instead ?

Yes, I think that would be good. Most module docs point to the projects main branch, so maybe https://github.com/jothi-prasath/auto-epp/blob/master/sample-auto-epp.conf?

done

@pbsds pbsds merged commit 23fb8f6 into NixOS:master Nov 30, 2023
24 checks passed
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

4 participants