diff options
| author | Bruno Victal <mirai@makinata.eu> | 2023-01-27 21:06:12 +0000 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2023-02-09 01:07:47 +0100 |
| commit | 802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6 (patch) | |
| tree | 3adf9c824a6531b7ad74fc21bcba080772be7bc2 /gnu/system.scm | |
| parent | 22dd558c70901a336de97187f0470be584571158 (diff) | |
system: Deprecate hosts-file.
* gnu/system.scm (operating-system-hosts-file): Deprecate procedure.
(warn-hosts-file-field-deprecation): New procedure, helper for
deprecated variable.
(operating-system)[hosts-file]: Use helper to warn deprecated field.
(local-host-aliases): Mark as deprecated.
(local-host-entries): New procedure.
(operating-system-default-essential-services,
hurd-default-essential-services): Use hosts-service-type. Use
'%operating-system-hosts-file' and 'local-host-entries'.
(default-/etc/hosts): Remove procedure.
(operating-system-etc-service): Remove hosts file.
* doc/guix.texi (operating-system Reference)
(Networking Services) (Virtualization Services): Rewrite documentation
entries to use hosts-service-type.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/system.scm')
| -rw-r--r-- | gnu/system.scm | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/gnu/system.scm b/gnu/system.scm index d67f9a615bf..df60fda53bc 100644 --- a/gnu/system.scm +++ b/gnu/system.scm | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | ;;; Copyright © 2020, 2022 Efraim Flashner <efraim@flashner.co.il> | 14 | ;;; Copyright © 2020, 2022 Efraim Flashner <efraim@flashner.co.il> |
| 15 | ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> | 15 | ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> |
| 16 | ;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com> | 16 | ;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com> |
| 17 | ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> | ||
| 17 | ;;; | 18 | ;;; |
| 18 | ;;; This file is part of GNU Guix. | 19 | ;;; This file is part of GNU Guix. |
| 19 | ;;; | 20 | ;;; |
| @@ -97,7 +98,7 @@ | |||
| 97 | operating-system-user-services | 98 | operating-system-user-services |
| 98 | operating-system-packages | 99 | operating-system-packages |
| 99 | operating-system-host-name | 100 | operating-system-host-name |
| 100 | operating-system-hosts-file | 101 | operating-system-hosts-file ;deprecated |
| 101 | operating-system-hurd | 102 | operating-system-hurd |
| 102 | operating-system-kernel | 103 | operating-system-kernel |
| 103 | operating-system-kernel-file | 104 | operating-system-kernel-file |
| @@ -169,7 +170,8 @@ | |||
| 169 | read-boot-parameters-file | 170 | read-boot-parameters-file |
| 170 | boot-parameters->menu-entry | 171 | boot-parameters->menu-entry |
| 171 | 172 | ||
| 172 | local-host-aliases | 173 | local-host-aliases ;deprecated |
| 174 | local-host-entries | ||
| 173 | %root-account | 175 | %root-account |
| 174 | %setuid-programs | 176 | %setuid-programs |
| 175 | %sudoers-specification | 177 | %sudoers-specification |
| @@ -208,6 +210,15 @@ VERSION is the target version of the boot-parameters record." | |||
| 208 | #$system "/boot"))) | 210 | #$system "/boot"))) |
| 209 | 211 | ||
| 210 | ;; System-wide configuration. | 212 | ;; System-wide configuration. |
| 213 | |||
| 214 | (define-with-syntax-properties (warn-hosts-file-field-deprecation | ||
| 215 | (value properties)) | ||
| 216 | (when value | ||
| 217 | (warning (source-properties->location properties) | ||
| 218 | (G_ "the 'hosts-file' field is deprecated, please use \ | ||
| 219 | 'hosts-service-type' instead~%"))) | ||
| 220 | value) | ||
| 221 | |||
| 211 | ;; TODO: Add per-field docstrings/stexi. | 222 | ;; TODO: Add per-field docstrings/stexi. |
| 212 | (define-record-type* <operating-system> operating-system | 223 | (define-record-type* <operating-system> operating-system |
| 213 | make-operating-system | 224 | make-operating-system |
| @@ -239,8 +250,9 @@ VERSION is the target version of the boot-parameters record." | |||
| 239 | (default %base-firmware)) | 250 | (default %base-firmware)) |
| 240 | 251 | ||
| 241 | (host-name operating-system-host-name) ; string | 252 | (host-name operating-system-host-name) ; string |
| 242 | (hosts-file operating-system-hosts-file ; file-like | #f | 253 | (hosts-file %operating-system-hosts-file ; deprecated |
| 243 | (default #f)) | 254 | (default #f) |
| 255 | (sanitize warn-hosts-file-field-deprecation)) | ||
| 244 | 256 | ||
| 245 | (mapped-devices operating-system-mapped-devices ; list of <mapped-device> | 257 | (mapped-devices operating-system-mapped-devices ; list of <mapped-device> |
| 246 | (default '())) | 258 | (default '())) |
| @@ -296,6 +308,10 @@ VERSION is the target version of the boot-parameters record." | |||
| 296 | source-properties->location)) | 308 | source-properties->location)) |
| 297 | (innate))) | 309 | (innate))) |
| 298 | 310 | ||
| 311 | (define-deprecated (operating-system-hosts-file os) | ||
| 312 | hosts-service-type | ||
| 313 | (%operating-system-hosts-file os)) | ||
| 314 | |||
| 299 | (define* (operating-system-kernel-arguments | 315 | (define* (operating-system-kernel-arguments |
| 300 | os root-device #:key (version %boot-parameters-version)) | 316 | os root-device #:key (version %boot-parameters-version)) |
| 301 | "Return all the kernel arguments, including the ones not specified directly | 317 | "Return all the kernel arguments, including the ones not specified directly |
| @@ -733,7 +749,8 @@ bookkeeping." | |||
| 733 | (non-boot-fs (non-boot-file-system-service os)) | 749 | (non-boot-fs (non-boot-file-system-service os)) |
| 734 | (swaps (swap-services os)) | 750 | (swaps (swap-services os)) |
| 735 | (procs (service user-processes-service-type)) | 751 | (procs (service user-processes-service-type)) |
| 736 | (host-name (host-name-service (operating-system-host-name os))) | 752 | (host-name (operating-system-host-name os)) |
| 753 | (hosts-file (%operating-system-hosts-file os)) | ||
| 737 | (entries (operating-system-directory-base-entries os))) | 754 | (entries (operating-system-directory-base-entries os))) |
| 738 | (cons* (service system-service-type entries) | 755 | (cons* (service system-service-type entries) |
| 739 | (service linux-builder-service-type | 756 | (service linux-builder-service-type |
| @@ -755,12 +772,19 @@ bookkeeping." | |||
| 755 | (operating-system-groups os)) | 772 | (operating-system-groups os)) |
| 756 | (operating-system-skeletons os)) | 773 | (operating-system-skeletons os)) |
| 757 | (operating-system-etc-service os) | 774 | (operating-system-etc-service os) |
| 775 | ;; XXX: hosts-file is deprecated | ||
| 776 | (if hosts-file | ||
| 777 | (simple-service 'deprecated-hosts-file etc-service-type | ||
| 778 | (list `("hosts" ,hosts-file))) | ||
| 779 | (service hosts-service-type | ||
| 780 | (local-host-entries host-name))) | ||
| 758 | (service fstab-service-type | 781 | (service fstab-service-type |
| 759 | (filter file-system-needed-for-boot? | 782 | (filter file-system-needed-for-boot? |
| 760 | (operating-system-file-systems os))) | 783 | (operating-system-file-systems os))) |
| 761 | (session-environment-service | 784 | (session-environment-service |
| 762 | (operating-system-environment-variables os)) | 785 | (operating-system-environment-variables os)) |
| 763 | host-name procs root-fs | 786 | (host-name-service host-name) |
| 787 | procs root-fs | ||
| 764 | (service setuid-program-service-type | 788 | (service setuid-program-service-type |
| 765 | (operating-system-setuid-programs os)) | 789 | (operating-system-setuid-programs os)) |
| 766 | (service profile-service-type | 790 | (service profile-service-type |
| @@ -774,7 +798,9 @@ bookkeeping." | |||
| 774 | (operating-system-firmware os))))))) | 798 | (operating-system-firmware os))))))) |
| 775 | 799 | ||
| 776 | (define (hurd-default-essential-services os) | 800 | (define (hurd-default-essential-services os) |
| 777 | (let ((entries (operating-system-directory-base-entries os))) | 801 | (let ((host-name (operating-system-host-name os)) |
| 802 | (hosts-file (%operating-system-hosts-file os)) | ||
| 803 | (entries (operating-system-directory-base-entries os))) | ||
| 778 | (list (service system-service-type entries) | 804 | (list (service system-service-type entries) |
| 779 | %boot-service | 805 | %boot-service |
| 780 | %hurd-startup-service | 806 | %hurd-startup-service |
| @@ -794,6 +820,12 @@ bookkeeping." | |||
| 794 | (operating-system-file-systems os))) | 820 | (operating-system-file-systems os))) |
| 795 | (pam-root-service (operating-system-pam-services os)) | 821 | (pam-root-service (operating-system-pam-services os)) |
| 796 | (operating-system-etc-service os) | 822 | (operating-system-etc-service os) |
| 823 | ;; XXX: hosts-file is deprecated | ||
| 824 | (if hosts-file | ||
| 825 | (simple-service 'deprecated-hosts-file etc-service-type | ||
| 826 | (list `("hosts" ,hosts-file))) | ||
| 827 | (service hosts-service-type | ||
| 828 | (local-host-entries host-name))) | ||
| 797 | (service setuid-program-service-type | 829 | (service setuid-program-service-type |
| 798 | (operating-system-setuid-programs os)) | 830 | (operating-system-setuid-programs os)) |
| 799 | (service profile-service-type (operating-system-packages os))))) | 831 | (service profile-service-type (operating-system-packages os))))) |
| @@ -912,14 +944,17 @@ of PROVENANCE-SERVICE-TYPE to its services." | |||
| 912 | " | 944 | " |
| 913 | This is the GNU system. Welcome.\n") | 945 | This is the GNU system. Welcome.\n") |
| 914 | 946 | ||
| 915 | (define (local-host-aliases host-name) | 947 | (define-deprecated (local-host-aliases host-name) |
| 948 | local-host-entries | ||
| 916 | "Return aliases for HOST-NAME, to be used in /etc/hosts." | 949 | "Return aliases for HOST-NAME, to be used in /etc/hosts." |
| 917 | (string-append "127.0.0.1 localhost " host-name "\n" | 950 | (string-append "127.0.0.1 localhost " host-name "\n" |
| 918 | "::1 localhost " host-name "\n")) | 951 | "::1 localhost " host-name "\n")) |
| 919 | 952 | ||
| 920 | (define (default-/etc/hosts host-name) | 953 | (define (local-host-entries host-name) |
| 921 | "Return the default /etc/hosts file." | 954 | "Return <host> records for @var{host-name}." |
| 922 | (plain-file "hosts" (local-host-aliases host-name))) | 955 | (map (lambda (address) |
| 956 | (host address "localhost" (list host-name))) | ||
| 957 | '("127.0.0.1" "::1"))) | ||
| 923 | 958 | ||
| 924 | (define (validated-sudoers-file file) | 959 | (define (validated-sudoers-file file) |
| 925 | "Return a copy of FILE, a sudoers file, after checking that it is | 960 | "Return a copy of FILE, a sudoers file, after checking that it is |
| @@ -1068,8 +1103,6 @@ fi\n"))) | |||
| 1068 | ,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '()) | 1103 | ,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '()) |
| 1069 | ("profile" ,#~#$profile) | 1104 | ("profile" ,#~#$profile) |
| 1070 | ("bashrc" ,#~#$bashrc) | 1105 | ("bashrc" ,#~#$bashrc) |
| 1071 | ("hosts" ,#~#$(or (operating-system-hosts-file os) | ||
| 1072 | (default-/etc/hosts (operating-system-host-name os)))) | ||
| 1073 | ;; Write the operating-system-host-name to /etc/hostname to prevent | 1106 | ;; Write the operating-system-host-name to /etc/hostname to prevent |
| 1074 | ;; NetworkManager from changing the system's hostname when connecting | 1107 | ;; NetworkManager from changing the system's hostname when connecting |
| 1075 | ;; to certain networks. Some discussion at | 1108 | ;; to certain networks. Some discussion at |
