Uporabne home storitve

main
Jurij Podgoršek 2024-03-07 11:48:45 +01:00
parent e14f407ab8
commit c839a2c66b
4 changed files with 293 additions and 0 deletions

View File

@ -0,0 +1,7 @@
;;; SPDX-License-Identifier: GPL-3.0-or-later
;; -*- mode: scheme; -*-
(channel
(version 0)
(url "https://git.kompot.si/kompot/guix-paketi")
(branch "main"))

View File

@ -0,0 +1,75 @@
(define-module (g1smo home services mako)
#:use-module (ice-9 match)
#:use-module (gnu home services)
#:use-module (gnu services configuration)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (gnu packages wm)
#:use-module (guix import utils)
#:use-module ((gnu home-services-utils) #:select (maybe-object->string))
#:export (home-mako-service-type
home-mako-configuration))
(define-configuration/no-serialization home-mako-configuration
(package
(package mako)
"mako package to use")
(config
(alist '())
""))
(define (serialize-mako-config config)
(define* (serialize-criteria criteria #:optional (res '()))
(match criteria
((field value)
(format #f "[~a]\n"
(string-join
(cons (format #f "~a=\"~a\"" field value) res))))
((field value . rest)
(serialize-criteria
rest
(cons (format #f "~a=\"~a\"" field value) res)))))
(define (serialize-key key)
(if (list? key)
(serialize-criteria key)
(string-append (maybe-object->string key) "=")))
(define (serialize-val val)
(cond
((or (number? val) (symbol? val)) (maybe-object->string val))
((list? val) (serialize-mako-config val))
(else val)))
(define (serialize-field key val)
(let ((val (serialize-val val))
(key (serialize-key key)))
(list key val)))
(generic-serialize-alist
(lambda args (flatten (interpose args)))
serialize-field
config))
(define (add-mako-configuration config)
(let ((cfg (home-mako-configuration-config config)))
`(("mako/config"
,(apply mixed-text-file
"config"
(serialize-mako-config cfg))))))
(define add-mako-package
(compose list home-mako-configuration-package))
(define home-mako-service-type
(service-type
(name 'home-mako)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
add-mako-configuration)
(service-extension
home-profile-service-type
add-mako-package)))
(default-value (home-mako-configuration))
(description "")))

View File

@ -0,0 +1,87 @@
(define-module (g1smo home services pipewire)
#:use-module (guix gexp)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd))
(define (home-pipewire-files-service _)
`(("alsa/asoundrc"
,(mixed-text-file
"asoundrc"
#~(string-append
"<"
#$(file-append
pipewire
"/share/alsa/alsa.conf.d/50-pipewire.conf")
">\n<"
#$(file-append
pipewire
"/share/alsa/alsa.conf.d/99-pipewire-default.conf")
">\n"
"
pcm_type.pipewire {
lib " #$(file-append
pipewire
"/lib/alsa-lib/libasound_module_pcm_pipewire.so") "
}
ctl_type.pipewire {
lib " #$(file-append
pipewire
"/lib/alsa-lib/libasound_module_ctl_pipewire.so") "
}
")))))
(define (home-pipewire-shepherd-service _)
(list
(shepherd-service
(requirement '(dbus))
(provision '(pipewire))
(stop #~(make-kill-destructor))
(start #~(make-forkexec-constructor
(list #$(file-append pipewire "/bin/pipewire")))))
(shepherd-service
(requirement '(pipewire))
(provision '(wireplumber))
(stop #~(make-kill-destructor))
(start #~(make-forkexec-constructor
(list #$(file-append wireplumber "/bin/wireplumber")))))
#;
(shepherd-service
(requirement '(pipewire))
(provision '(pipewire-media-session))
(stop #~(make-kill-destructor))
(start #~(make-forkexec-constructor
(list
#$(file-append
pipewire-media-session
"/bin/pipewire-media-session")
"-c"
#$(file-append
pipewire-media-session
"/share/pipewire/media-session.d/media-session.conf")))))
(shepherd-service
(requirement '(pipewire))
(provision '(pipewire-pulse))
(stop #~(make-kill-destructor))
(start #~(make-forkexec-constructor
(list #$(file-append pipewire "/bin/pipewire-pulse")))))))
(define-public home-pipewire-service-type
(service-type
(name 'home-pipewire)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
home-pipewire-files-service)
(service-extension
home-shepherd-service-type
home-pipewire-shepherd-service)
(service-extension
home-profile-service-type
(const (list pipewire pulseaudio)))))
(default-value #f)
(description "run pipewire and stuff")))

View File

@ -0,0 +1,124 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2023 Brian Cully <bjc@spork.org>
;;;
;;; This file is part of GNU Guix.
;;;
(define-module (g1smo home services sound)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (gnu home services xdg)
#:use-module (gnu packages linux)
#:use-module (gnu services configuration)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (home-pipewire-configuration home-pipewire-service-type))
;;;
;;; PipeWire support.
;;;
(define-configuration/no-serialization home-pipewire-configuration
(pipewire
(file-like pipewire)
"The PipeWire package to use.")
(wireplumber
(file-like wireplumber)
"The WirePlumber package to use.")
(enable-pulseaudio?
(boolean #t)
"When true, enable PipeWire's PulseAudio emulation support, allowing
PulseAudio clients to use PipeWire transparently."))
(define (home-pipewire-shepherd-service config)
(shepherd-service
(documentation "PipeWire media processing.")
(provision '(pipewire))
(requirement '(dbus))
(start #~(make-forkexec-constructor
(list #$(file-append
(home-pipewire-configuration-pipewire config)
"/bin/pipewire"))))
(stop #~(make-kill-destructor))))
(define (home-pipewire-pulseaudio-shepherd-service config)
(shepherd-service
(documentation "Drop-in PulseAudio replacement service for PipeWire.")
(provision '(pipewire-pulseaudio))
(requirement '(pipewire))
(start #~(make-forkexec-constructor
(list #$(file-append
(home-pipewire-configuration-pipewire config)
"/bin/pipewire-pulse"))))
(stop #~(make-kill-destructor))))
(define (home-wireplumber-shepherd-service config)
(shepherd-service
(documentation "WirePlumber session management for PipeWire.")
(provision '(wireplumber))
(requirement '(pipewire))
(start #~(make-forkexec-constructor
(list #$(file-append
(home-pipewire-configuration-wireplumber config)
"/bin/wireplumber"))))
(stop #~(make-kill-destructor))))
(define (home-pipewire-shepherd-services config)
(cons* (home-pipewire-shepherd-service config)
(home-wireplumber-shepherd-service config)
(if (home-pipewire-configuration-enable-pulseaudio? config)
(list (home-pipewire-pulseaudio-shepherd-service config))
'())))
(define (home-pipewire-asoundrc config)
(mixed-text-file
"asoundrc"
#~(string-append
"<"
#$(file-append
(home-pipewire-configuration-pipewire config)
"/share/alsa/alsa.conf.d/50-pipewire.conf")
">\n"
"<"
#$(file-append
(home-pipewire-configuration-pipewire config)
"/share/alsa/alsa.conf.d/99-pipewire-default.conf")
">\n"
"pcm_type.pipewire {\n"
" lib \""
#$(file-append
(home-pipewire-configuration-pipewire config)
"/lib/alsa-lib/libasound_module_pcm_pipewire.so")
"\"\n}\n"
"ctl_type.pipewire {\n"
" lib \""
#$(file-append
(home-pipewire-configuration-pipewire config)
"/lib/alsa-lib/libasound_module_ctl_pipewire.so")
"\"\n}\n")))
(define home-pipewire-disable-pulseaudio-auto-start
(plain-file "client.conf" "autospawn = no"))
(define (home-pipewire-xdg-configuration config)
(cons* `("alsa/asoundrc" ,(home-pipewire-asoundrc config))
(if (home-pipewire-configuration-enable-pulseaudio? config)
`(("pulse/client.conf"
,home-pipewire-disable-pulseaudio-auto-start))
'())))
(define home-pipewire-service-type
(service-type
(name 'pipewire)
(extensions
(list (service-extension home-shepherd-service-type
home-pipewire-shepherd-services)
(service-extension home-xdg-configuration-files-service-type
home-pipewire-xdg-configuration)))
(description
"Start essential PipeWire services.")
(default-value (home-pipewire-configuration))))