diff options
| author | Herman Rimm <herman@rimm.ee> | 2026-07-16 17:17:09 +0200 |
|---|---|---|
| committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2026-07-28 18:32:32 +0200 |
| commit | 90a0b71c0c3a9cbbeb850dac991b0e48c38337f0 (patch) | |
| tree | a8474bff666443d493f84733d16fe4c86e8023c7 | |
| parent | 19b655562009fa9e5cf259836d8a3789f6d67073 (diff) | |
services: elogind: Fix runtime-directory-size field.
Both runtime-directory-size and runtime-directory-size-percent field currently
cause an error if set. A comment above the latter already calls for its
deprecation. This patch combines both into a single field and fixes
their serialization.
* gnu/services/desktop.scm (percent?, percent, elogind-serialize-percent):
Replace with…
(non-negative-integer-and-suffix?, non-negative-integer-and-suffix)
(elogind-serialize-non-negative-integer-and-suffix): … these.
(elogind-configuration)[runtime-directory-size-percent]: Remove field,
integrating logic into …
[runtime-directory-size]: … here. Serialize it.
* doc/guix.texi (Desktop Services): Adjust accordingly.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Merges: guix/guix#9987
| -rw-r--r-- | doc/guix.texi | 16 | ||||
| -rw-r--r-- | gnu/services/desktop.scm | 64 |
2 files changed, 34 insertions, 46 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index b34f0d1d3da..d2e8f2335a5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -27671,16 +27671,12 @@ Action to take when the system is idle. | |||
| 27671 | The delay after which the action configured in @code{idle-action} is | 27671 | The delay after which the action configured in @code{idle-action} is |
| 27672 | taken after the system is idle. | 27672 | taken after the system is idle. |
| 27673 | 27673 | ||
| 27674 | @item @code{runtime-directory-size-percent} (type: maybe-percent) | 27674 | @item @code{runtime-directory-size} (default: @code{'(10 . %)}) (type: maybe-non-negative-integer-and-suffix) |
| 27675 | Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime | 27675 | Set the size limit on the @env{XDG_RUNTIME_DIR} runtime directory for |
| 27676 | directory for each user who logs in. This specifies the per-user size | 27676 | each user who logs in. The size in bytes can be given as an integer and |
| 27677 | limit relative to the amount of physical @acronym{RAM,read access | 27677 | paired with symbols: K, M, G, or T. When paired with @code{'%}, the |
| 27678 | memory}. This value takes precedence over that specified via | 27678 | integer represents the limit as a percentage share of the total amount |
| 27679 | @code{runtime-directory-size}. | 27679 | of physical @acronym{RAM, read access memory}. |
| 27680 | |||
| 27681 | @item @code{runtime-directory-size} (type: maybe-non-negative-integer) | ||
| 27682 | Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime | ||
| 27683 | directory for each user who logs in. | ||
| 27684 | 27680 | ||
| 27685 | @item @code{remove-ipc?} (default: @code{#t}) (type: maybe-boolean) | 27681 | @item @code{remove-ipc?} (default: @code{#t}) (type: maybe-boolean) |
| 27686 | Whether @acronym{IPC,inter-process communication} objects belonging to | 27682 | Whether @acronym{IPC,inter-process communication} objects belonging to |
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index d0f56cc434c..5b6c10b0e72 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | ;;; Copyright © 2025 Sergio Pastor Pérez <sergio.pastorperez@gmail.com> | 23 | ;;; Copyright © 2025 Sergio Pastor Pérez <sergio.pastorperez@gmail.com> |
| 24 | ;;; Copyright © 2025 dan <i@dan.games> | 24 | ;;; Copyright © 2025 dan <i@dan.games> |
| 25 | ;;; Copyright © 2026 Noé Lopez <noelopez@free.fr> | 25 | ;;; Copyright © 2026 Noé Lopez <noelopez@free.fr> |
| 26 | ;;; Copyright © 2026 Herman Rimm <herman@rimm.ee> | ||
| 26 | ;;; | 27 | ;;; |
| 27 | ;;; This file is part of GNU Guix. | 28 | ;;; This file is part of GNU Guix. |
| 28 | ;;; | 29 | ;;; |
| @@ -1286,12 +1287,16 @@ and many other) available for GIO applications.") | |||
| 1286 | (define-maybe non-negative-integer | 1287 | (define-maybe non-negative-integer |
| 1287 | (prefix elogind-)) | 1288 | (prefix elogind-)) |
| 1288 | 1289 | ||
| 1289 | (define (percent? x) | 1290 | (define (non-negative-integer-and-suffix? x) |
| 1290 | (and (non-negative-integer? x) | 1291 | (match-lambda |
| 1291 | (>= x 0) | 1292 | ((x . '%) |
| 1292 | (<= x 100))) | 1293 | (and (non-negative-integer? x) |
| 1293 | 1294 | (<= x 100))) | |
| 1294 | (define-maybe percent | 1295 | (((? non-negative-integer?) . suffix) |
| 1296 | (member suffix '(K M G T))) | ||
| 1297 | (x (non-negative-integer? x)))) | ||
| 1298 | |||
| 1299 | (define-maybe non-negative-integer-and-suffix | ||
| 1295 | (prefix elogind-)) | 1300 | (prefix elogind-)) |
| 1296 | 1301 | ||
| 1297 | (define char-set:user-name | 1302 | (define char-set:user-name |
| @@ -1399,7 +1404,13 @@ and many other) available for GIO applications.") | |||
| 1399 | 1404 | ||
| 1400 | (define elogind-serialize-action elogind-base-serializer) | 1405 | (define elogind-serialize-action elogind-base-serializer) |
| 1401 | (define elogind-serialize-non-negative-integer elogind-base-serializer) | 1406 | (define elogind-serialize-non-negative-integer elogind-base-serializer) |
| 1402 | (define elogind-serialize-percent elogind-base-serializer) | 1407 | |
| 1408 | (define (elogind-serialize-non-negative-integer-and-suffix name value) | ||
| 1409 | (let ((name (elogind-name->string name))) | ||
| 1410 | (match value | ||
| 1411 | ((first . second) | ||
| 1412 | (format #f "~a=~a~a~%" name first second)) | ||
| 1413 | (_ (format #f "~a=~a~%" name value))))) | ||
| 1403 | 1414 | ||
| 1404 | (define (elogind-list-serializer name value) | 1415 | (define (elogind-list-serializer name value) |
| 1405 | (format #f "~a=~{~a~^ ~}~%" (elogind-name->string name) value)) | 1416 | (format #f "~a=~{~a~^ ~}~%" (elogind-name->string name) value)) |
| @@ -1541,21 +1552,13 @@ during which elogind will hold off on reacting to lid events.") | |||
| 1541 | "The delay after which the action configured in @code{idle-action} is | 1552 | "The delay after which the action configured in @code{idle-action} is |
| 1542 | taken after the system is idle.") | 1553 | taken after the system is idle.") |
| 1543 | 1554 | ||
| 1544 | ;; XXX: Perhaps deprecate in the future and handle all the accepted forms | ||
| 1545 | ;; directly in 'runtime-directory-size' instead. | ||
| 1546 | (runtime-directory-size-percent | ||
| 1547 | maybe-percent | ||
| 1548 | "Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime | ||
| 1549 | directory for each user who logs in. This specifies the per-user size limit | ||
| 1550 | relative to the amount of physical @acronym{RAM, read access memory}. This | ||
| 1551 | value takes precedence over that specified via @code{runtime-directory-size}." | ||
| 1552 | (serializer empty-serializer)) ;special cased at serialization time | ||
| 1553 | |||
| 1554 | (runtime-directory-size | 1555 | (runtime-directory-size |
| 1555 | maybe-non-negative-integer | 1556 | (maybe-non-negative-integer-and-suffix '(10 . %)) |
| 1556 | "Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime | 1557 | "Set the size limit on the @env{XDG_RUNTIME_DIR} runtime directory |
| 1557 | directory for each user who logs in." | 1558 | for each user who logs in. The size in bytes can be given as an integer |
| 1558 | (serializer empty-serializer)) ;special cased at serialization time | 1559 | and paired with symbols: K, M, G, or T. When paired with @code{'%}, the |
| 1560 | integer represents the limit as a percentage share of the total amount | ||
| 1561 | of physical @acronym{RAM, read access memory}.") | ||
| 1559 | 1562 | ||
| 1560 | (remove-ipc? | 1563 | (remove-ipc? |
| 1561 | (maybe-boolean #t) | 1564 | (maybe-boolean #t) |
| @@ -1620,21 +1623,10 @@ the user shall be removed when the user fully logs out.") | |||
| 1620 | (memq (configuration-field-name field) | 1623 | (memq (configuration-field-name field) |
| 1621 | %elogind-configuration-sleep-fields)) | 1624 | %elogind-configuration-sleep-fields)) |
| 1622 | elogind-configuration-fields))) | 1625 | elogind-configuration-fields))) |
| 1623 | (match-record config <elogind-configuration> | 1626 | (mixed-text-file |
| 1624 | (runtime-directory-size-percent runtime-directory-size) | 1627 | "logind.conf" |
| 1625 | ;; Handle the special-cased | 1628 | "[Login]\n" |
| 1626 | ;; runtime-directory-size-percent/runtime-directory-size options pair. | 1629 | (serialize-configuration config logind-fields)))) |
| 1627 | (let ((runtime-directory-size | ||
| 1628 | (if (maybe-value-set? runtime-directory-size-percent) | ||
| 1629 | (format #f "~a%~%" runtime-directory-size-percent) ;10 -> 10% | ||
| 1630 | runtime-directory-size))) | ||
| 1631 | (mixed-text-file | ||
| 1632 | "logind.conf" | ||
| 1633 | "[Login]\n" | ||
| 1634 | (if (maybe-value-set? runtime-directory-size) | ||
| 1635 | (list "RuntimeDirectorySize=" runtime-directory-size) | ||
| 1636 | "") | ||
| 1637 | (serialize-configuration config logind-fields)))))) | ||
| 1638 | 1630 | ||
| 1639 | (define (sleep.conf config) | 1631 | (define (sleep.conf config) |
| 1640 | (let ((sleep-fields (filter (lambda (field) | 1632 | (let ((sleep-fields (filter (lambda (field) |
