;;; -*- mode: scheme -*-

(use-modules (gnu)
             (nonguix)
             (rosenthal)
             (rosenthal services keyboard)
             (rosenthal services shellutils)
             (gnu home services fontutils)
             (gnu home services shells)
             (gnu packages fcitx5)
             (gnu packages gnome-xyz)
             (gnu packages shells))

(define %my-keyboard-layout
  (keyboard-layout "us"))

(define %my-user
  (user-account
    (name "alice")
    ;; Initial password: test
    ;; Change your password via `passwd' after logged in.
    (password (crypt "test" "$6$abc"))
    (group "users")
    (supplementary-groups '("wheel" "audio" "video"))
    (shell (file-append fish "/bin/fish"))))

(define %my-home
  (home-environment
    (packages (specifications->packages
               '(;; Desktop, see also `%rosenthal-skeletons'.
                 "niri"
                 "dconf"
                 "wl-clipboard"
                 "xdg-desktop-portal-gnome"
                 "xdg-desktop-portal-gtk"
                 "xdg-utils"
                 "imv"                ;image viewer
                 "wezterm"            ;terminal emulator
                 "xwayland-satellite" ;rootless XWayland support

                 ;; File manager.
                 "exo"
                 "file-roller"
                 "thunar"
                 "thunar-archive-plugin"
                 "thunar-media-tags-plugin"
                 "thunar-volman"
                 "tumbler"

                 ;; Web browser.
                 "librewolf"
                 "ublock-origin-icecat"

                 ;; Text editors, see also `%rosenthal-skeletons'.
                 "emacs-pgtk"
                 "neovim"

                 "emacs-no-littering"
                 ;; Enhancements to the default interface.
                 "emacs-helpful"
                 "emacs-mwim"
                 ;; Completion.
                 "emacs-corfu"
                 "emacs-orderless"
                 "emacs-vertico"
                 ;; Guile hacking.
                 "emacs-flycheck"
                 "emacs-flycheck-guile"
                 "emacs-geiser"
                 "emacs-geiser-guile"
                 "emacs-parinfer-rust-mode"
                 ;; Theming.
                 "emacs-doom-modeline"
                 ;; Fonts.
                 "font-adobe-source-serif"
                 "font-google-noto-emoji"
                 "font-sarasa-gothic"
                 "font-victor-mono"
                 "fontconfig"
                 ;; Other useful packages.
                 "emacs-edit-indirect"
                 "emacs-evil"
                 "emacs-guix"
                 "emacs-magit"
                 "emacs-markdown-mode"

                 ;; Fonts.
                 "font-adobe-source-serif"
                 "font-google-noto"
                 "font-google-noto-emoji"
                 "font-nerd-symbols"
                 "font-sarasa-gothic"
                 "font-victor-mono")))
    (services
     (cons* (service home-fish-service-type)
            (service home-keyboard-service-type %my-keyboard-layout)

            (service home-noctalia-shell-service-type)
            (service home-polkit-gnome-service-type)

            ;; Default cursor theme.
            (service home-theme-service-type
              (home-theme-configuration
                (packages (list qogir-icon-theme))
                (icon-theme "Qogir")
                (cursor-theme "Qogir")))

            ;; Input method.
            (service home-fcitx5-service-type
              (home-fcitx5-configuration
                (gtk-im-module? #t)
                (qt-im-module? #t)
                (themes
                 (list fcitx5-material-color-theme))
                (input-method-editors
                 (list fcitx5-anthy
                       fcitx5-chewing
                       fcitx5-chinese-addons
                       fcitx5-hangul
                       fcitx5-rime
                       fcitx5-skk
                       fcitx5-unikey))))

            %rosenthal-desktop-home-services))))

(define %my-os
  (operating-system
    (host-name "antelope")
    (timezone "Europe/Paris")
    (locale "en_US.utf8")
    (keyboard-layout %my-keyboard-layout)

    (kernel linux)
    (firmware (cons* linux-firmware %base-firmware))

    ;; Use the UEFI variant of GRUB with the EFI System
    ;; Partition mounted on /boot/efi.
    (bootloader
      (bootloader-configuration
        (bootloader grub-efi-bootloader)
        (targets '("/boot/efi"))
        (keyboard-layout %my-keyboard-layout)))

    ;; Assume the target root file system is labelled "my-root",
    ;; and the EFI System Partition has UUID 1234-ABCD.
    (file-systems
     (cons* (file-system
              (device (file-system-label "my-root"))
              (mount-point "/")
              (type "ext4"))
            (file-system
              (device (uuid "1234-ABCD" 'fat))
              (mount-point "/boot/efi")
              (type "vfat"))
            %base-file-systems))

    (skeletons %rosenthal-skeletons)

    (users
     (cons* %my-user
            (user-account
              (inherit %root-account)
              ;; Don't initialize password for root.
              (password #f))
            %base-user-accounts))

    (packages
     (append (specifications->packages
              '(;; CLI utilities.
                "curl"
                "file"
                "git"
                "gnupg"
                "mosh"
                "rsync"
                "unzip"
                ;; Provide Wayland session for the login manager.
                "niri"))
             %base-packages))

    (services
     (cons* (service guix-home-service-type
              `((,(user-account-name %my-user) ,%my-home)))

            %rosenthal-desktop-services/tuigreet))))

((compose
  ;; (nonguix-transformation-nvidia)
  (nonguix-transformation-guix)
  (rosenthal-transformation-guix))
 %my-os)
