guix-commits
[Top][All Lists]
Advanced

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

branch master updated: images: wsl2: Create XDG_RUNTIME_DIR on first log


From: guix-commits
Subject: branch master updated: images: wsl2: Create XDG_RUNTIME_DIR on first login.
Date: Mon, 26 Dec 2022 03:35:02 -0500

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new c50cd1bbec images: wsl2: Create XDG_RUNTIME_DIR on first login.
c50cd1bbec is described below

commit c50cd1bbece27097456242f246f89c053e7cc1a2
Author: dan <i@dan.games>
AuthorDate: Wed Nov 9 04:05:53 2022 +0800

    images: wsl2: Create XDG_RUNTIME_DIR on first login.
    
    * gnu/system/images/wsl2.scm (wsl-boot-program): Create XDG_RUNTIME_DIR on
    first login and set it.
    
    Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
 gnu/system/images/wsl2.scm | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gnu/system/images/wsl2.scm b/gnu/system/images/wsl2.scm
index 80c2e775b4..d9aaa1a271 100644
--- a/gnu/system/images/wsl2.scm
+++ b/gnu/system/images/wsl2.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
+;;; Copyright © 2022 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -75,7 +76,11 @@ USER."
          (let* ((pw (getpw #$user))
                 (shell (passwd:shell pw))
                 (sudo #+(file-append sudo "/bin/sudo"))
-                (args (cdr (command-line))))
+                (args (cdr (command-line)))
+                (uid (passwd:uid pw))
+                (gid (passwd:gid pw))
+                (runtime-dir (string-append "/run/user/"
+                                            (number->string uid))))
            ;; Save the value of $PATH set by WSL.  Useful for finding
            ;; Windows binaries to run with WSL's binfmt interop.
            (setenv "WSLPATH" (getenv "PATH"))
@@ -88,9 +93,15 @@ USER."
                   MS_REMOUNT
                   #:update-mtab? #f)
 
+           ;; Create XDG_RUNTIME_DIR for the login user.
+           (unless (file-exists? runtime-dir)
+             (mkdir runtime-dir)
+             (chown runtime-dir uid gid))
+           (setenv "XDG_RUNTIME_DIR" runtime-dir)
+
            ;; Start login shell as user.
            (apply execl sudo "sudo"
-                  "--preserve-env=WSLPATH"
+                  "--preserve-env=WSLPATH,XDG_RUNTIME_DIR"
                   "-u" #$user
                   "--"
                   shell "-l" args))))))



reply via email to

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