system: Add 'create-home-directory?' field to <user-account>.
* gnu/system/shadow.scm (<user-account>)[create-home-directory?]: New field. (user-account->gexp): Serialize it. * gnu/build/activation.scm (activate-users+groups)[activate-user]: Update 'match-lambda' pattern accordingly. Pass #:create-home? to 'ensure-user'. (add-user, modify-user, ensure-user): Add #:create-home? parameter and honor it. * doc/guix.texi (User Accounts): Document it.master
parent
3eb2fca612
commit
eb56ee027b
|
@ -7223,6 +7223,10 @@ A comment about the account, such as the account owner's full name.
|
||||||
@item @code{home-directory}
|
@item @code{home-directory}
|
||||||
This is the name of the home directory for the account.
|
This is the name of the home directory for the account.
|
||||||
|
|
||||||
|
@item @code{create-home-directory?} (default: @code{#t})
|
||||||
|
Indicates whether the home directory of this account should be created
|
||||||
|
if it does not exist yet.
|
||||||
|
|
||||||
@item @code{shell} (default: Bash)
|
@item @code{shell} (default: Bash)
|
||||||
This is a G-expression denoting the file name of a program to be used as
|
This is a G-expression denoting the file name of a program to be used as
|
||||||
the shell (@pxref{G-Expressions}).
|
the shell (@pxref{G-Expressions}).
|
||||||
|
|
|
@ -110,7 +110,8 @@ owner-writable in HOME."
|
||||||
files)))
|
files)))
|
||||||
|
|
||||||
(define* (add-user name group
|
(define* (add-user name group
|
||||||
#:key uid comment home shell password system?
|
#:key uid comment home create-home?
|
||||||
|
shell password system?
|
||||||
(supplementary-groups '())
|
(supplementary-groups '())
|
||||||
(log-port (current-error-port)))
|
(log-port (current-error-port)))
|
||||||
"Create an account for user NAME part of GROUP, with the specified
|
"Create an account for user NAME part of GROUP, with the specified
|
||||||
|
@ -139,7 +140,7 @@ properties. Return #t on success."
|
||||||
`("-G" ,(string-join supplementary-groups ","))
|
`("-G" ,(string-join supplementary-groups ","))
|
||||||
'())
|
'())
|
||||||
,@(if comment `("-c" ,comment) '())
|
,@(if comment `("-c" ,comment) '())
|
||||||
,@(if home
|
,@(if (and home create-home?)
|
||||||
(if (file-exists? home)
|
(if (file-exists? home)
|
||||||
`("-d" ,home) ; avoid warning from 'useradd'
|
`("-d" ,home) ; avoid warning from 'useradd'
|
||||||
`("-d" ,home "--create-home"))
|
`("-d" ,home "--create-home"))
|
||||||
|
@ -158,7 +159,8 @@ properties. Return #t on success."
|
||||||
#t)))))
|
#t)))))
|
||||||
|
|
||||||
(define* (modify-user name group
|
(define* (modify-user name group
|
||||||
#:key uid comment home shell password system?
|
#:key uid comment home create-home?
|
||||||
|
shell password system?
|
||||||
(supplementary-groups '())
|
(supplementary-groups '())
|
||||||
(log-port (current-error-port)))
|
(log-port (current-error-port)))
|
||||||
"Modify user account NAME to have all the given settings."
|
"Modify user account NAME to have all the given settings."
|
||||||
|
@ -186,7 +188,8 @@ logged in."
|
||||||
(zero? (system* "groupdel" name)))
|
(zero? (system* "groupdel" name)))
|
||||||
|
|
||||||
(define* (ensure-user name group
|
(define* (ensure-user name group
|
||||||
#:key uid comment home shell password system?
|
#:key uid comment home create-home?
|
||||||
|
shell password system?
|
||||||
(supplementary-groups '())
|
(supplementary-groups '())
|
||||||
(log-port (current-error-port))
|
(log-port (current-error-port))
|
||||||
#:rest rest)
|
#:rest rest)
|
||||||
|
@ -207,7 +210,8 @@ numeric gid or #f."
|
||||||
|
|
||||||
(define activate-user
|
(define activate-user
|
||||||
(match-lambda
|
(match-lambda
|
||||||
((name uid group supplementary-groups comment home shell password system?)
|
((name uid group supplementary-groups comment home create-home?
|
||||||
|
shell password system?)
|
||||||
(let ((profile-dir (string-append "/var/guix/profiles/per-user/"
|
(let ((profile-dir (string-append "/var/guix/profiles/per-user/"
|
||||||
name)))
|
name)))
|
||||||
(ensure-user name group
|
(ensure-user name group
|
||||||
|
@ -216,6 +220,7 @@ numeric gid or #f."
|
||||||
#:supplementary-groups supplementary-groups
|
#:supplementary-groups supplementary-groups
|
||||||
#:comment comment
|
#:comment comment
|
||||||
#:home home
|
#:home home
|
||||||
|
#:create-home? create-home?
|
||||||
#:shell shell
|
#:shell shell
|
||||||
#:password password)
|
#:password password)
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@
|
||||||
(default '())) ; list of strings
|
(default '())) ; list of strings
|
||||||
(comment user-account-comment (default ""))
|
(comment user-account-comment (default ""))
|
||||||
(home-directory user-account-home-directory)
|
(home-directory user-account-home-directory)
|
||||||
|
(create-home-directory? user-account-create-home-directory? ;Boolean
|
||||||
|
(default #t))
|
||||||
(shell user-account-shell ; gexp
|
(shell user-account-shell ; gexp
|
||||||
(default #~(string-append #$bash "/bin/bash")))
|
(default #~(string-append #$bash "/bin/bash")))
|
||||||
(system? user-account-system? ; Boolean
|
(system? user-account-system? ; Boolean
|
||||||
|
@ -255,6 +257,7 @@ of user '~a' is undeclared")
|
||||||
#$(user-account-supplementary-groups account)
|
#$(user-account-supplementary-groups account)
|
||||||
#$(user-account-comment account)
|
#$(user-account-comment account)
|
||||||
#$(user-account-home-directory account)
|
#$(user-account-home-directory account)
|
||||||
|
#$(user-account-create-home-directory? account)
|
||||||
,#$(user-account-shell account) ; this one is a gexp
|
,#$(user-account-shell account) ; this one is a gexp
|
||||||
#$(user-account-password account)
|
#$(user-account-password account)
|
||||||
#$(user-account-system? account)))
|
#$(user-account-system? account)))
|
||||||
|
|
Reference in New Issue