diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 190bb8fe24..2c984a0747 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2022 Ludovic Courtès +;;; Copyright © 2013-2023 Ludovic Courtès ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2015, 2016, 2020 Mark H Weaver ;;; Copyright © 2015 Sou Bunnbu @@ -703,9 +703,10 @@ (define-deprecated (rngd-service #:key (rng-tools rng-tools) ;;; /etc/hosts ;;; -(define (valid-name? name) - "Return true if @var{name} is likely to be a valid host name." - (false-if-exception (not (string-any char-set:whitespace name)))) +(eval-when (expand load eval) + (define (valid-name? name) + "Return true if @var{name} is likely to be a valid host name." + (false-if-exception (not (string-any char-set:whitespace name))))) (define-compile-time-procedure (assert-valid-name (name valid-name?)) "Ensure @var{name} is likely to be a valid host name." @@ -2664,16 +2665,17 @@ (define-record-type* ipv6-address?)))) (gateway network-route-gateway (default #f))) -(define* (cidr->netmask str #:optional (family AF_INET)) - "Given @var{str}, a string in CIDR notation (e.g., \"1.2.3.4/24\"), return +(eval-when (expand load eval) + (define* (cidr->netmask str #:optional (family AF_INET)) + "Given @var{str}, a string in CIDR notation (e.g., \"1.2.3.4/24\"), return the netmask as a string like \"255.255.255.0\"." - (match (string-split str #\/) - ((ip (= string->number bits)) - (let ((mask (ash (- (expt 2 bits) 1) - (- (if (= family AF_INET6) 128 32) - bits)))) - (inet-ntop family mask))) - (_ #f))) + (match (string-split str #\/) + ((ip (= string->number bits)) + (let ((mask (ash (- (expt 2 bits) 1) + (- (if (= family AF_INET6) 128 32) + bits)))) + (inet-ntop family mask))) + (_ #f)))) (define (cidr->ip str) "Strip the netmask bit of @var{str}, a CIDR-notation IP/netmask address."