unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 3dfcab797c89f7c1d70ac04f0b8fdf7c8866bda4 4417 bytes (raw)
name: gnu/machine.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 David Thompson <davet@gnu.org>
;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.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 machine)
  #:use-module (gnu system)
  #:use-module (guix derivations)
  #:use-module (guix monads)
  #:use-module (guix records)
  #:use-module (guix store)
  #:use-module ((guix utils) #:select (source-properties->location))
  #:export (environment-type
            environment-type?
            environment-type-name
            environment-type-description
            environment-type-location

            machine
            machine?
            this-machine

            machine-system
            machine-environment
            machine-configuration
            machine-display-name

            build-machine
            deploy-machine
            machine-remote-eval))

;;; Commentary:
;;;
;;; This module provides the types used to declare individual machines in a
;;; heterogeneous Guix deployment. The interface allows users of specify system
;;; configurations and the means by which resources should be provisioned on a
;;; per-host basis.
;;;
;;; Code:

\f
;;;
;;; Declarations for resources that can be provisioned.
;;;

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

  ;; Interface to the environment type's deployment code. Each procedure
  ;; should take the same arguments as the top-level procedure of this file
  ;; that shares the same name. For example, 'machine-remote-eval' should be
  ;; of the form '(machine-remote-eval machine exp)'.
  (machine-remote-eval environment-type-machine-remote-eval) ; procedure
  (deploy-machine      environment-type-deploy-machine)      ; procedure

  ;; Metadata.
  (name        environment-type-name)       ; symbol
  (description environment-type-description ; string
               (default #f))
  (location    environment-type-location    ; <location>
               (default (and=> (current-source-location)
                               source-properties->location))
               (innate)))

\f
;;;
;;; Declarations for machines in a deployment.
;;;

(define-record-type* <machine> machine
  make-machine
  machine?
  this-machine
  (system        machine-system)       ; <operating-system>
  (environment   machine-environment)  ; symbol
  (configuration machine-configuration ; configuration object
                 (default #f)))        ; specific to environment

(define (machine-display-name machine)
  "Return the host-name identifying MACHINE."
  (operating-system-host-name (machine-system machine)))

(define (build-machine machine)
  "Monadic procedure that builds the system derivation for MACHINE and returning
a list containing the path of the derivation file and the path of the derivation
output."
  (let ((os (machine-system machine)))
    (mlet* %store-monad ((osdrv (operating-system-derivation os))
                         (_ ((store-lift build-derivations) (list osdrv))))
      (return (list (derivation-file-name osdrv)
                    (derivation->output-path osdrv))))))

(define (machine-remote-eval machine exp)
  "Evaluate EXP, a gexp, on MACHINE. Ensure that all the elements EXP refers to
are built and deployed to MACHINE beforehand."
  (let ((environment (machine-environment machine)))
    ((environment-type-machine-remote-eval environment) machine exp)))

(define (deploy-machine machine)
  "Monadic procedure transferring the new system's OS closure to the remote
MACHINE, activating it on MACHINE and switching MACHINE to the new generation."
  (let ((environment (machine-environment machine)))
    ((environment-type-deploy-machine environment) machine)))

debug log:

solving 3dfcab797 ...
found 3dfcab797 in https://yhetil.org/guix-patches/87a7dx9tog.fsf_-_@sdf.lonestar.org/ ||
	https://yhetil.org/guix-patches/87y31gs4k5.fsf_-_@sdf.lonestar.org/

applying [1/1] https://yhetil.org/guix-patches/87a7dx9tog.fsf_-_@sdf.lonestar.org/
diff --git a/gnu/machine.scm b/gnu/machine.scm
new file mode 100644
index 000000000..3dfcab797

Checking patch gnu/machine.scm...
Applied patch gnu/machine.scm cleanly.

skipping https://yhetil.org/guix-patches/87y31gs4k5.fsf_-_@sdf.lonestar.org/ for 3dfcab797
index at:
100644 3dfcab797c89f7c1d70ac04f0b8fdf7c8866bda4	gnu/machine.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).