guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

13/20: installer: Use guix build syscalls module for network interrogati


From: John Darrington
Subject: 13/20: installer: Use guix build syscalls module for network interrogation.
Date: Thu, 12 Jan 2017 20:41:04 +0000 (UTC)

jmd pushed a commit to branch wip-installer
in repository guix.

commit a8ab689900224d107896cdcf001453521fc17579
Author: John Darrington <address@hidden>
Date:   Tue Jan 10 15:59:53 2017 +0100

    installer: Use guix build syscalls module for network interrogation.
    
    * gnu/system/installer/network.scm (interfaces): Do some of the
    work with the module (guix build syscalls) rather than everything
    ourself.
---
 gnu/system/installer/network.scm |   38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/gnu/system/installer/network.scm b/gnu/system/installer/network.scm
index bbf60d9..1667abc 100644
--- a/gnu/system/installer/network.scm
+++ b/gnu/system/installer/network.scm
@@ -22,6 +22,7 @@
   #:use-module (gnu system installer misc)
   #:use-module (gnu system installer utils)
   #:use-module (gnu system installer wireless)
+  #:use-module (guix build syscalls)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (gurses menu)
@@ -39,22 +40,14 @@
             network-page-key-handler))
 
 (define (interfaces)
-  "Return a alist of network interfaces. Keys include 'name, 'class and 'state"
-  (slurp "ip -o link"
-         (lambda (s)
-           (match (string-split s #\space)
-             ((_ interface-name _ _ _ _ _ _
-                 state _ _ _ _ _ _ _ _ _ class . _)
-              (let ((clean-name (string-trim-right interface-name #\:)))
-              `((name .  ,clean-name)
-                (state . ,state)
-                (class . ,(cond
-                           ((equal? class "link/loopback") 'loopback)
-                           ((equal? class "link/ether")
-                            (if (zero? (system* "iw" "dev" clean-name "info"))
-                                 'wireless
-                                 'ethernet))
-                           (else 'other))))))))))
+  (map (lambda (ifce)
+                `((name .  ,ifce)
+                  (class . ,(cond
+                             ((loopback-network-interface? ifce) 'loopback)
+                             ((zero? (system* "iw" "dev" ifce "info"))
+                              'wireless)
+                             (else 'ethernet)))))
+       (all-network-interface-names)))
 
 (define my-buttons `((continue ,(N_ "_Continue") #t)
                     (test     ,(N_ "_Test") #t)))
@@ -155,12 +148,12 @@
                       (getmaxy text-window) 0 #:panel #f))
 
         (menu (make-menu
-               (filter (lambda (i) (memq
+               (filter (lambda (i) (memq
                                      (assq-ref i 'class)
                                      '(ethernet wireless)))
                         (interfaces))
-               #:disp-proc
-               (lambda (datum row)
+               #:disp-proc
+               (lambda (datum row)
 
                   (match (string-split
                           (car (slurp
@@ -170,9 +163,9 @@
 
 
                   ;; Convert a network device name such as "enp0s25" to
-                 ;; something more descriptive like
-                 ;; "82567LM Gigabit Network Connection"
-                 (let* ((name (assq-ref datum 'name))
+                 ;; something more descriptive like
+                 ;; "82567LM Gigabit Network Connection"
+                 (let* ((name (assq-ref datum 'name))
                          (addr (string-tokenize name char-set:digit)))
                     (match addr
                       ((bus device . func)
@@ -195,7 +188,6 @@
                              "Device:"))
                        state flags))))))))))
 
-
     (addstr*   text-window  (format #f
              (gettext
               "To install GuixSD a connection to one of ~s must be available.  
The following network devices exist on the system.  Select one to configure or 
\"Continue\" to proceeed.") %default-substitute-urls))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]