unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* removing items from %desktop-services
@ 2018-05-16  8:44 Efraim Flashner
  2018-05-17 14:28 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Efraim Flashner @ 2018-05-16  8:44 UTC (permalink / raw)
  To: help-guix


[-- Attachment #1.1: Type: text/plain, Size: 1470 bytes --]

I'm trying to modify the list of services in my os-config, and I've run
into a bit of a problem. I've replaced my ntp-service with an
openntpd-service, but I'm having trouble with the syntax for removing
more services. Here's a snippet:

(use-modules (srfi srfi-1)

<snip>

   (modify-services (delete (ntp-service) %desktop-services)
   ;(modify-services (fold delete %desktop-services
   ;                       '(
   ;                         (screen-locker-service slock)
   ;                         (screen-locker-service xlockmore "xlock")
   ;                         (ntp-service)
   ;                         )

<snip>

The uncommented out code works and deletes (ntp-service) from
%desktop-servies as expected. When I comment that line out and put in
the multi-line version with fold then I find out that it doesn't work,
as evidenced by the error that I have two services providing ntpd (ntp
and openntpd).

I know I can put (modify-services (delete (service)
                                    (delete (other-service)
                                      (delete (third-service)
                                        %desktop-services)))

but I'd rather do it more cleanly with `fold' or something similar.


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #1.2: macbook41_config.scm --]
[-- Type: text/plain, Size: 6515 bytes --]

(use-modules (guix store)
             (gnu)
             (gnu system nss)
             (gnu system locale)
             (srfi srfi-1))
(use-service-modules admin cups desktop mcron networking pm ssh xorg)
(use-package-modules bootloaders certs cups gnome linux video)

(define %btrfs-scrub
  #~(job '(next-hour '(3))
         (string-append #$btrfs-progs "/bin/btrfs scrub -c 3 start /")))

(define %btrfs-balance
  #~(job '(next-hour '(5))
         (string-append #$btrfs-progs "/bin/btrfs balance start -dusage=50 -musage=70 /")))

(define my-xorg-modules
  ;; Only the modules on this laptop
  (fold delete %default-xorg-modules
        '("xf86-video-ati"
          "xf86-video-cirrus"
          "xf86-video-mach64"
          "xf86-video-nouveau"
          "xf86-video-nv"
          "xf86-video-sis"
          "xf86-input-evdev"
          "xf86-input-keyboard"
          "xf86-input-mouse"
          "xf86-input-synaptics"
          )))

(operating-system
  (host-name "macbook41")
  (timezone "Asia/Jerusalem")
  (locale "en_US.utf8")
  (locale-definitions
    (list (locale-definition (source "en_US")
                             (name "en_US.utf8"))
          (locale-definition (source "he_IL")
                             (name "he_IL.utf8"))))

  ;; Assuming /dev/sdX is the target hard disk, and "my-root"
  ;; is the label of the target root file system.
  (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (target "/boot/efi")))

  (kernel-arguments '("zswap.enabled=1"
                      ;; Required to run X32 software and VMs
                      ;; https://wiki.debian.org/X32Port
                      ;; Still untested on GuixSD.
                      "syscall.x32=y"))

  (file-systems (cons* (file-system
                         (device "my-root")
                         (mount-point "/")
                         (type "btrfs")
                         (title 'label)
                         (options "autodefrag,compress=lzo,discard,ssd_spread"))
                       (file-system
                         (device "none")
                         (mount-point "/var/guix/temproots")
                         (title 'device)
                         (type "tmpfs")
                         (check? #f))
                       (file-system
                         (device (uuid "F010-1913" 'fat))
                         (title 'uuid)
                         (mount-point "/boot/efi")
                         (type "vfat"))
                       %base-file-systems))

  (swap-devices '("/dev/sda2"))

  (users (cons (user-account
                (name "efraim")
                (comment "Efraim")
                (group "users")
                (supplementary-groups '("wheel" "netdev" "kvm"
                                        "lp" "lpadmin"
                                        "audio" "video"))
                (home-directory "/home/efraim"))
               %base-user-accounts))

  ;; This is where we specify system-wide packages.
  (packages (cons* nss-certs         ;for HTTPS access
                   gvfs              ;for user mounts
                   cups
                   btrfs-progs
                   libvdpau-va-gl    ;intel graphics vdpau
                   %base-packages))

  (services (cons* (service enlightenment-desktop-service-type)
                   (console-keymap-service "il-heb")
                   (service guix-publish-service-type
                            (guix-publish-configuration
                              (port 3000)))
                   (service openssh-service-type
                            (openssh-configuration
                              (port-number 22)
                              (allow-empty-passwords? #f)
                              (password-authentication? #t)))

                   (tor-service)
                   (tor-hidden-service "http"
                                       '((22 "127.0.0.1:22")))

                   (service cups-service-type
                            (cups-configuration
                              (web-interface? #t)
                              (extensions
                                (list cups-filters hplip))))

                   (service tlp-service-type)

                   (service rottlog-service-type)
                   (service mcron-service-type
                            (mcron-configuration
                             (jobs (list %btrfs-scrub
                                         %btrfs-balance))))

                   (service openntpd-service-type
                            (openntpd-configuration
                              (listen-on '("127.0.0.1" "::1"))
                              (allow-large-adjustment? #t)))

                   (modify-services (delete (ntp-service) %desktop-services)
                   ;(modify-services (fold delete %desktop-services
                   ;                       '(
                   ;                         (screen-locker-service slock)
                   ;                         (screen-locker-service xlockmore "xlock")
                   ;                         (ntp-service)
                   ;                         )
                   ;                       )
                     (guix-service-type config =>
                                        (guix-configuration
                                          (inherit config)
                                          (substitute-urls
                                            (cons* ;"https://bayfront.guixsd.org" ; currently offline
                                                   "https://berlin.guixsd.org"
                                                   ;"http://192.168.1.134:8181" ; odroid-c2
                                                   "http://192.168.1.183" ; E1240
                                                   %default-substitute-urls))
                                          (extra-options
                                            '("--cores=1")))) ; we're on a laptop

                     (slim-service-type config =>
                                        (slim-configuration
                                          (inherit config)
                                          (startx (xorg-start-command
                                                    #:modules my-xorg-modules))))
                     )))

  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: removing items from %desktop-services
  2018-05-16  8:44 removing items from %desktop-services Efraim Flashner
@ 2018-05-17 14:28 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-05-17 14:28 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: help-guix

Hello,

Efraim Flashner <efraim@flashner.co.il> skribis:

> I'm trying to modify the list of services in my os-config, and I've run
> into a bit of a problem. I've replaced my ntp-service with an
> openntpd-service, but I'm having trouble with the syntax for removing
> more services. Here's a snippet:

There’s an example of that in the manual (info "(guix) Using the
Configuration System"):

     (remove (lambda (service)
               (eq? (service-kind service) avahi-service-type))
             %desktop-services)

I suppose you could do the same for ntpd.

Now it’s a bit more verbose.  In the snippets you posted you used
‘delete’, but that’ll only work if the service you want to remove has
the default configuration (and assuming it can be usefully compared with
‘equal?’), so the more verbose ‘remove’ stanza is needed.

Now, just like we have ‘modify-services’, we could have
‘remove-services’ or similar, like this:

  (define (remove-services types services)
    (remove (lambda (service)
              (any (lambda (type)
                     (eq? (service-kind service) type))
                   types))
            services))

and then you could write:

  ;; Remove NTP and Avahi.
  (remove-services (list avahi-service-type ntp-service-type)
                   %desktop-services)

HTH!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-17 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-16  8:44 removing items from %desktop-services Efraim Flashner
2018-05-17 14:28 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).