help-guix
[Top][All Lists]
Advanced

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

writable skeleton files in sub-directories


From: Reza Alizadeh Majd
Subject: writable skeleton files in sub-directories
Date: Wed, 14 Oct 2020 22:34:59 +0330

Hi Guix,

working on a new service for `lxqt-desktop`, I need to provide a series
of predefined configurations for that. so I defined a series of
skeleton files and add them to the service using `account-service-type`
extension.

the problem is that when the location of a skeleton file is a path other
than user's home directory, it will be created in read-only mode.

I also tried  to use `computed-file` and `chmod` the created file. but
the permission still didn't apply.

I also provided a test configuration to reproduce this issue:

--8<---------------cut here---------------start------------->8---
(use-modules (gnu) (guix records))

;;
;; Test service definition
;;
(define-record-type* <test-config> test-config
  make-test-config test-config?)

(define (test-skeletons)
  `((".config/test"
     ,(computed-file "test-config-dir"
                     (with-imported-modules
                      '((guix build utils))
                      #~(begin
                          (use-modules (guix build utils))
                          (mkdir-p #$output)))))
    (".config/test/foo.conf" ,(plain-file "foo.conf" "this is readonly"))
    (".config/test/bar.conf"
     ,(computed-file "bar.conf"
                     (with-imported-modules
                      '((guix build utils))
                      #~(begin
                          (use-modules (guix build utils))
                          (call-with-output-file #$output
                            (lambda (port)
                              (display "this is also readonly" port)))
                          (chmod #$output #o644)))))
    ("baz.txt" ,(plain-file "baz.txt" "this is writable"))))

(define test-service-type
  (service-type
   (name 'test-service)
   (extensions
    (list (service-extension account-service-type
                             (const (test-skeletons)))))
   (default-value (test-config))
   (description "test service for skeleton files issue")))

;;
;; Operating system definition
;;
(operating-system
  (host-name "guix.local")
  (timezone "Asia/Tehran")
  (locale "en_US.utf8")

  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (target "/dev/sda")))
  (file-systems (cons (file-system
                        (device (file-system-label "my-root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))

  (services (cons* (service test-service-type)
                   %base-services)))
--8<---------------cut here---------------end--------------->8---


running the above configuration, `~/baz.txt` is writable, but
`foo.conf` and `bar.conf` files which are located in `~/.config/test/`
are both read-only:

--8<---------------cut here---------------start------------->8---
root@guix ~# ll
...
-rw-r--r-- 1 root root 29 Oct 14 21:18 baz.txt
...

root@guix ~# ll .config/test/
...
-r--r--r-- 1 root root   20 Oct 14 21:18 foo.conf
-r--r--r-- 1 root root   40 Oct 14 21:18 bar.conf
...
--8<---------------cut here---------------end--------------->8---

is there anything that I might be missed in definition of skeleton
files? or it might be a bug in creation of skeleton files.


Regards, 
Reza

-- 
Reza Alizadeh Majd
PantherX Team
https://www.pantherx.org/



reply via email to

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