user.scm 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (gnu installer user)
  19. #:use-module (guix records)
  20. #:use-module (srfi srfi-1)
  21. #:export (<user>
  22. user
  23. make-user
  24. user-name
  25. user-real-name
  26. user-group
  27. user-home-directory
  28. user-password
  29. users->configuration))
  30. (define-record-type* <user>
  31. user make-user
  32. user?
  33. (name user-name)
  34. (real-name user-real-name
  35. (default ""))
  36. (group user-group
  37. (default "users"))
  38. (password user-password)
  39. (home-directory user-home-directory))
  40. (define (users->configuration users)
  41. "Return the configuration field for USERS."
  42. (define (user->sexp user)
  43. `(user-account
  44. (name ,(user-name user))
  45. (comment ,(user-real-name user))
  46. (group ,(user-group user))
  47. (home-directory ,(user-home-directory user))
  48. (supplementary-groups '("wheel" "netdev"
  49. "audio" "video"))))
  50. `((users (cons*
  51. ,@(filter-map (lambda (user)
  52. ;; Do not emit a 'user-account' form for "root".
  53. (and (not (string=? (user-name user) "root"))
  54. (user->sexp user)))
  55. users)
  56. %base-user-accounts))))