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)))))
python-llvmlite: Use specific commit for llvm patch URLs....As this commit [1] appears to affect the patches, including the v0.30.0 tag (so the tag must have been changed). 1: https://github.com/numba/llvmlite/commit/cdd99deb32f9d48aadb0f7407fb8ad06f6a8ce6c * gnu/packages/llvm.scm (python-llvmlite)[inputs]: Use a specific commit for the patches. Christopher Baines 2020-07-03gnu: Add lld....* gnu/packages/llvm.scm (lld): New variable. Jakub Kądziołka 2020-07-03gnu: llvm-9: Backport patch to fix miscompilation for big-endian targets....* gnu/packages/llvm.scm (llvm-9)[source]: Add new patch. * gnu/packages/patches/llvm-9-fix-bitcast-miscompilation.patch: New file. * gnu/local.mk (dist_patch_DATA): Register new file. Jakub Kądziołka 2020-07-03gnu: llvm-9: Backport patches to fix miscompilations....* gnu/packages/llvm.scm (llvm-9)[source]: Add new patches. * gnu/packages/patches/llvm-9-fix-lpad-miscompilation.patch, gnu/packages/patches/llvm-9-fix-scev-miscompilation.patch: New files. * gnu/local.mk (dist_patch_DATA): Register new patches. Jakub Kądziołka 2020-05-28gnu: clang: Build 'clang-tools-extra'....* gnu/packages/llvm.scm (clang-from-llvm): Add #:tools-extra. Add 'output' field. In 'inputs', add TOOLS-EXTRA when it's given. In 'arguments', add 'add-tools-extra' and 'move-extra-tools' phases when TOOLS-EXTRA is given. Ludovic Courtès 2020-05-22gnu: llvm: Remove unused 'package-elisp-from-package' procedure....This private procedure had been unused since 3a3d4d9d545028cda846ae827a60249f7162d34e. * gnu/packages/llvm.scm (package-elisp-from-package): Remove. Ludovic Courtès 2020-05-02Merge branch 'master' into core-updatesMarius Bakke 2020-05-02gnu: llvm-for-extempore: Update to 3.8....* gnu/packages/llvm.scm (llvm-for-extempore): Update to 3.8. [source]: Use upstream patched source. * gnu/packages/patches/llvm-for-extempore.patch: Delete due to source being already patched. * gnu/local.mk (dist_patch_DATA): Remove it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Giacomo Leidi 2020-04-24Merge branch 'master' into core-updatesMarius Bakke 2020-04-24gnu: llvm: Add 10.0.0....* gnu/packages/llvm.scm (llvm-10, clang-runtime-10, clang-10) (clang-toolchain-10, llvm-9, clang-runtime-9, clang-9) (clang-toolchain-9): New variables. (llvm, clang, clang-runtime, clang-toolchain): Redefine as aliases to the '-9' bindings. * gnu/packages/patches/clang-10.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Ludovic Courtès 2020-04-13Merge branch 'master' into core-updatesMarius Bakke 2020-04-12gnu: emacs-clang-format: Fix grammar of "allows to filter" to "filters"....* gnu/packages/llvm (emacs-clang-format): Fix grammar. Vagrant Cascadian 2020-03-26llvm: Add support for the Hurd....* gnu/packages/llvm.scm (system->llvm-target): Use X86 for i586 (i.e., the Hurd). Jan Nieuwenhuizen 2020-03-15gnu: libcxx: Hide GCC's C++ headers during the build process....* gnu/packages/llvm.scm (libcxx)[arguments]: New field. Marius Bakke 2020-03-15gnu: clang: Switch to 'C_INCLUDE_PATH' & co....* gnu/packages/llvm.scm (clang-from-llvm)[native-search-paths]: Remove "CPATH", and add "C_INCLUDE_PATH" and "CPLUS_INCLUDE_PATH". Marius Bakke 2020-03-05gnu: clang-runtime: Fix build with glibc 2.31....* gnu/packages/patches/clang-runtime-3.8-libsanitizer-mode-field.patch, gnu/packages/patches/clang-runtime-3.9-libsanitizer-mode-field.patch, gnu/packages/patches/clang-runtime-9-libsanitizer-mode-field.patch: New files. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/llvm.scm (clang-runtime, clang-runtime-8, clang-runtime-7, clang-runtime-6, clang-runtime-3.9.1, clang-runtime-3.8, clang-runtime-3.7): Add the respective patches. Marius Bakke 2020-03-05gnu: clang-runtime: Adjust for CPLUS_INCLUDE_PATH changes....* gnu/packages/llvm.scm (clang-runtime-from-llvm)[arguments]: Add #:modules and #:phases. Marius Bakke 2020-03-04Merge branch 'master' into core-updatesMarius Bakke 2020-02-26gnu: clang: Move version conditionals out of the builder....* gnu/packages/llvm.scm (clang-from-llvm)[arguments]: Rewrite phase 'set-glibc-file-names' to use VERSION>=? from (guix utils) and splice in the relevant build code, instead of doing the comparison at build time. Marius Bakke 2020-02-26gnu: clang: Fix C++ search path handling on non-x86_64....* gnu/packages/llvm.scm (clang-from-llvm)[arguments]: Add phase 'add-missing-triplets'. Marius Bakke 2020-02-25gnu: clang-runtime-3.5: Fix build....* gnu/packages/llvm.scm (clang-runtime-3.5) [inputs]: Add libtirpc. [arguments]: Add phase to find rpc headers. Ricardo Wurmus 2020-02-24gnu: LLVM: Promote LLVM 9 to the default 'llvm' package....* gnu/packages/llvm.scm (llvm-8): Rename to ... (llvm): ... this. Update to 9.0.1. [license]: Change to ASL2.0. (clang-runtime-from-llvm)[license]: Inherit from LLVM. (clang-from-llvm)[license]: Conditionally choose license based on version. (llvm-9, clang-runtime-8, clang-8, clang-toolchain-8): New public variables. (llvm-7): Inherit from LLVM-8 (for the license change). (llvm-6): Inherit from LLVM-7. (llvm-3.9.1): Inherit from LLVM-6. (llvm-3.8): Inherit from LLVM-3.9.1. (llvm-3.7): Inherit from LLVM-3.8. (llvm-3.6): Inherit from LLVM-3.7. (llvm-3.5): Inherit from LLVM-3.6. (libcxx, libclc, libomp): Update to 9.0.1. Marius Bakke 2020-02-24gnu: clang: Use the correct CLANG-RUNTIME for versions 6 and 7....* gnu/packages/llvm.scm (clang-7): Use CLANG-RUNTIME-7. (clang-6): Use CLANG-RUNTIME-6. Marius Bakke 2020-02-24gnu: Reorganize llvm.scm....* gnu/packages/llvm.scm (libcxx, libclc, libomp, libcxx-6): Move package definitions below the various LLVM/Clang variants. Marius Bakke 2020-02-24gnu: clang@9: Update to 9.0.1....* gnu/packages/llvm.scm (llvm-9): Update to 9.0.1. clang-runtime-9, clang-9): Update hashes. Marius Bakke 2020-02-24gnu: llvm: Add helper procedure for constructing download URLs.......in preparation for LLVM 9.0.1 which is no longer hosted on llvm.org. * gnu/packages/llvm.scm (llvm-download-uri): New procedure. (llvm-8, clang-runtime-from-llvm, clang-from-llvm, libcxx, libomp, llvm-9, llvm-7, llvm-6, libcxx-6, llvm-3.9.1, llvm-3.8, llvm-3.7, llvm-3.6, llvm-3.5)[source](uri): Use it. Marius Bakke 2020-02-24gnu: clang@9: Fix search path handling....* gnu/packages/patches/clang-9.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/llvm.scm (clang-9): Add #:patches. Marius Bakke