about summary refs log tree commit diff
path: root/init/nixos.el
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-06-22T08·29+0200
committerVincent Ambo <github@tazj.in>2019-02-10T20·43+0100
commit4fe8d78dbb16dbec2b8c173a5142b4b14927fd28 (patch)
tree481bd47ba446167088f846f9eeb383a847dc7d86 /init/nixos.el
parentf0dfc8b06de568e57050510a5b56fcbb725a6733 (diff)
refactor: Begin moving package configuration to use-package
This is the first in a series of commits for refactoring my
configuration to make use of jwiegley's use-package.

In the previous layout of the configuration there were some questions
around what settings go into which file, but in the end it is all just
related to which packages are being configured (besides settings
related to global Emacs behaviour).

This commit introduces use-package forms for all currently used
packages (which are still installed via Nix, not via package.el) but
does not yet clean up the rest of the configuration in a suitable way.

Note that this version introduces a bug in which the configuration of
telephone line is not correctly initialised after package setup.
Diffstat (limited to 'init/nixos.el')
-rw-r--r--init/nixos.el133
1 files changed, 63 insertions, 70 deletions
diff --git a/init/nixos.el b/init/nixos.el
index 431ba705c3bc..f3cefea7f391 100644
--- a/init/nixos.el
+++ b/init/nixos.el
@@ -6,11 +6,6 @@
 (require 'f)
 (require 'dash)
 
-(defvar is-nixos
-  (let ((os-f "/etc/os-release"))
-    (s-contains?
-     "NixOS" (if (f-file? os-f) (f-read os-f)))))
-
 (defun pulseaudio-ctl (cmd)
   (shell-command (concat "pulseaudio-ctl " cmd))
   (message "Volume command: %s" cmd))
@@ -38,70 +33,68 @@
               (0 "eDP1")
               ,(-map (lambda (n) (list n "eDP1")) (number-sequence 6 9)))))
 
-(if is-nixos
-    (progn
-      (message "Running on NixOS, configuring ExWM.")
-      (require 'exwm)
-      (require 'exwm-config)
-
-      (fringe-mode 3)
-
-      (setq exwm-workspace-number 10)
-      ;; Make class name the buffer name
-      (add-hook 'exwm-update-class-hook
-                (lambda ()
-                  (exwm-workspace-rename-buffer exwm-class-name)))
-
-      ;; 's-r': Reset
-      (exwm-input-set-key (kbd "s-r") #'exwm-reset)
-      ;; 's-w': Switch workspace
-      (exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
-      ;; 's-N': Switch to certain workspace
-      (dotimes (i 10)
-        (exwm-input-set-key (kbd (format "s-%d" i))
-                            `(lambda ()
-                               (interactive)
-                               (exwm-workspace-switch-create ,i))))
-
-      ;; Launch applications with completion (dmenu style!)
-      (exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
-      (exwm-input-set-key (kbd "s-p") #'ivy-password-store)
-      (exwm-input-set-key (kbd "C-s-p") '(lambda ()
-                                           (interactive)
-                                           (ivy-password-store "~/.aprila-secrets")))
-
-      ;; Toggle between line-mode / char-mode
-      (exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
-
-      ;; Volume keys
-      (exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
-      (exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
-      (exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
-
-      ;; Brightness keys
-      (exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
-      (exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
-      (exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
-
-      ;; Line-editing shortcuts
-      (exwm-input-set-simulation-keys
-       '(([?\C-d] . delete)
-         ([?\C-w] . ?\C-c)))
-
-      ;; Enable EXWM
-      (exwm-enable)
-
-      ;; Show time in the mode line
-      (display-time-mode)
-
-      ;; Configure xrandr when running on laptop
-      (when (equal (shell-command-to-string "hostname") "adho\n")
-        (require 'exwm-randr)
-        (setq exwm-randr-workspace-output-plist (generate-randr-config))
-        (exwm-randr-enable))
-
-      ;; Let buffers move seamlessly between workspaces
-      (setq exwm-workspace-show-all-buffers t)
-      (setq exwm-layout-show-all-buffers t)))
+(use-package exwm
+  :hook ((exwm-update-class . (lambda ()
+                                ;; Make class name the buffer name
+                                (exwm-workspace-rename-buffer exwm-class-name))))
+  :init
+  (progn
+    (require 'exwm-config)
+
+    (fringe-mode 3)
+
+    (setq exwm-workspace-number 10)
+
+    ;; 's-r': Reset
+    (exwm-input-set-key (kbd "s-r") #'exwm-reset)
+    ;; 's-w': Switch workspace
+    (exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
+    ;; 's-N': Switch to certain workspace
+    (dotimes (i 10)
+      (exwm-input-set-key (kbd (format "s-%d" i))
+                          `(lambda ()
+                             (interactive)
+                             (exwm-workspace-switch-create ,i))))
+
+    ;; Launch applications with completion (dmenu style!)
+    (exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
+    (exwm-input-set-key (kbd "s-p") #'ivy-password-store)
+    (exwm-input-set-key (kbd "C-s-p") '(lambda ()
+                                         (interactive)
+                                         (ivy-password-store "~/.aprila-secrets")))
+
+    ;; Toggle between line-mode / char-mode
+    (exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
+
+    ;; Volume keys
+    (exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
+    (exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
+    (exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
+
+    ;; Brightness keys
+    (exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
+    (exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
+    (exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
+
+    ;; Line-editing shortcuts
+    (exwm-input-set-simulation-keys
+     '(([?\C-d] . delete)
+       ([?\C-w] . ?\C-c)))
+
+    ;; Enable EXWM
+    (exwm-enable)
+
+    ;; Show time in the mode line
+    (display-time-mode)
+
+    ;; Configure xrandr when running on laptop
+    (when (equal (shell-command-to-string "hostname") "adho\n")
+      (require 'exwm-randr)
+      (setq exwm-randr-workspace-output-plist (generate-randr-config))
+      (exwm-randr-enable))
+
+    ;; Let buffers move seamlessly between workspaces
+    (setq exwm-workspace-show-all-buffers t)
+    (setq exwm-layout-show-all-buffers t)))
 
 (provide 'nixos)