From a79fb3393170e9c49c2c753b903b630124770056 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 4 Mar 2017 16:31:30 +0000 Subject: Add memcached package and service --- gnu/local.mk | 2 + gnu/packages/memcached.scm | 47 +++++++++++++++++++++++ gnu/services/memcached.scm | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 gnu/packages/memcached.scm create mode 100644 gnu/services/memcached.scm diff --git a/gnu/local.mk b/gnu/local.mk index ca415ec48f..b42665fbd2 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -250,6 +250,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/maths.scm \ %D%/packages/mc.scm \ %D%/packages/mcrypt.scm \ + %D%/packages/memcached.scm \ %D%/packages/messaging.scm \ %D%/packages/mingw.scm \ %D%/packages/mg.scm \ @@ -416,6 +417,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/lirc.scm \ %D%/services/mail.scm \ %D%/services/mcron.scm \ + %D%/services/memcached.scm \ %D%/services/messaging.scm \ %D%/services/networking.scm \ %D%/services/nfs.scm \ diff --git a/gnu/packages/memcached.scm b/gnu/packages/memcached.scm new file mode 100644 index 0000000000..17dcca0515 --- /dev/null +++ b/gnu/packages/memcached.scm @@ -0,0 +1,47 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Christopher Baines +;;; +;;; 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 . + +(define-module (gnu packages memcached) + #:use-module (guix packages) + #:use-module (guix build-system gnu) + #:use-module (guix download) + #:use-module (gnu packages libevent) + #:use-module (gnu packages cyrus-sasl) + #:use-module ((guix licenses) #:prefix license:)) + +(define-public memcached + (package + (name "memcached") + (version "1.4.35") + (source + (origin + (method url-fetch) + (uri (string-append + "https://memcached.org/files/memcached-" version ".tar.gz")) + (sha256 + (base32 "0xll8rhinv30f6qpbr5zqdw2nfsk20ha382j00v0yv50bb4mm0gl")))) + (build-system gnu-build-system) + (inputs + `(("libevent" ,libevent) + ("cyrus-sasl" ,cyrus-sasl))) + (home-page "https://memcached.org/") + (synopsis "In memory caching service") + (description "Memcached is a in memory key value store. It has a small +and generic API, and was originally intended for use with dynamic web +applications.") + (license license:bsd-3))) diff --git a/gnu/services/memcached.scm b/gnu/services/memcached.scm new file mode 100644 index 0000000000..9e4b536a96 --- /dev/null +++ b/gnu/services/memcached.scm @@ -0,0 +1,94 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Christopher Baines +;;; +;;; 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 . + +(define-module (gnu services memcached) + #:use-module (gnu packages admin) + #:use-module (gnu packages memcached) + #:use-module (gnu services shepherd) + #:use-module (gnu services) + #:use-module (gnu system shadow) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (guix modules) + #:use-module (ice-9 match) + #:export (memcached-service-type + + + memcached-configuration + memcached-configuration? + memcached-configuration-memecached + memcached-configuration-interfaces + memcached-configuration-tcp-port + memcached-configuration-udp-port)) + +;;; +;;; Memcached +;;; + +(define-record-type* + memcached-configuration make-memcached-configuration + memcached-configuration? + (memcached memcached-configuration-memcached ; + (default memcached)) + (interfaces memcached-configuration-interfaces + (default '("127.0.0.1"))) + (tcp-port memcached-configuration-tcp-port + (default 11211)) + (udp-port memcached-configuration-udp-port + (default 11211)) + (additional-options memcached-configuration-additional-options + (default '()))) + +(define %memcached-accounts + (list (user-group (name "memcached") (system? #t)) + (user-account + (name "memcached") + (group "memcached") + (system? #t) + (comment "Memcached server user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define memcached-shepherd-service + (match-lambda + (($ memcached interfaces tcp-port udp-port + additional-options) + (with-imported-modules (source-module-closure + '((gnu build shepherd))) + (list (shepherd-service + (provision '(memcached)) + (documentation "Run the Memcached daemon.") + (requirement '(user-processes loopback)) + (modules '((gnu build shepherd))) + (start #~(make-forkexec-constructor + `(#$(file-append memcached "/bin/memcached") + "-l" #$(string-join interfaces ",") + "-p" #$(number->string tcp-port) + "-U" #$(number->string udp-port) + "-u" "memcached" + ,#$@additional-options) + #:log-file "/var/log/memcached")) + (stop #~(make-kill-destructor)))))))) + +(define memcached-service-type + (service-type (name 'memcached) + (extensions + (list (service-extension shepherd-root-service-type + memcached-shepherd-service) + (service-extension account-service-type + (const %memcached-accounts)))))) -- cgit v1.2.3