aboutsummaryrefslogtreecommitdiff
path: root/gnu/system.scm
diff options
context:
space:
mode:
authorBruno Victal <mirai@makinata.eu>2023-01-27 21:06:12 +0000
committerLudovic Courtès <ludo@gnu.org>2023-02-09 01:07:47 +0100
commit802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6 (patch)
tree3adf9c824a6531b7ad74fc21bcba080772be7bc2 /gnu/system.scm
parent22dd558c70901a336de97187f0470be584571158 (diff)
downloadguix-802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6.tar
guix-802ea1f3a43e5fb8d0b8bd2882954d8a6e49cde6.tar.gz
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.scm59
1 files changed, 46 insertions, 13 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index d67f9a615b..df60fda53b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2020, 2022 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -97,7 +98,7 @@
operating-system-user-services
operating-system-packages
operating-system-host-name
- operating-system-hosts-file
+ operating-system-hosts-file ;deprecated
operating-system-hurd
operating-system-kernel
operating-system-kernel-file
@@ -169,7 +170,8 @@
read-boot-parameters-file
boot-parameters->menu-entry
- local-host-aliases
+ local-host-aliases ;deprecated
+ local-host-entries
%root-account
%setuid-programs
%sudoers-specification
@@ -208,6 +210,15 @@ VERSION is the target version of the boot-parameters record."
#$system "/boot")))
;; System-wide configuration.
+
+(define-with-syntax-properties (warn-hosts-file-field-deprecation
+ (value properties))
+ (when value
+ (warning (source-properties->location properties)
+ (G_ "the 'hosts-file' field is deprecated, please use \
+'hosts-service-type' instead~%")))
+ value)
+
;; TODO: Add per-field docstrings/stexi.
(define-record-type* <operating-system> operating-system
make-operating-system
@@ -239,8 +250,9 @@ VERSION is the target version of the boot-parameters record."
(default %base-firmware))
(host-name operating-system-host-name) ; string
- (hosts-file operating-system-hosts-file ; file-like | #f
- (default #f))
+ (hosts-file %operating-system-hosts-file ; deprecated
+ (default #f)
+ (sanitize warn-hosts-file-field-deprecation))
(mapped-devices operating-system-mapped-devices ; list of <mapped-device>
(default '()))
@@ -296,6 +308,10 @@ VERSION is the target version of the boot-parameters record."
source-properties->location))
(innate)))
+(define-deprecated (operating-system-hosts-file os)
+ hosts-service-type
+ (%operating-system-hosts-file os))
+
(define* (operating-system-kernel-arguments
os root-device #:key (version %boot-parameters-version))
"Return all the kernel arguments, including the ones not specified directly
@@ -733,7 +749,8 @@ bookkeeping."
(non-boot-fs (non-boot-file-system-service os))
(swaps (swap-services os))
(procs (service user-processes-service-type))
- (host-name (host-name-service (operating-system-host-name os)))
+ (host-name (operating-system-host-name os))
+ (hosts-file (%operating-system-hosts-file os))
(entries (operating-system-directory-base-entries os)))
(cons* (service system-service-type entries)
(service linux-builder-service-type
@@ -755,12 +772,19 @@ bookkeeping."
(operating-system-groups os))
(operating-system-skeletons os))
(operating-system-etc-service os)
+ ;; XXX: hosts-file is deprecated
+ (if hosts-file
+ (simple-service 'deprecated-hosts-file etc-service-type
+ (list `("hosts" ,hosts-file)))
+ (service hosts-service-type
+ (local-host-entries host-name)))
(service fstab-service-type
(filter file-system-needed-for-boot?
(operating-system-file-systems os)))
(session-environment-service
(operating-system-environment-variables os))
- host-name procs root-fs
+ (host-name-service host-name)
+ procs root-fs
(service setuid-program-service-type
(operating-system-setuid-programs os))
(service profile-service-type
@@ -774,7 +798,9 @@ bookkeeping."
(operating-system-firmware os)))))))
(define (hurd-default-essential-services os)
- (let ((entries (operating-system-directory-base-entries os)))
+ (let ((host-name (operating-system-host-name os))
+ (hosts-file (%operating-system-hosts-file os))
+ (entries (operating-system-directory-base-entries os)))
(list (service system-service-type entries)
%boot-service
%hurd-startup-service
@@ -794,6 +820,12 @@ bookkeeping."
(operating-system-file-systems os)))
(pam-root-service (operating-system-pam-services os))
(operating-system-etc-service os)
+ ;; XXX: hosts-file is deprecated
+ (if hosts-file
+ (simple-service 'deprecated-hosts-file etc-service-type
+ (list `("hosts" ,hosts-file)))
+ (service hosts-service-type
+ (local-host-entries host-name)))
(service setuid-program-service-type
(operating-system-setuid-programs os))
(service profile-service-type (operating-system-packages os)))))
@@ -912,14 +944,17 @@ of PROVENANCE-SERVICE-TYPE to its services."
"
This is the GNU system. Welcome.\n")
-(define (local-host-aliases host-name)
+(define-deprecated (local-host-aliases host-name)
+ local-host-entries
"Return aliases for HOST-NAME, to be used in /etc/hosts."
(string-append "127.0.0.1 localhost " host-name "\n"
"::1 localhost " host-name "\n"))
-(define (default-/etc/hosts host-name)
- "Return the default /etc/hosts file."
- (plain-file "hosts" (local-host-aliases host-name)))
+(define (local-host-entries host-name)
+ "Return <host> records for @var{host-name}."
+ (map (lambda (address)
+ (host address "localhost" (list host-name)))
+ '("127.0.0.1" "::1")))
(define (validated-sudoers-file file)
"Return a copy of FILE, a sudoers file, after checking that it is
@@ -1068,8 +1103,6 @@ fi\n")))
,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '())
("profile" ,#~#$profile)
("bashrc" ,#~#$bashrc)
- ("hosts" ,#~#$(or (operating-system-hosts-file os)
- (default-/etc/hosts (operating-system-host-name os))))
;; Write the operating-system-host-name to /etc/hostname to prevent
;; NetworkManager from changing the system's hostname when connecting
;; to certain networks. Some discussion at