unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How to compose sysctl-service-type?
@ 2021-03-10 17:05 Leo Famulari
  2021-03-12 23:44 ` Leo Famulari
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Famulari @ 2021-03-10 17:05 UTC (permalink / raw)
  To: help-guix

I'm trying to set some default sysctl settings for Guix System:

https://bugs.gnu.org/47013

The problem is that I can't figure out how to compose the
sysctl-service-type. Overall, I'm really confused at the variety of ways
that services are created and used.

If we put (service sysctl-service-type ...) in %base-services, then
users cannot set their own things in config.scm, because it fails with
"guix system: error: service 'sysctl' provided more than once". On the
other hand, special-files-service-type can be used this way.

So I tried to make a simple-service 'default-sysctl-settings':

------
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index f6a490f712..68058efe15 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -35,6 +35,7 @@
   #:use-module (gnu services)
   #:use-module (gnu services admin)
   #:use-module (gnu services shepherd)
+  #:use-module (gnu services sysctl)
   #:use-module (gnu system pam)
   #:use-module (gnu system shadow)                ; 'user-account', etc.
   #:use-module (gnu system uuid)
@@ -2484,6 +2485,14 @@ to handle."
                                            (requirement requirement)
                                            (name-servers name-servers)))))
 
+(define (default-sysctl-settings default-settings)
+  (simple-service 'base-sysctl-settings
+                  sysctl-service-type
+                  default-settings))
+
 \f
 (define %base-services
   ;; Convenience variable holding the basic services.
@@ -2532,6 +2541,12 @@ to handle."
                  (udev-configuration
                    (rules (list lvm2 fuse alsa-utils crda))))
 
+        (service default-sysctl-settings
+                 (sysctl-configuration
+                  (settings
+                   '(("fs.protected_hardlinks" . "1")
+                     ("fs.protected_symlinks" . "1")))))
+
         (service special-files-service-type
                  `(("/bin/sh" ,(file-append bash "/bin/sh"))
                    ("/usr/bin/env" ,(file-append coreutils "/bin/env"))))))
------

But, that crashes like this:

------
Backtrace:
In guix/ui.scm:
  2164:12 19 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1736:10 18 (with-exception-handler _ _ #:unwind? _ # _)
  1731:15 17 (with-exception-handler #<procedure 7f1973632750 at ic…> …)
In guix/scripts/system.scm:
   1394:8 16 (_)
In guix/status.scm:
    780:4 15 (call-with-status-report _ _)
In guix/scripts/system.scm:
   1228:4 14 (_)
In ice-9/boot-9.scm:
  1736:10 13 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
   636:37 12 (thunk)
   1305:8 11 (call-with-build-handler #<procedure 7f1975b9de40 at g…> …)
  2066:24 10 (run-with-store #<store-connection 256.99 7f19743da870> …)
In guix/scripts/system.scm:
    823:2  9 (_ _)
    705:7  8 (_ #<store-connection 256.99 7f19743da870>)
In gnu/system/vm.scm:
   737:31  7 (system-qemu-image/shared-store-script _ #:system _ # _ …)
    661:2  6 (system-qemu-image/shared-store #<<operating-system> k…> …)
In gnu/system.scm:
  1231:38  5 (operating-system-uuid #<<operating-system> kernel: #<…> …)
In gnu/services.scm:
    963:4  4 (instantiate-missing-services _)
In guix/combinators.scm:
    46:26  3 (fold2 #<procedure adjust-service-list (svc result ins…> …)
In gnu/services.scm:
   954:11  2 (adjust-service-list _ (#<<service> type: #<service…> …) …)
In ice-9/boot-9.scm:
  1669:16  1 (raise-exception _ #:continuable? _)
  1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #<procedure default-sysctl-settings (a)>
------


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

* Re: How to compose sysctl-service-type?
  2021-03-10 17:05 How to compose sysctl-service-type? Leo Famulari
@ 2021-03-12 23:44 ` Leo Famulari
  0 siblings, 0 replies; 2+ messages in thread
From: Leo Famulari @ 2021-03-12 23:44 UTC (permalink / raw)
  To: help-guix

On Wed, Mar 10, 2021 at 12:05:37PM -0500, Leo Famulari wrote:
> I'm trying to set some default sysctl settings for Guix System:
> 
> https://bugs.gnu.org/47013
> 
> The problem is that I can't figure out how to compose the
> sysctl-service-type. Overall, I'm really confused at the variety of ways
> that services are created and used.

With roptat's assistance on IRC, I was able to send an improved revision
to the patch ticket.


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

end of thread, other threads:[~2021-03-12 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 17:05 How to compose sysctl-service-type? Leo Famulari
2021-03-12 23:44 ` Leo Famulari

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).