mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
services: nar-herder: Add cached compression support.
* gnu/services/guix.scm (<nar-herder-cached-compression-configuration>): New record type. (nar-herder-configuration-cached-compressions, nar-herder-configuration-cached-compression-min-uses, nar-herder-configuration-cached-compression-workers, nar-herder-configuration-cached-compression-nar-source, nar-herder-cached-compression-configuration, nar-herder-cached-compression-configuration?, nar-herder-cached-compression-configuration-type, nar-herder-cached-compression-configuration-level, nar-herder-cached-compression-configuration-directory, nar-herder-cached-compression-configuration-directory-max-size): New procedures. * doc/guix.texi (Guix Services): Document this.
This commit is contained in:
parent
46c1df1eab
commit
9a5533c653
2 changed files with 118 additions and 3 deletions
|
@ -36836,6 +36836,42 @@ advertised.
|
||||||
Log level to use, specify a log level like @code{'INFO} to stop logging
|
Log level to use, specify a log level like @code{'INFO} to stop logging
|
||||||
individual requests.
|
individual requests.
|
||||||
|
|
||||||
|
@item @code{cached-compressions} (default: @code{'()})
|
||||||
|
Activate generating cached nars with different compression details from
|
||||||
|
the stored nars. This is a list of
|
||||||
|
nar-herder-cached-compression-configuration records.
|
||||||
|
|
||||||
|
@item @code{min-uses} (default: @code{3})
|
||||||
|
When cached-compressions are enabled, generate cached nars when at least
|
||||||
|
this number of requests are made for a nar.
|
||||||
|
|
||||||
|
@item @code{workers} (default: @code{2})
|
||||||
|
Number of cached nars to generate at a time.
|
||||||
|
|
||||||
|
@item @code{nar-source} (default: @code{#f})
|
||||||
|
Location to fetch nars from when computing cached compressions. By
|
||||||
|
default, the storage location will be used.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
|
@deftp {Data Type} nar-herder-cached-compression-configuration
|
||||||
|
Data type representing the cached compression configuration.
|
||||||
|
|
||||||
|
@table @asis
|
||||||
|
@item @code{type}
|
||||||
|
Type of compression to use, e.g. @code{'zstd}.
|
||||||
|
|
||||||
|
@item @code{workers} (default: @code{#f})
|
||||||
|
Level of the compression to use.
|
||||||
|
|
||||||
|
@item @code{directory} (default: @code{#f})
|
||||||
|
Location to store the cached nars. If unspecified, they will be stored
|
||||||
|
in /var/cache/nar-herder/nar/TYPE.
|
||||||
|
|
||||||
|
@item @code{directory-max-size} (default: @code{#f})
|
||||||
|
Maximum size in bytes of the directory.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,18 @@ (define-module (gnu services guix)
|
||||||
nar-herder-configuration-storage
|
nar-herder-configuration-storage
|
||||||
nar-herder-configuration-storage-limit
|
nar-herder-configuration-storage-limit
|
||||||
nar-herder-configuration-storage-nar-removal-criteria
|
nar-herder-configuration-storage-nar-removal-criteria
|
||||||
nar-herder-configuration-log-level))
|
nar-herder-configuration-log-level
|
||||||
|
nar-herder-configuration-cached-compressions
|
||||||
|
nar-herder-configuration-cached-compression-min-uses
|
||||||
|
nar-herder-configuration-cached-compression-workers
|
||||||
|
nar-herder-configuration-cached-compression-nar-source
|
||||||
|
|
||||||
|
nar-herder-cached-compression-configuration
|
||||||
|
nar-herder-cached-compression-configuration?
|
||||||
|
nar-herder-cached-compression-configuration-type
|
||||||
|
nar-herder-cached-compression-configuration-level
|
||||||
|
nar-herder-cached-compression-configuration-directory
|
||||||
|
nar-herder-cached-compression-configuration-directory-max-size))
|
||||||
|
|
||||||
;;;; Commentary:
|
;;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -828,17 +839,67 @@ (define-record-type* <nar-herder-configuration>
|
||||||
(negative-ttl nar-herder-configuration-negative-ttl
|
(negative-ttl nar-herder-configuration-negative-ttl
|
||||||
(default #f))
|
(default #f))
|
||||||
(log-level nar-herder-configuration-log-level
|
(log-level nar-herder-configuration-log-level
|
||||||
(default 'DEBUG)))
|
(default 'DEBUG))
|
||||||
|
(cached-compressions
|
||||||
|
nar-herder-configuration-cached-compressions
|
||||||
|
(default '()))
|
||||||
|
(cached-compression-min-uses
|
||||||
|
nar-herder-configuration-cached-compression-min-uses
|
||||||
|
(default 3))
|
||||||
|
(cached-compression-workers
|
||||||
|
nar-herder-configuration-cached-compression-workers
|
||||||
|
(default 2))
|
||||||
|
(cached-compression-nar-source
|
||||||
|
nar-herder-configuration-cached-compression-nar-source
|
||||||
|
(default #f)))
|
||||||
|
|
||||||
|
(define-record-type* <nar-herder-cached-compression-configuration>
|
||||||
|
nar-herder-cached-compression-configuration
|
||||||
|
make-nar-herder-cached-compression-configuration
|
||||||
|
nar-herder-cached-compression-configuration?
|
||||||
|
(type nar-herder-cached-compression-configuration-type)
|
||||||
|
(level nar-herder-cached-compression-configuration-level
|
||||||
|
(default #f))
|
||||||
|
(directory nar-herder-cached-compression-configuration-directory
|
||||||
|
(default #f))
|
||||||
|
(directory-max-size
|
||||||
|
nar-herder-cached-compression-configuration-directory-max-size
|
||||||
|
(default #f)))
|
||||||
|
|
||||||
(define (nar-herder-shepherd-services config)
|
(define (nar-herder-shepherd-services config)
|
||||||
|
(define (cached-compression-configuration->options cached-compression)
|
||||||
|
(match-record
|
||||||
|
cached-compression
|
||||||
|
<nar-herder-cached-compression-configuration>
|
||||||
|
(type level directory directory-max-size)
|
||||||
|
|
||||||
|
`(,(simple-format #f "--enable-cached-compression=~A~A"
|
||||||
|
type
|
||||||
|
(if level
|
||||||
|
(simple-format #f ":~A" level)
|
||||||
|
""))
|
||||||
|
,@(if directory
|
||||||
|
(list
|
||||||
|
(simple-format #f "--cached-compression-directory=~A=~A"
|
||||||
|
type
|
||||||
|
directory))
|
||||||
|
'())
|
||||||
|
,@(if directory-max-size
|
||||||
|
(list
|
||||||
|
(simple-format #f "--cached-compression-directory-max-size=~A=~A"
|
||||||
|
type
|
||||||
|
directory-max-size))
|
||||||
|
'()))))
|
||||||
|
|
||||||
(match-record config <nar-herder-configuration>
|
(match-record config <nar-herder-configuration>
|
||||||
(package user group
|
(package user group
|
||||||
mirror
|
mirror
|
||||||
database database-dump
|
database database-dump
|
||||||
host port
|
host port
|
||||||
storage storage-limit storage-nar-removal-criteria
|
storage storage-limit storage-nar-removal-criteria
|
||||||
ttl negative-ttl log-level)
|
ttl negative-ttl log-level
|
||||||
|
cached-compressions cached-compression-min-uses
|
||||||
|
cached-compression-workers cached-compression-nar-source)
|
||||||
|
|
||||||
(unless (or mirror storage)
|
(unless (or mirror storage)
|
||||||
(error "nar-herder: mirror or storage must be set"))
|
(error "nar-herder: mirror or storage must be set"))
|
||||||
|
@ -882,6 +943,24 @@ (define (nar-herder-shepherd-services config)
|
||||||
'())
|
'())
|
||||||
#$@(if log-level
|
#$@(if log-level
|
||||||
(list (simple-format #f "--log-level=~A" log-level))
|
(list (simple-format #f "--log-level=~A" log-level))
|
||||||
|
'())
|
||||||
|
#$@(append-map
|
||||||
|
cached-compression-configuration->options
|
||||||
|
cached-compressions)
|
||||||
|
#$@(if cached-compression-min-uses
|
||||||
|
(list (simple-format
|
||||||
|
#f "--cached-compression-min-uses=~A"
|
||||||
|
cached-compression-min-uses))
|
||||||
|
'())
|
||||||
|
#$@(if cached-compression-workers
|
||||||
|
(list (simple-format
|
||||||
|
#f "--cached-compression-workers=~A"
|
||||||
|
cached-compression-workers))
|
||||||
|
'())
|
||||||
|
#$@(if cached-compression-nar-source
|
||||||
|
(list (simple-format
|
||||||
|
#f "--cached-compression-nar-source=~A"
|
||||||
|
cached-compression-nar-source))
|
||||||
'()))
|
'()))
|
||||||
#:user #$user
|
#:user #$user
|
||||||
#:group #$group
|
#:group #$group
|
||||||
|
|
Loading…
Reference in a new issue