Skip to content

Conversation

@devnoname120
Copy link
Contributor

@devnoname120 devnoname120 commented Nov 16, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

Summary

This PR adds support for the nice option in Homebrew services, allowing users to set the scheduling priority (nice level) for services on both macOS and Linux.

This PR is a follow to #14936
It aims to fix half of #14931

Changes

  • Added nice method to Service class with validation (accepts integers from -20 to 19)
  • Added Nice support to to_plist method for macOS launchd plist generation
  • Added Nice support to to_systemd_unit method for Linux systemd unit generation
  • Added nice to to_hash and from_hash methods for API serialization
  • Added comprehensive tests covering:
    • Valid nice values (including zero)
    • Values outside valid range
    • requires_root is set when negative nice values are specified (negative nice values require root privileges)
    • Verification that nice appears in generated plist and systemd unit files
  • Updated documentation in Formula-Cookbook.md

Motivation

Previously, Homebrew services supported Apple plist daemons which had Nice support, but with the switch to their own syntax it became impossible to define a nice value. This PR restores that functionality and extends it to work with both macOS (launchd) and Linux (systemd) service managers.

The nice level ranges from -20 (highest priority) to 19 (lowest priority), and an error is raised if negative nice values are used but requires_root is missing.

- Add nice method to Service class with validation (-20 to 19)
- Automatically set requires_root for negative nice values
- Add Nice support to plist (macOS) and systemd unit (Linux) generation
- Add nice to to_hash and from_hash for API serialization
- Add comprehensive tests for nice functionality
- Update documentation with nice option
Copilot AI review requested due to automatic review settings November 16, 2025 01:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the nice option to Homebrew services, allowing users to control the scheduling priority of services on both macOS and Linux. The nice level ranges from -20 (highest priority) to 19 (lowest priority).

Key changes:

  • Added nice method with validation and automatic requires_root handling for negative values
  • Extended plist and systemd unit generation to include nice values
  • Added comprehensive test coverage for all nice-related functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/Formula-Cookbook.md Documented the new nice option in the service configuration table
Library/Homebrew/service.rb Implemented the nice method with validation, added nice support to plist/systemd generation, and integrated it with API serialization
Library/Homebrew/test/service_spec.rb Added comprehensive test coverage for nice value validation, requires_root behavior, and output generation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 16, 2025 01:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks, looks great so far, a few small tweaks!

Copilot AI review requested due to automatic review settings November 16, 2025 22:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 16, 2025 22:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 16, 2025 23:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 16, 2025 23:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks, great work here @devnoname120, you rock!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 18, 2025
Merged via the queue into Homebrew:main with commit 3816cee Nov 18, 2025
42 checks passed
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