From b33e191c86b7638517ea838b63a54d031a033554 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 9 Oct 2018 18:52:37 +0200 Subject: guix build: '-f' accepts file-like objects. * guix/scripts/build.scm (options->things-to-build)[validate-type]: Check for 'file-like?'. (options->derivations): Accept 'file-like?'. * tests/guix-build.sh: Add a test with 'computed-file'. * doc/guix.texi (Additional Build Options): Mention file-like objects. --- doc/guix.texi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 3c116fc0be..9b37270a83 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6365,9 +6365,8 @@ retrieved using the @option{--log-file} option. @item --file=@var{file} @itemx -f @var{file} - -Build the package or derivation that the code within @var{file} -evaluates to. +Build the package, derivation, or other file-like object that the code within +@var{file} evaluates to (@pxref{G-Expressions, file-like objects}). As an example, @var{file} might contain a package definition like this (@pxref{Defining Packages}): -- cgit 1.4.1 From 795d430d90e41eb172315bfccf79c9f13fc0ebfa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 9 Oct 2018 11:51:44 +0200 Subject: pull: Turn ~/.config/guix/current into a symlink to /var/guix/profiles. This is more consistent with what 'guix package' does, more pleasant for users (we no longer clobber ~/.config/guix), and more cluster-friendly (since /var/guix/profiles is usually an NFS share already.) * guix/scripts/pull.scm (%current-profile, %user-profile-directory): New variables. (migrate-generations, ensure-default-profile): New procedures. (guix-pull): Use %CURRENT-PROFILE by default. Call 'ensure-default-profile'. * doc/guix.texi (Invoking guix pull): Adjust 'guix package -p ~/.config/guix/current' example. * guix/scripts.scm (warn-about-old-distro): Check %PROFILE-DIRECTORY "/current-guix". --- doc/guix.texi | 2 +- guix/scripts.scm | 4 ++-- guix/scripts/pull.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 6 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 9b37270a83..5ae80917a9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2831,7 +2831,7 @@ generation---i.e., the previous Guix---and so on: $ guix package -p ~/.config/guix/current --roll-back switched from generation 3 to 2 $ guix package -p ~/.config/guix/current --delete-generations=1 -deleting /home/charlie/.config/guix/current-1-link +deleting /var/guix/profiles/per-user/charlie/current-guix-1-link @end example The @command{guix pull} command is usually invoked with no arguments, diff --git a/guix/scripts.scm b/guix/scripts.scm index 4cbbbeb96f..98751bc812 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -26,6 +26,7 @@ #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix derivations) + #:use-module ((guix profiles) #:select (%profile-directory)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-37) @@ -169,8 +170,7 @@ Show what and how will/would be built." (define age (match (false-if-not-found - (lstat (string-append (config-directory #:ensure? #f) - "/current"))) + (lstat (string-append %profile-directory "/current-guix"))) (#f #f) (stat (- (time-second (current-time time-utc)) (stat:mtime stat))))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 0d65857beb..5fecc11de3 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -225,6 +225,53 @@ Download and deploy the latest version of Guix.\n")) (lambda (key err) (report-git-error err)))) + +;;; +;;; Profile. +;;; + +(define %current-profile + ;; The "real" profile under /var/guix. + (string-append %profile-directory "/current-guix")) + +(define %user-profile-directory + ;; The user-friendly name of %CURRENT-PROFILE. + (string-append (config-directory #:ensure? #f) "/current")) + +(define (migrate-generations profile directory) + "Migration the generations of PROFILE to DIRECTORY." + (format (current-error-port) + (G_ "Migrating profile generations to '~a'...~%") + %profile-directory) + (for-each (lambda (generation) + (let ((source (generation-file-name profile generation)) + (target (string-append directory "/current-guix-" + (number->string generation) + "-link"))) + (rename-file source target))) + (profile-generations profile))) + +(define (ensure-default-profile) + (ensure-profile-directory) + + ;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move + ;; them to %PROFILE-DIRECTORY. + (unless (string=? %profile-directory + (dirname (canonicalize-profile %user-profile-directory))) + (migrate-generations %user-profile-directory %profile-directory)) + + ;; Make sure ~/.config/guix/current points to /var/guix/profiles/…. + (let ((link %user-profile-directory)) + (unless (equal? (false-if-exception (readlink link)) + %current-profile) + (catch 'system-error + (lambda () + (false-if-exception (delete-file link)) + (symlink %current-profile link)) + (lambda args + (leave (G_ "while creating symlink '~a': ~a~%") + link (strerror (system-error-errno args)))))))) + ;;; ;;; Queries. @@ -438,9 +485,8 @@ Use '~/.config/guix/channels.scm' instead.")) (list %default-options))) (cache (string-append (cache-directory) "/pull")) (channels (channel-list opts)) - (profile (or (assoc-ref opts 'profile) - (string-append (config-directory) "/current")))) - + (profile (or (assoc-ref opts 'profile) %current-profile))) + (ensure-default-profile) (cond ((assoc-ref opts 'query) (process-query opts profile)) ((assoc-ref opts 'dry-run?) -- cgit 1.4.1 From acce0a474c1493ab18912bc46285248e4ccb0314 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Mon, 9 Apr 2018 01:04:10 +0200 Subject: services: wpa-supplicant: Extend to support configuration parameters. This allows using WPA Supplicant "standalone" without an additional network manager. The default configuration is unchanged. * gnu/services/networking.scm (): New record type. (wpa-supplicant-shepherd-service): Pass configuration records to the daemon. (wpa-supplicant-service-type): Adjust accordingly. * doc/guix.texi (Networking Services): Document the new service type. --- doc/guix.texi | 35 +++++++++++++----- gnu/services/networking.scm | 86 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 91 insertions(+), 30 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 5ae80917a9..2cea52f02b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11737,18 +11737,35 @@ When true, enable connman's vpn plugin. @defvr {Scheme Variable} wpa-supplicant-service-type This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA supplicant}, an authentication daemon required to authenticate against -encrypted WiFi or ethernet networks. It is configured to listen for -requests on D-Bus. +encrypted WiFi or ethernet networks. +@end defvr -The value of this service is the @code{wpa-supplicant} package to use. -Thus, it can be instantiated like this: +@deftp {Data Type} wpa-supplicant-configuration +Data type representing the configuration of WPA Supplicant. -@lisp -(use-modules (gnu services networking)) +It takes the following parameters: -(service wpa-supplicant-service-type) -@end lisp -@end defvr +@table @asis +@item @code{wpa-supplicant} (default: @code{wpa-supplicant}) +The WPA Supplicant package to use. + +@item @code{dbus?} (default: @code{#t}) +Whether to listen for requests on D-Bus. + +@item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"}) +Where to store the PID file. + +@item @code{interface} (default: @code{#f}) +If this is set, it must specify the name of a network interface that +WPA supplicant will control. + +@item @code{config-file} (default: @code{#f}) +Optional configuration file to use. + +@item @code{extra-options} (default: @code{'()}) +List of additional command-line arguments to pass to the daemon. +@end table +@end deftp @cindex iptables @defvr {Scheme Variable} iptables-service-type diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 3fdb2bb9f7..c809b4a4a4 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -5,7 +5,7 @@ ;;; Copyright © 2016 John Darrington ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2017 Thomas Danckaert -;;; Copyright © 2017 Marius Bakke +;;; Copyright © 2017, 2018 Marius Bakke ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac @@ -101,6 +101,16 @@ modem-manager-configuration modem-manager-configuration? modem-manager-service-type + + + wpa-supplicant-configuration + wpa-supplicant-configuration? + wpa-supplicant-configuration-wpa-supplicant + wpa-supplicant-configuration-pid-file + wpa-supplicant-configuration-dbus? + wpa-supplicant-configuration-interface + wpa-supplicant-configuration-config-file + wpa-supplicant-configuration-extra-options wpa-supplicant-service-type openvswitch-service-type @@ -1019,28 +1029,62 @@ networking.")))) ;;; WPA supplicant ;;; - -(define (wpa-supplicant-shepherd-service wpa-supplicant) - "Return a shepherd service for wpa_supplicant" - (list (shepherd-service - (documentation "Run WPA supplicant with dbus interface") - (provision '(wpa-supplicant)) - (requirement '(user-processes dbus-system loopback)) - (start #~(make-forkexec-constructor - (list (string-append #$wpa-supplicant - "/sbin/wpa_supplicant") - "-u" "-B" "-P/var/run/wpa_supplicant.pid") - #:pid-file "/var/run/wpa_supplicant.pid")) - (stop #~(make-kill-destructor))))) +(define-record-type* + wpa-supplicant-configuration make-wpa-supplicant-configuration + wpa-supplicant-configuration? + (wpa-supplicant wpa-supplicant-configuration-wpa-supplicant ; + (default wpa-supplicant)) + (pid-file wpa-supplicant-configuration-pid-file ;string + (default "/var/run/wpa_supplicant.pid")) + (dbus? wpa-supplicant-configuration-dbus? ;Boolean + (default #t)) + (interface wpa-supplicant-configuration-interface ;#f | string + (default #f)) + (config-file wpa-supplicant-configuration-config-file ;#f | + (default #f)) + (extra-options wpa-supplicant-configuration-extra-options ;list of strings + (default '()))) + +(define wpa-supplicant-shepherd-service + (match-lambda + (($ wpa-supplicant pid-file dbus? interface + config-file extra-options) + (list (shepherd-service + (documentation "Run the WPA supplicant daemon") + (provision '(wpa-supplicant)) + (requirement '(user-processes dbus-system loopback)) + (start #~(make-forkexec-constructor + (list (string-append #$wpa-supplicant + "/sbin/wpa_supplicant") + (string-append "-P" #$pid-file) + "-B" ;run in background + #$@(if dbus? + #~("-u") + #~()) + #$@(if interface + #~(string-append "-i" #$interface) + #~()) + #$@(if config-file + #~(string-append "-c" #$config-file) + #~()) + #$@extra-options) + #:pid-file #$pid-file)) + (stop #~(make-kill-destructor))))))) (define wpa-supplicant-service-type - (service-type (name 'wpa-supplicant) - (extensions - (list (service-extension shepherd-root-service-type - wpa-supplicant-shepherd-service) - (service-extension dbus-root-service-type list) - (service-extension profile-service-type list))) - (default-value wpa-supplicant))) + (let ((config->package + (match-lambda + (($ wpa-supplicant) + (list wpa-supplicant))))) + (service-type (name 'wpa-supplicant) + (extensions + (list (service-extension shepherd-root-service-type + wpa-supplicant-shepherd-service) + (service-extension dbus-root-service-type config->package) + (service-extension profile-service-type config->package))) + (description "Run the WPA Supplicant daemon, a service that +implements authentication, key negotiation and more for wireless networks.") + (default-value (wpa-supplicant-configuration))))) ;;; -- cgit 1.4.1