mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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>
This commit is contained in:
parent
9369c1ccf4
commit
c50cd1bbec
1 changed files with 13 additions and 2 deletions
|
@ -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 @@ (define (wsl-boot-program 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 @@ (define (wsl-boot-program 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))))))
|
||||
|
|
Loading…
Reference in a new issue