summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Paśnikowski <marek@marekpasnikowski.pl>2024-07-27 23:12:59 +0200
committerMarek Paśnikowski <marek@marekpasnikowski.pl>2024-07-28 15:30:23 +0200
commit4f2d79d26d540b24006b7b9f46ac7a3a8d7f44f1 (patch)
tree5e5601a7c22b11e0274f7c821c8bb8bad1fd6903
parent5f0277a30d9800a72784a011109c13d09ae008c3 (diff)
refactor!(update): modernize the function code
-rw-r--r--suweren/home.scm4
-rw-r--r--suweren/update.scm140
2 files changed, 94 insertions, 50 deletions
diff --git a/suweren/home.scm b/suweren/home.scm
index 289ac9a..4817c9b 100644
--- a/suweren/home.scm
+++ b/suweren/home.scm
@@ -36,7 +36,7 @@
;; string ->
;; (record service)
-(define-public (%suweren-home-services system user)
+(define-public (%suweren-home-services host-name*)
(let* ((packages (list gnupg
librewolf))
@@ -48,7 +48,7 @@
home-profile-service-type
packages))
(shepherd (service home-shepherd-service-type))
- (update-commands* (update-commands system user)))
+ (update-commands* (update-commands host-name*)))
(list bash
dbus
pipewire
diff --git a/suweren/update.scm b/suweren/update.scm
index 90c60f6..8da35ad 100644
--- a/suweren/update.scm
+++ b/suweren/update.scm
@@ -1,54 +1,98 @@
(define-module (suweren update)
+ ;; home-bash-extension
+ ;; home-bash-service-type
#:use-module (gnu home services shells)
+
+ ;; simple-service
#:use-module (gnu services))
-(define-public (update-commands system user)
- (let* ((and "&& ")
- (delete-home-generations "guix home delete-generations 7d ; ")
- (delete-roots "sudo guix gc -d 7d ")
- (delete-system-generations "sudo guix system delete-generations 7d ; ")
- (guile-load-path "GUILE_LOAD_PATH='$HOME/Szablony/distribution:$HOME/Szablony/deployment' ")
- (pull-guix "guix pull ")
- (reconfigure-home (string-append "guix home reconfigure -e "
- "'((@ (users "
- user
- ") "
- user
- "-home-environment) \""
- system
- "\")' "))
- (reconfigure-system (string-append "sudo guix system reconfigure -e "
- "'(@ (systems "
- system
- " system-configuration) "
- system
- ")' "))
-
- (collect-garbage (string-append delete-home-generations
- delete-system-generations
- delete-roots))
- (test-home (string-append guile-load-path
- reconfigure-home))
- (test-system (string-append guile-load-path
- reconfigure-system))
- (update-system (string-append pull-guix
- and
- reconfigure-system
- and
- reconfigure-home
- and
- collect-garbage))
-
- (aliases `(("collect-garbage" . ,collect-garbage)
- ("pull-guix" . ,pull-guix)
- ("reconfigure-home" . ,reconfigure-home)
- ("reconfigure-system" . ,reconfigure-system)
- ("test-home" . ,test-home)
- ("test-system" . ,test-system)
- ("update-system" . ,update-system)))
-
- (value (home-bash-extension (aliases aliases))))
-
+;; string
+(define and*
+ " && ")
+
+;; string
+(define delete-garbage
+ "sudo guix gc -d 7d")
+
+;; string
+(define delete-home-generations
+ "guix home delete-generations 7d")
+
+;; string
+(define delete-system-generations
+ "sudo guix system delete-generations 7d")
+
+;; string
+(define guile-load-path
+ "GUILE_LOAD_PATH='$HOME/Szablony/distribution:$HOME/Szablony/deployment'")
+
+;; string
+(define pull-guix
+ "guix pull")
+
+;; string
+(define collect-garbage
+ (string-append delete-home-generations
+ and*
+ delete-system-generations
+ and*
+ delete-garbage))
+
+;; string ->
+;; string
+(define (system-definition host-name*)
+ (string-append "'(@ (systems "
+ host-name*
+ " system-configuration) "
+ host-name*
+ ")'"))
+
+;; string ->
+;; string
+(define (reconfigure-system system-definition*)
+ (string-append "sudo guix system reconfigure -e "
+ system-definition*))
+
+;; string ->
+;; string
+(define (test-update reconfigure-system*)
+ (string-append guile-load-path
+ " "
+ reconfigure-system*))
+
+;; string ->
+;; string
+(define (update-system reconfigure-system*)
+ (string-append pull-guix
+ and*
+ reconfigure-system*
+ and*
+ collect-garbage))
+
+;; string ->
+;; string ->
+;; string ->
+;; alist
+(define (aliases reconfigure-system*
+ test-update*
+ update-system*)
+ `(("collect-garbage" . ,collect-garbage)
+ ("pull-guix" . ,pull-guix)
+ ("reconfigure-system" . ,reconfigure-system*)
+ ("test-system" . ,test-update*)
+ ("update-system" . ,update-system*)))
+
+;; string ->
+;; record service
+(define-public (update-commands host-name*)
+ (let* ((system-definition* (system-definition host-name*))
+ (reconfigure-system* (reconfigure-system system-definition*))
+ (test-update* (test-update reconfigure-system*))
+ (update-system* (update-system reconfigure-system*))
+ (aliases* (aliases reconfigure-system*
+ test-update*
+ update-system*))
+ (service-extension* (home-bash-extension (aliases aliases*))))
(simple-service 'update-commands
home-bash-service-type
- value)))
+ service-extension*)))