aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2022, 2024 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu home)
  #:use-module (gnu home services)
  #:use-module (gnu home services symlink-manager)
  #:use-module (gnu home services shells)
  #:use-module (gnu home services xdg)
  #:use-module (gnu home services fontutils)
  #:use-module (gnu services)
  #:use-module (guix records)
  #:use-module (guix diagnostics)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex)
  #:export (home-environment
            home-environment?
            this-home-environment

            home-environment-derivation
            home-environment-packages
            home-environment-user-services
            home-environment-essential-services
            home-environment-services
            home-environment-location

            home-environment-with-provenance

            home-generation-base))

;;; Comment:
;;;
;;; This module provides a <home-environment> record for managing
;;; per-user packages and configuration files in the similar way as
;;; <operating-system> do for system packages and configuration files.
;;;
;;; Code:

(define-record-type* <home-environment> home-environment
  make-home-environment
  home-environment?
  this-home-environment

  (packages           home-environment-packages            ; list of (PACKAGE OUTPUT...)
                      (default '()))

  (essential-services home-environment-essential-services  ; list of services
                      (thunked)
                      (default (home-environment-default-essential-services
                                this-home-environment)))

  (services           home-environment-user-services
                      (default '())
                      (sanitize validate-service-list))

  (location           home-environment-location            ; <location>
                      (default (and=> (current-source-location)
                                      source-properties->location))
                      (innate)))

(define (home-environment-default-essential-services he)
  "Return the list of essential services for home environment."
  (list
   (service home-run-on-first-login-service-type)
   (service home-activation-service-type)
   (service home-environment-variables-service-type)

   (service home-symlink-manager-service-type)

   (service home-fontconfig-service-type)
   (service home-xdg-base-directories-service-type)
   (service home-shell-profile-service-type)

   (service home-service-type)
   (service home-profile-service-type (home-environment-packages he))))

(define* (home-environment-services he)
  "Return all the services of home environment."
  (instantiate-missing-services
   (append (home-environment-user-services he)
           (home-environment-essential-services he))))

(define* (home-environment-derivation he)
  "Return a derivation that builds home environment."
  (let* ((services         (home-environment-services he))
         (home (fold-services services
                              #:target-type home-service-type)))
    (service-value home)))


(define (home-environment-configuration-file he)
  "Return the configuration file of HE, based on its 'location' field, or #f
if it could not be determined."
  (let ((file (and=> (home-environment-location he)
                     location-file)))
    (and file
         (or (and (string-prefix? "/" file) file)
             (search-path %load-path file)))))

(define* (home-environment-with-provenance he
                                           #:optional
                                           (config-file
                                            (home-environment-configuration-file
                                             he)))
  "Return a variant of HE that stores its own provenance information,
including CONFIG-FILE, if available.  This is achieved by adding an instance
of HOME-PROVENANCE-SERVICE-TYPE to its services."
  (home-environment
    (inherit he)
    (services (cons (service home-provenance-service-type config-file)
                    (home-environment-user-services he)))))

(define-gexp-compiler (home-environment-compiler (he <home-environment>)
                                                 system target)
  ((store-lift
    (lambda (store)
      (run-with-store store (home-environment-derivation he)
                      #:system system
                      #:target target)))))

(define %profile-generation-rx
  ;; Regexp that matches profile generation.
  (make-regexp "(.*)-([0-9]+)-link$"))

(define (home-generation-base file)
  "If FILE is a Home generation GC root such as \"guix-home-42-link\",
return its corresponding base---e.g., \"guix-home\".  Otherwise return #f.

This is similar to the 'generation-profile' procedure but applied to Home
generations."
  (match (regexp-exec %profile-generation-rx file)
    (#f #f)
    (m  (let ((profile (match:substring m 1)))
          ;; Distinguish from a "real" profile and from a system generation.
          (and (file-exists? (string-append profile "/on-first-login"))
               (file-exists? (string-append profile "/profile/manifest"))
               profile)))))
commit/po?id=ef1107e2cca9a5b6f7129d019aabac2f0e89a238'>nls: Update string translations.Ludovic Courtès 2020-11-12nls: Update translations of the manual.Ludovic Courtès 2020-11-12nls: Update translations of the manual.Julien Lepiller 2020-11-12nls: Update 'ta' translation.Julien Lepiller 2020-11-03nls: Fix Texinfo typo....* po/doc/guix-manual.de.po: Fix ‘@sasmp{}’ that broke ‘make’. Tobias Geerinckx-Rice 2020-11-03nls: Update translations of the manual.Julien Lepiller 2020-11-03nls: Internationalize command synopses as shown in 'guix help'....This is a followup to 3794ce93be8216d8378df7b808ce7f53b1e05a53. * po/guix/Makevars (XGETTEXT_OPTIONS): Add '--keyword=synopsis'. Ludovic Courtès 2020-11-01nls: Update ‘de’ cookbook translation.Florian Pelz 2020-10-31guix build: Move transformation options to (guix transformations)....* guix/transformations.scm: New file. * tests/scripts-build.scm: Rename to... * tests/transformations.scm: ... this. * Makefile.am (MODULES): Add 'guix/transformations.scm'. (SCM_TESTS): Adjust to rename. * guix/scripts/build.scm (numeric-extension?) (tarball-base-name, <downloaded-file>, download-to-store*) (compile-downloaded-file, package-with-source) (transform-package-source, evaluate-replacement-specs) (transform-package-inputs, transform-package-inputs/graft) (%not-equal, package-git-url, evaluate-git-replacement-specs) (transform-package-source-branch, transform-package-source-commit) (transform-package-source-git-url, package-dependents/spec) (package-toolchain-rewriting, transform-package-toolchain) (transform-package-with-debug-info, transform-package-tests) (%transformations, transformation-procedure, %transformation-options) (show-transformation-options-help, options->transformation) (package-transformations): Move to (guix transformations). * guix/scripts/environment.scm: Adjust accordingly. * guix/scripts/graph.scm: Likewise. * guix/scripts/install.scm: Likewise. * guix/scripts/pack.scm: Likewise. * guix/scripts/package.scm: Likewise. * guix/scripts/upgrade.scm: Likewise. * po/guix/POTFILES.in: Add 'guix/transformations.scm'. Ludovic Courtès 2020-10-30nls: Update 'es' translation.Miguel Ángel Arruga Vivas 2020-10-30nls: Update 'fr' translation of the manual.Julien Lepiller 2020-10-29nls: Update 'ru' translation of the manual.Julien Lepiller 2020-10-27nls: Update.Ludovic Courtès 2020-10-16nls: Update manual translations.Ludovic Courtès 2020-10-16nls: Update.Ludovic Courtès 2020-10-02gexp: 'local-file' warns when passed a non-literal relative file name....Fixes <https://bugs.gnu.org/43736>. Reported by Vitaliy Shatrov <guix.vits@disroot.org>. * guix/gexp.scm (%local-file): Add #:literal? and #:location. Emit a warning when LITERAL? is false and FILE is not absolute. (local-file): In the non-literal case, pass #:location and #:literal?. * po/guix/POTFILES.in: Add guix/gexp.scm. * tests/guix-system.sh: Add test for the warning. Ludovic Courtès 2020-09-29nls: Fix copyright and bug address in pot files....* po/guix/Makevars: Fix COPYRIGHT_HOLDER and MSGID_BUGS_ADDRESS. * po/packages/Makevars: idem. Julien Lepiller 2020-09-29nls: Fix documentation pot generation....* po/doc/local.mk: Fix POT_OPTIONS to properly assign copyright and define the proper license. Julien Lepiller 2020-07-27nls: Update 'fr' translation.Ludovic Courtès 2020-07-11Add 'guix git authenticate'....* guix/scripts/git.scm, guix/scripts/git/authenticate.scm, tests/guix-git-authenticate.sh: New files. * Makefile.am (MODULES): Add the *.scm files. (SH_TESTS): Add 'tests/guix-git-authenticate.sh'. * doc/guix.texi (Channels)[Specifying Channel Authorizations]: Mention 'guix git authenticate'. (Invoking guix git authenticate): New node. * po/guix/POTFILES.in: Add 'guix/scripts/git.scm' and 'guix/scripts/git/authenticate.scm'. Ludovic Courtès 2020-05-05nls: Update.Ludovic Courtès 2020-04-14nls: Update.Ludovic Courtès 2020-04-12nls: Update.Ludovic Courtès 2020-04-08installer: Add proxy support....* gnu/installer/proxy.scm: New file. * gnu/local.mk (INSTALLER_MODULES): Add it. * po/guix/POTFILES.in: Add it. * gnu/installer/newt/parameters.scm (run-proxy-page): New procedure, (run-parameters-page): add the previous procedure to the parameters menu. Mathieu Othacehe 2020-04-08installer: Turn help menu into parameters menu....* gnu/local.mk (INSTALLER_MODULES): Rename help.scm into parameters.scm. * po/guix/POTFILES.in: Ditto. * gnu/installer/record.scm (<installer>): Rename help-menu into parameter-menu and help-page into parameters-page. * gnu/installer/newt/parameters.scm: Renamed from help.scm. Update information messages. * gnu/installer/newt.scm: Update accordingly. * gnu/installer/newt/keymap.scm: Ditto. Mathieu Othacehe 2020-04-06installer: Add a help page....* gnu/installer/newt/help.scm: New file. * gnu/local.mk (INSTALLER_MODULES): Add it. * po/guix/POTFILES.in: Add it. * gnu/installer/record.scm (<installer>): Add 'help-menu' and 'help-page' fields, (installer-help-menu, installer-help-page): new exported procedures. * gnu/installer/newt.scm (init): Set the help line, (help-menu, help-page): new procedures used ... (newt-installer): ... here. * gnu/installer/newt/keymap.scm (run-layout-page): Add a context argument to differenciate the help context from the main one, (run-keymap-page): add a context argument and pass it to run-layout-page. * gnu/installer.scm (compute-keymap-step): Add a context argument and pass it to 'installer-keymap-page', (installer-steps): set the help menu and pass the appropriate context to compute-keymap-step calls, (guile-newt): update to revision 2. Mathieu Othacehe 2020-04-02nls: Add Tamil translation....* po/guix/LINGUAS: Add 'ta'. * po/guix/ta.po: New file. Julien Lepiller 2020-03-23nls: Update.Ludovic Courtès 2020-03-06doc: Fix build of German Cookbook translation....This is a follow-up to f98e83a17fa30587520e858231ec9c61f3624ecd. See <https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00095.html>. Reported there by Vagrant Cascadian <vagrant@debian.org>. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): Use correct file name. (doc-po-update-cookbook-%): Use correct PO file name. Florian Pelz 2020-02-17doc: Add German Cookbook translation....* doc/local.mk (info_TEXINFOS): Add guix-cookbook.de.texi. (TRANSLATED_INFO): Add guix-cookbook.de.texi. * po/doc/guix-cookbook.de.po: New file. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): Add guix-cookbook.de.po. Florian Pelz 2020-02-14Revert "nls: Update 'es' translation of the manual."...I believe this change breaks guix pull: ./guix.es.texi:20971: @samp missing closing brace This reverts commit d156e3fbcd6fc61a39d1d32622b90b0f8f741729. Christopher Baines 2020-02-14nls: Update 'fr' translation.Julien Lepiller 2020-02-14nls: Update 'de' translation of the manual.Julien Lepiller 2020-02-14nls: Update 'es' translation of the manual.Julien Lepiller 2020-02-14nls: Update 'pt_BR' translation.Julien Lepiller 2019-09-24Merge branch 'master' into core-updatesLudovic Courtès 2019-09-21guix package: Add 'guix show' alias....* guix/scripts/show.scm: New file. * Makefile.am (MODULES): Add it. * po/guix/POTFILES.in: Add it. * tests/guix-package-aliases.sh: Add test. * doc/guix.texi (Invoking guix package): Document it and use it in a example. Signed-off-by: Ludovic Courtès <ludo@gnu.org> zimoun 2019-09-18doc: Add Guix Cookbook....* .gitignore: Update ignore list. * Makefile.am (assert-no-store-file-names): Exclude the cookbook. * bootstrap: Generate po files for cookbook translations. * doc/guix-cookbook.texi: New file. * doc/local.mk (info_TEXINFOS): Add it; add a rule to build cookbook translations. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): New variable. (EXTRA_DIST): Add cookbook pot file and po files. (doc-po-update-cookbook-%): New target. (doc-pot-update): Also update cookbook pot file. (doc-po-update): Also update cookbook po files. Ricardo Wurmus 2019-09-06Merge branch 'master' into core-updatesMark H Weaver 2019-08-31nls: Update 'fr' translation of the manual.Julien Lepiller