unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#62281] [PATCH] home: Add home-xorg-server-service-type.
@ 2023-03-19 21:54 Sergey Trofimov
  2023-03-21 21:32 ` Sergey Trofimov
  0 siblings, 1 reply; 2+ messages in thread
From: Sergey Trofimov @ 2023-03-19 21:54 UTC (permalink / raw)
  To: 62281; +Cc: Sergey Trofimov, paren, andrew, ludo

* gnu/home/services/desktop.scm
(home-xorg-server-service-type): New variable.
* gnu/services/xorg.scm (xorg-server-wrapper-package):
Rename from xorg-server-profile-server and export.
* doc/guix.texi: Document home-xorg-server-service-type.
---
 doc/guix.texi                 | 27 +++++++++++++++++++
 gnu/home/services/desktop.scm | 17 +++++++++++-
 gnu/services/xorg.scm         | 51 ++++++++++++++++++-----------------
 3 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index fa9ea5a6ec..9c1df5d1b5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -42661,6 +42661,33 @@ The list of expressions to be read by @code{xmodmap} on service startup.
 @end table
 @end deftp
 
+@defvar home-xorg-server-service-type
+This is the service type to run rootless @code{xorg-server}.  It takes
+@code{xorg-configuration} which is used to generate the Xorg server
+start script.
+
+@lisp
+(service home-xorg-server-service-type
+         (xorg-configuration
+          (modules (list xf86-video-intel xf86-input-libinput))
+          (drivers (list "intel"))))
+@end lisp
+
+Xorg can be started after logging in the console using @command{xinit}
+or @command{sx}.  This could also be automated by adding auto-start
+launcher to the shell's rc file.
+
+@lisp
+(simple-service
+ 'sx-autostart home-bash-service-type
+ (home-bash-extension
+  (bash-profile
+   (list (plain-file
+          "bash-sx-autostart"
+          "[[ ! $DISPLAY && $(tty) == /dev/tty1 ]] && exec sx")))))
+@end lisp
+@end defvar
+
 @node Guix Home Services
 @subsection Guix Home Services
 
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index fb1cd44060..cfb2dd52fa 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -25,6 +25,7 @@ (define-module (gnu home services desktop)
   #:autoload   (gnu packages glib)    (dbus)
   #:autoload   (gnu packages xdisorg) (redshift unclutter)
   #:autoload   (gnu packages xorg) (setxkbmap xmodmap)
+  #:use-module (gnu services xorg)
   #:use-module (guix records)
   #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
@@ -37,7 +38,11 @@ (define-module (gnu home services desktop)
             home-dbus-service-type
 
             home-unclutter-configuration
-            home-unclutter-service-type))
+            home-unclutter-service-type
+
+            home-xorg-server-service-type)
+
+  #:re-export (xorg-configuration))
 
 \f
 ;;;
@@ -332,3 +337,13 @@ (define home-xmodmap-service-type
    (default-value (home-xmodmap-configuration))
    (description "Run the @code{xmodmap} utility to modify keymaps and pointer
 buttons under the Xorg display server via user-defined expressions.")))
+
+(define home-xorg-server-service-type
+  (service-type
+   (name 'xorg-server)
+   (extensions
+    (list (service-extension home-profile-service-type
+                             (compose list xorg-server-wrapper-package))))
+   (default-value (xorg-configuration))
+   (description "Add @command{X} to the home profile, to be used with
+@command{sx} or @command{xinit}.")))
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index c4745cecf5..0e8f352926 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -84,6 +84,7 @@ (define-module (gnu services xorg)
             xorg-wrapper
             xorg-start-command
             xinitrc
+            xorg-server-wrapper-package
             xorg-server-service-type
 
             %default-slim-theme
@@ -506,37 +507,37 @@ (define-syntax handle-xorg-configuration
                       (xorg-configuration xorg-configuration))
                      config)))))))
 
-(define (xorg-server-profile-service config)
-  ;; XXX: profile-service-type only accepts <package> objects.
-  (list
-   (package
-     (name "xorg-wrapper")
-     (version (package-version xorg-server))
-     (source (xorg-wrapper config))
-     (build-system trivial-build-system)
-     (arguments
-      '(#:modules ((guix build utils))
-        #:builder
-        (begin
-          (use-modules (guix build utils))
-          (let* ((source (assoc-ref %build-inputs "source"))
-                 (out (assoc-ref %outputs "out"))
-                 (bin (string-append out "/bin")))
-            (mkdir-p bin)
-            (symlink source (string-append bin "/X"))
-            (symlink source (string-append bin "/Xorg"))
-            #t))))
-     (home-page (package-home-page xorg-server))
-     (synopsis (package-synopsis xorg-server))
-     (description (package-description xorg-server))
-     (license (package-license xorg-server)))))
+(define (xorg-server-wrapper-package config)
+  "Return a package with @command{X} and @command{Xorg} commands launching
+xorg-server with provided @var{config}."
+  (package
+    (name "xorg-wrapper")
+    (version (package-version xorg-server))
+    (source (xorg-wrapper config))
+    (build-system trivial-build-system)
+    (arguments
+     '(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((source (assoc-ref %build-inputs "source"))
+                (out (assoc-ref %outputs "out"))
+                (bin (string-append out "/bin")))
+           (mkdir-p bin)
+           (symlink source (string-append bin "/X"))
+           (symlink source (string-append bin "/Xorg"))
+           #t))))
+    (home-page (package-home-page xorg-server))
+    (synopsis (package-synopsis xorg-server))
+    (description (package-description xorg-server))
+    (license (package-license xorg-server))))
 
 (define xorg-server-service-type
   (service-type
    (name 'xorg-server)
    (extensions
     (list (service-extension profile-service-type
-                             xorg-server-profile-service)))
+                             (compose list xorg-server-wrapper-package))))
    (default-value (xorg-configuration))
    (description "Add @command{X} to the system profile, to be used with
 @command{sx} or @command{xinit}.")))
-- 
2.39.2





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

* [bug#62281] [PATCH] home: Add home-xorg-server-service-type.
  2023-03-19 21:54 [bug#62281] [PATCH] home: Add home-xorg-server-service-type Sergey Trofimov
@ 2023-03-21 21:32 ` Sergey Trofimov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Trofimov @ 2023-03-21 21:32 UTC (permalink / raw)
  To: 62281


This is not needed. Xorg config should be a part of the 
operating-system and guix already has xorg-server-service-type for 
that. Autostart of sx could be done in the home-environment using 
this code:

(define (sx-autostart-on tty)
  (simple-service
   'sx-autostart home-shell-profile-service-type
   (list (mixed-text-file
          "sx-autostart"
          "[[ ! $DISPLAY && $(tty) == /dev/" tty " ]] && "
          "exec " (@ (gnu packages xdisorg) sx) "/bin/sx"))))




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

end of thread, other threads:[~2023-03-21 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-19 21:54 [bug#62281] [PATCH] home: Add home-xorg-server-service-type Sergey Trofimov
2023-03-21 21:32 ` Sergey Trofimov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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