;; This is an operating system configuration generated
;; by the graphical installer.

(use-modules
  (gnu)
  (nongnu packages linux)
  (gnu packages)
  (guix packages)
  (guix profiles)
  (srfi srfi-1)
  (pkill9 services fhs)
  (pkill9 utils))

(use-service-modules
  cups
  desktop
  networking
  ssh
  xorg)

(define (manifest->packages manifest)
  "Return the list of packages in MANIFEST."
  (filter-map (lambda (entry)
                (let ((item (manifest-entry-item entry)))
                  (if (package? item) item #f)))
              (manifest-entries manifest)))

(define fhs-packages
  (append (list (package-output->package (@ (gnu packages gcc) gcc-7) "lib"))
          (manifest->packages
           (specifications->manifest
            (list
             "libxcomposite" "libxtst" "libxaw" "libxt" "libxrandr" "libxext" "libx11"
             "libxfixes" "glib" "gtk+" "gtk+@2" "bzip2" "zlib" "gdk-pixbuf" "libxinerama"
             "libxdamage" "libxcursor" "libxrender" "libxscrnsaver" "libxxf86vm"
             "libxi" "libsm" "libice" "gconf" "freetype" "curl" "nspr" "nss" "fontconfig"
             "cairo" "pango" "expat" "dbus" "cups" "libcap" "sdl2" "libusb" "dbus-glib"
             "atk" "eudev" "network-manager" "pulseaudio" "openal" "alsa-lib" "mesa"

             "libxmu" "libxcb" "glu" "util-linux" "libogg" "libvorbis" "sdl" "sdl2-image"
             "glew" "openssl" "libidn" "tbb" "flac" "freeglut" "libjpeg" "libpng" "libpng@1.2"
             "libsamplerate" "libmikmod" "libtheora" "libtiff" "pixman" "speex" "sdl-image"
             "sdl-ttf" "sdl-mixer" "sdl2-ttf" "sdl2-mixer" "gstreamer" "gst-plugins-base"
             "glu" "libcaca" "libcanberra" "libgcrypt" "libvpx"
             ;;"librsvg" ;; currently requires compiling, but shouldn't, it's being weird
             "libxft"
             "libvdpau" "gst-plugins-ugly" "libdrm" "xkeyboard-config" "libpciaccess"
             "ffmpeg@3.4" "libpng" "libgpg-error" "sqlite" "libnotify"

             "fuse" "e2fsprogs" "p11-kit" "xz" "keyutils" "xcb-util-keysyms" "libselinux"
             "ncurses" "jack" "jack2" "vulkan-loader")))))

(operating-system
 (kernel linux)
 (firmware (list linux-firmware))
 (locale "en_GB.utf8")
 (timezone "Europe/Paris")
 (keyboard-layout (keyboard-layout "us" "intl"))
 (host-name "odyssey-guix")
 (users (cons* (user-account
                 (name "mat")
                 (comment "Mathieu")
                 (group "users")
                 (home-directory "/home/mat")
                 (supplementary-groups
                   '("wheel" "netdev" "audio" "video")))
               %base-user-accounts))
 (packages
   (append
     (list (specification->package "awesome")
           (specification->package "i3-gaps")
           (specification->package "i3status")
           (specification->package "dmenu")
           (specification->package "st")
           (specification->package "kitty")
           (specification->package "rofi")
           (specification->package "nss-certs"))
     %base-packages))
 (services
   (append
     (list (service xfce-desktop-service-type)
           (service openssh-service-type
                    (openssh-configuration
                     (x11-forwarding? #t)
                     (port-number 31422)
                     (password-authentication? #f)))
           (service tor-service-type)
           (service cups-service-type)
           (bluetooth-service #:auto-enable? #t)
           (service fhs-binaries-compatibility-service-type
             (fhs-configuration
              (lib-packages fhs-packages)
              (additional-special-files
               `(;; QT apps fail to recieve keyboard input unless they find this hardcoded path.
                 ("/usr/share/X11/xkb"
                  ,(file-append
                    (canonical-package
                     (@ (gnu packages xorg) xkeyboard-config))
                    "/share/X11/xkb"))
                 ;; Chromium component of electron apps break without fontconfig configuration here.
                 ("/etc/fonts" ,"/run/current-system/profile/etc/fonts")))))
           (set-xorg-configuration
             (xorg-configuration
               (keyboard-layout keyboard-layout))))
     %desktop-services))
 (bootloader
   (bootloader-configuration
     (bootloader grub-efi-bootloader)
     (targets (list "/boot/efi"))
     (keyboard-layout keyboard-layout)))
 (swap-devices
   (list (swap-space
           (target
             (uuid "165c9852-d080-4d84-918b-f7e781dbe820")))))
 (mapped-devices
   (list (mapped-device
           (source
             (uuid "5766c046-17c0-4d98-8d9a-e79f0272034c"))
           (target "encrypted-guix")
           (type luks-device-mapping))))
 (file-systems
   (cons* (file-system
            (mount-point "/")
            (device "/dev/mapper/encrypted-guix")
            (type "btrfs")
            (dependencies mapped-devices))
          (file-system
            (mount-point "/boot/efi")
            (device (uuid "9648-C9A8" 'fat32))
            (type "vfat"))
          %base-file-systems)))