diff --git a/kompot/home/services/mako.scm b/kompot/home/services/mako.scm index bb77cc4..0ed0f4b 100644 --- a/kompot/home/services/mako.scm +++ b/kompot/home/services/mako.scm @@ -1,75 +1,362 @@ -(define-module (g1smo home services mako) - #:use-module (ice-9 match) +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 ( +;;; +;;; This file is not 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 . + +;;; Source: https://git.sr.ht/~whereiseveryone/guixrus/tree/master/item/guixrus/home/services/mako.scm#L351 + +(define-module (kompot home services mako) #:use-module (gnu home services) + #:use-module (gnu home services shepherd) #:use-module (gnu services configuration) - #:use-module (guix packages) + #:autoload (gnu packages glib) (dbus) + #:autoload (gnu packages wm) (mako) + #:autoload (gnu packages xdisorg) (redshift) #: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)) + #:use-module (guix records) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match) + #:export (home-mako-section + %home-mako-default-section + %home-mako-default-grouped-section + home-mako-configuration + home-mako-service-type)) -(define-configuration/no-serialization home-mako-configuration - (package - (package mako) - "mako package to use") - (config - (alist '()) - "")) +(define-record-type* + home-mako-section make-home-mako-section + home-mako-section? -(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))))) + (if-app-name home-mako-if-app-name ;string | #f + (default #f)) + (if-app-icon home-mako-if-app-icon ;string | #f + (default #f)) + (if-summary home-mako-if-summary ;string | #f + (default #f)) + (if-summary-regex? home-mako-if-summary-regex? ;boolean + (default #f)) + (if-body home-mako-if-body ;string | #f + (default #f)) + (if-body-regex? home-mako-if-body-regex? ;boolean + (default #f)) + (if-urgency home-mako-if-urgency ;'low | 'normal | 'critical | #f + (default #f)) + (if-category home-mako-if-category ;string | #f + (default #f)) + (if-desktop-entry home-mako-if-desktop-entry ;string | #f + (default #f)) + (if-actionable? home-mako-if-actionable? ;boolean | '() + (default '())) + (if-expiring? home-mako-if-expiring? ;boolean | '() + (default '())) + (if-mode home-mako-if-mode ;string | #f + (default #f)) + (if-grouped? home-mako-if-grouped? ;boolean | '() + (default '())) + (if-group-index home-mako-if-group-index ;integer | #f + (default #f)) + (if-hidden? home-mako-if-hidden? ;boolean | '() + (default '())) + (if-output home-mako-if-output ;string | #f + (default #f)) + (if-anchor home-mako-if-anchor ;'top-right | 'top-center | 'top-left | 'bottom-right | 'bottom-center | 'bottom-left | 'center-right | 'center-left | 'center | #f + (default #f)) - (define (serialize-key key) - (if (list? key) - (serialize-criteria key) - (string-append (maybe-object->string key) "="))) + (on-button-left home-mako-on-button-left ;#f | 'default | 'dismiss | 'dismiss-all | 'dismiss-group | list of (file-like | string) + (default 'default)) + (on-button-middle home-mako-on-button-middle ;#f | 'default | 'dismiss | 'dismiss-all | 'dismiss-group | string | list of (file-like | string) + (default #f)) + (on-button-right home-mako-on-button-right ;#f | 'default | 'dismiss | 'dismiss-all | 'dismiss-group | list of (file-like | string) + (default 'dismiss)) + (on-touch home-mako-on-touch ;#f | 'default | 'dismiss | 'dismiss-all | 'dismiss-group | list of (file-like | string) + (default 'dismiss)) + (on-notify home-mako-on-notify ;#f | 'default | 'dismiss | 'dismiss-all | 'dismiss-group | list of (file-like | string) + (default #f)) - (define (serialize-val val) - (cond - ((or (number? val) (symbol? val)) (maybe-object->string val)) - ((list? val) (serialize-mako-config val)) - (else val))) + (font home-mako-font ;string + (default "monospace")) + (font-size home-mako-font-size ;number + (default 10)) - (define (serialize-field key val) - (let ((val (serialize-val val)) - (key (serialize-key key))) - (list key val))) + (background-color home-mako-background-color ;string + (default "285577FF")) + (text-color home-mako-text-color ;string + (default "FFFFFFFF")) - (generic-serialize-alist - (lambda args (flatten (interpose args))) - serialize-field - config)) + (width home-mako-width ;integer + (default 300)) + (height home-mako-height ;integer + (default 100)) + (outer-margin home-mako-outer-margin ;list of integer + (default '(0))) + (margin home-mako-margin ;list of integer + (default '(10))) + (padding home-mako-padding ;list of integer + (default '(5))) -(define (add-mako-configuration config) - (let ((cfg (home-mako-configuration-config config))) - `(("mako/config" - ,(apply mixed-text-file - "config" - (serialize-mako-config cfg)))))) + (border-size home-mako-border-size ;integer + (default 2)) + (border-color home-mako-border-color ;string + (default "4C7899FF")) + (border-radius home-mako-border-radius ;integer + (default 0)) -(define add-mako-package - (compose list home-mako-configuration-package)) + (progress-color home-mako-progress-color ;string + (default "5588AAFF")) + (progress-style home-mako-progress-style ;'over | 'source + (default 'over)) + + (icons? home-mako-icons? ;boolean + (default #t)) + (max-icon-size home-mako-max-icon-size ;integer + (default 64)) + (icon-path home-mako-icon-path ;list of string + (default '())) + (icon-location home-mako-icon-location ;'left | 'right | 'top | 'bottom + (default 'left)) + + (markup? home-mako-markup? ;boolean + (default #t)) + (actions? home-mako-actions? ;boolean + (default #t)) + (history? home-mako-history? ;boolean + (default #t)) + (invisible? home-mako-invisible? ;boolean + (default #f)) + + (format home-mako-format + (default "%s\\n%b")) + (text-alignment home-mako-text-alignment ;'left | 'center | 'right + (default 'left)) + + (default-timeout home-mako-default-timeout ;integer + (default 0)) + (ignore-timeout? home-mako-ignore-timeout? ;boolean + (default #f)) + + (group-by home-mako-group-by ;list of string + (default #f)) + (max-visible home-mako-max-visible ;integer + (default #f)) + + (output home-mako-output ;string + (default #f)) + (layer home-mako-layer ;'background | 'bottom | 'top | 'overlay + (default 'top)) + (anchor home-mako-anchor ;'top-right | 'top-center | 'top-left | 'bottom-right | 'bottom-center | 'bottom-left | 'center-right | 'center-left | 'center + (default #f))) + +(define (home-mako-configuration-header-attributes section) + (define (boolean-clause name field) + (let ((value (field section))) + (cond ((null? value) '()) + (value (list "!" name " ")) + (else (list name))))) + + (define (string-clause name field) + (let ((value (field section))) + (if value + (list name "=\"" value "\" ") + '()))) + + (define (symbol-clause name field) + (if (field section) + (string-clause name (compose symbol->string field)) + '())) + + (define (number-clause name field) + (if (field section) + (string-clause name (compose number->string field)) + '())) + + (append (string-clause "app-name" home-mako-if-app-name) + (string-clause "app-icon" home-mako-if-app-icon) + (string-clause (if (home-mako-if-summary-regex? section) + "summary~" + "summary") + home-mako-if-summary) + (string-clause (if (home-mako-if-body-regex? section) + "body~" + "body") + home-mako-if-body) + (symbol-clause "urgency" home-mako-if-urgency) + (string-clause "category" home-mako-if-category) + (string-clause "desktop-entry" home-mako-if-desktop-entry) + (boolean-clause "actionable" home-mako-if-actionable?) + (boolean-clause "expiring" home-mako-if-expiring?) + (string-clause "mode" home-mako-if-mode) + (boolean-clause "grouped" home-mako-if-grouped?) + (number-clause "group-index" home-mako-if-group-index) + (boolean-clause "hidden" home-mako-if-hidden?) + (string-clause "output" home-mako-if-output) + (symbol-clause "anchor" home-mako-if-anchor))) + +(define (home-mako-configuration-header section) + (match (home-mako-configuration-header-attributes section) + (() '()) + ((attributes ...) + (append (list "\n[ ") attributes (list "]\n"))))) + +(define (home-mako-configuration-body section) + (define (string-clause name field) + (let ((value (field section))) + (if value + (list name "=" (field section) "\n") + '()))) + + (define (boolean-clause name field) + (list name "=" (if (field section) "1" "0") "\n")) + + (define (number-clause name field) + (if (field section) + (string-clause name (compose number->string field)) + '())) + + (define (symbol-clause name field) + (if (field section) + (string-clause name (compose symbol->string field)) + '())) + + (define (colour-clause name field) + (string-clause name (compose (cute string-append "#" <>) + field))) + + (define (directional-clause name field) + (if (field section) + (string-clause name (compose (cute string-join <> ",") + (cute map number->string <>) + field)) + '())) + + (define (event-clause name field) + (append (list name "=") + (match (field section) + ('default (list "invoke-default-action")) + ('dismiss (list "dismiss")) + ('dismiss-all (list "dismiss-all")) + ('dismiss-group (list "dismiss-group")) + ((args ...) + (append (list "exec") + (append-map (cute list " \"" <> "\"") + args))) + (#f (list "none"))) + (list "\n"))) + + (append (event-clause "on-button-left" home-mako-on-button-left) + (event-clause "on-button-middle" home-mako-on-button-middle) + (event-clause "on-button-right" home-mako-on-button-right) + (event-clause "on-touch" home-mako-on-touch) + (event-clause "on-notify" home-mako-on-notify) + (list "font=" (home-mako-font section) " " + (number->string (home-mako-font-size section)) "\n") + (colour-clause "background-color" home-mako-background-color) + (colour-clause "text-color" home-mako-text-color) + (number-clause "width" home-mako-width) + (number-clause "height" home-mako-height) + (directional-clause "outer-margin" home-mako-outer-margin) + (directional-clause "margin" home-mako-margin) + (directional-clause "padding" home-mako-padding) + (number-clause "border-size" home-mako-border-size) + (colour-clause "border-color" home-mako-border-color) + (number-clause "border-radius" home-mako-border-radius) + (list "progress-color=" + (symbol->string (home-mako-progress-style section)) + " #" (home-mako-progress-color section) "\n") + (boolean-clause "icons" home-mako-icons?) + (number-clause "max-icon-size" home-mako-max-icon-size) + (string-clause "icon-path" + (compose (cute string-join <> ":") + home-mako-icon-path)) + (symbol-clause "icon-location" home-mako-icon-location) + (boolean-clause "markup" home-mako-markup?) + (boolean-clause "actions" home-mako-actions?) + (boolean-clause "history" home-mako-history?) + (boolean-clause "invisible" home-mako-invisible?) + (string-clause "format" home-mako-format) + (symbol-clause "text-alignment" home-mako-text-alignment) + (number-clause "default-timeout" home-mako-default-timeout) + (boolean-clause "ignore-timeout" home-mako-ignore-timeout?) + (boolean-clause "ignore-timeout" home-mako-ignore-timeout?) + (if (home-mako-group-by section) + (string-clause "group-by" + (compose (cute string-join <> ",") + home-mako-group-by)) + '()) + (number-clause "max-visible" home-mako-max-visible) + (string-clause "output" home-mako-output) + (symbol-clause "layer" home-mako-layer) + (symbol-clause "anchor" home-mako-anchor))) + +(define (home-mako-configuration-section section) + (append (home-mako-configuration-header section) + (home-mako-configuration-body section))) + +(define %home-mako-default-section (home-mako-section)) + +(define %home-mako-default-grouped-section + (home-mako-section + (if-grouped? #t) + (format "(%g) %s\\n%b"))) + +(define-record-type* + home-mako-configuration make-home-mako-configuration + home-mako-configuration? + + (mako home-mako-configuration-mako ;file-like + (default mako)) + (sections home-mako-configuration-sections ;list of + (default (list %home-mako-default-section + %home-mako-default-grouped-section))) + + (max-history home-mako-configuration-max-history ;integer + (default 5)) + (sort home-mako-configuration-sort ;'time | 'priority + (default 'time)) + (sort-order home-mako-configuration-sort-order ;'ascending | 'descending + (default 'descending))) + +(define (home-mako-configuration-file config) + (apply mixed-text-file "mako-config" + (append (list "max-history=" + (number->string + (home-mako-configuration-max-history config)) + "\n" + "sort=" + (match (home-mako-configuration-sort-order config) + ('ascending "+") + ('descending "-")) + (symbol->string (home-mako-configuration-sort config)) + "\n") + (append-map home-mako-configuration-section + (home-mako-configuration-sections config))))) + +(define (home-mako-xdg-configuration-files config) + `(("mako/config" ,(home-mako-configuration-file config)))) + +(define (home-mako-profile-packages config) + (list (home-mako-configuration-mako config))) (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))) + (list (service-extension home-xdg-configuration-files-service-type + home-mako-xdg-configuration-files) + (service-extension home-profile-service-type + home-mako-profile-packages))) (default-value (home-mako-configuration)) - (description ""))) + (description + "Install and configure the @code{mako} notification daemon."))) diff --git a/kompot/home/services/pipewire.scm b/kompot/home/services/pipewire.scm deleted file mode 100644 index 9e68907..0000000 --- a/kompot/home/services/pipewire.scm +++ /dev/null @@ -1,87 +0,0 @@ -(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"))) diff --git a/kompot/home/services/sound.scm b/kompot/home/services/sound.scm deleted file mode 100644 index 9a8563a..0000000 --- a/kompot/home/services/sound.scm +++ /dev/null @@ -1,124 +0,0 @@ -;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2023 Ludovic Courtès -;;; Copyright © 2023 Brian Cully -;;; -;;; 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)))) - diff --git a/kompot/packages/forgejo.scm b/kompot/packages/forgejo.scm deleted file mode 100644 index 6ea3d19..0000000 --- a/kompot/packages/forgejo.scm +++ /dev/null @@ -1,80 +0,0 @@ -(define-module (kompot packages forgejo) - #:use-module ((guix licenses) #:prefix license:) - #:use-module (guix packages) - #:use-module (guix download) - #:use-module (guix gexp) - #:use-module (guix build-system go) - #:use-module (gnu packages bash) - #:use-module (gnu packages node) - #:use-module (gnu packages version-control)) - -(define-public forgejo - (package - (name "forgejo") - (version "1.19.3-0") - (source (origin - (method url-fetch) - (uri (string-append "https://codeberg.org/forgejo/forgejo" - "/archive/v" version ".tar.gz")) - (sha256 - (base32 "0492psgag2v8kaipzbhq8w6p8d72sfxpblj8j37fpz0pzf2kxriz")))) - (build-system go-build-system) - (arguments - `(#:install-source? #f - #:phases - (modify-phases %standard-phases - (add-after 'patch-source-shebangs 'unpatch-example-shebangs - ;; If we don't do this then git repos created with this version of - ;; gitea will use the build environment's bash for the different - ;; git repo hooks. - (lambda _ - (substitute* - (find-files "src/integrations/gitea-repositories-meta" - "(\\.sample|gitea|(post|pre)-receive|update)") - (("#!/gnu/store/.*/bin/bash") "#!/bin/bash") - (("#!/gnu/store/.*/bin/sh") "#!/bin/sh")))) - (add-before 'build 'prepare-build - (lambda _ - (setenv "TAGS" "bindata sqlite sqlite_unlock_notify") - (setenv "GITEA_WORK_DIR" "/var/lib/gitea"))) - (replace 'build - (lambda _ - (with-directory-excursion "src" - (invoke "make" "build") - (invoke "make" "generate-manpage")))) - (replace 'check - (lambda* (#:key tests? #:allow-other-keys) - (when tests? - (unsetenv "GITEA_WORK_DIR") - (with-directory-excursion "src" - (invoke "make" "test-backend") - ;; Gitea requires git with lfs support to run tests. - ;(invoke "make" "test-sqlite") - (invoke "make" "test-sqlite-migration"))))) - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out"))) - (with-directory-excursion "src" - (invoke "make" "install") - (install-file "man/man1/gitea.1.gz" - (string-append out "/share/man/man1")))))) - (add-after 'install 'wrap-program - (lambda* (#:key outputs inputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (bin (string-append out "/bin/gitea"))) - (wrap-program bin - `("PATH" ":" prefix - (,(dirname (search-input-file inputs "/bin/git"))))))))))) - (native-inputs - (list node-14.19.3)) - (inputs - (list bash-minimal - git)) - (home-page "https://gitea.io/") - (synopsis "Self-hosted git service") - (description "Gitea is an open-source forge software package for hosting -software development version control using Git as well as other collaborative -features like bug tracking, wikis and code review.") - (properties - '((release-monitoring-url . "https://github.com/go-gitea/gitea/releases"))) - (license license:expat)))