Skip to content

Commit

Permalink
Use readwise in emacs
Browse files Browse the repository at this point in the history
  • Loading branch information
peel committed Apr 22, 2024
1 parent 483d8fe commit c10d133
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
extraModules = [
./modules/nixos/setup
{
peel.secrets.enable = false;
virtualisation.host.pkgs = nixpkgs.legacyPackages.aarch64-darwin;
nixpkgs.config.pkgs = nixpkgs.legacyPackages.aarch64-linux.pkgs;
virtualisation.sharedDirectories = {
Expand Down
7 changes: 4 additions & 3 deletions modules/common/setup/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ in {

nix = {
package = pkgs.nixUnstable;
binaryCaches = builtins.map (x: x.url) caches;
binaryCachePublicKeys = builtins.map (x: x.key) caches;
settings.substituters = builtins.map (x: x.url) caches;
settings.trusted-public-keys = builtins.map (x: x.key) caches;
settings.trusted-substituters = builtins.map (x: x.url) caches;
gc = {
automatic = true;
options = "--delete-older-than 30d";
};
extraOptions = ''
experimental-features = nix-command flakes
experimental-features = nix-command flakes auto-allocate-uids configurable-impure-env
builders = @/etc/nix/machines
builders-use-substitutes = true
'';
};
time.timeZone = "Europe/Warsaw";
environment.systemPackages = [pkgs._1password];
}
56 changes: 30 additions & 26 deletions modules/common/setup/emacs/default.el
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
:bind (("C-x C-b" . consult-buffer)
("C-s" . consult-line)
("C-c C-r" . consult-ripgrep)
("M-g i" . consult-imenu)
([remap switch-to-buffer] . consult-buffer))
:config
(recentf-mode +1)
Expand Down Expand Up @@ -263,7 +264,7 @@
("C-c C-l S" . eglot-reconnect)
("C-c C-l q" . eglot-shutdown)
("C-c C-l h" . flymake-show-project-diagnostics)))
:after (envrc)
:after (:all envrc inheritenv)
:config
(advice-add 'eglot :before #'envrc-reload)
(defun peel/eglot-imports ()
Expand All @@ -286,7 +287,9 @@
(typescript-mode . eglot-ensure)
(haskell-mode . eglot-ensure)
(rust-mode . eglot-ensure)
(go-mode . eglot-ensure)))
(rustic-mode . eglot-ensure)
(go-mode . eglot-ensure)
(go-ts-mode . eglot-ensure)))
(use-package eglot-booster
:after eglot
:config (eglot-booster-mode))
Expand Down Expand Up @@ -326,9 +329,14 @@
:diminish
:init (envrc-global-mode))

(use-package inheritenv
:demand
:ensure t
:diminish)

;; ....................................................................... dhall
(use-package dhall-mode
:ensure t
:ensure nil ;; disabled as it fails to build
:mode "\\.dhall\\'"
:custom (dhall-format-at-save . -1))

Expand All @@ -354,7 +362,7 @@
(use-package rustic
:ensure t
:mode ("\\.rs?\\'" . rustic-mode)
:after nix-sandbox
:after inheritenv
:config
(add-hook 'eglot--managed-mode-hook (lambda () (flymake-mode -1)))
:custom
Expand Down Expand Up @@ -445,28 +453,7 @@

(use-package org-capture
:bind ("C-C n n" . org-capture)
:custom
;; FIXME
(defun peel/org-roam-capture ()
"Create a new frame and run `org-capture'."
(interactive)
(make-frame '((name . "org-capture")
(top . 300)
(left . 700)
(width . 80)
(height . 25)))
(defun peel/delete-if-capture-frame ()
(let (this-frame-name (substring-no-properties
(cdr (assoc 'name (frame-parameters)))))
(message this-frame-name)
(if (string-equal this-frame-name "org-capture")
'delete-frame
nil)))
(select-frame-by-name "org-capture")
(delete-other-windows)
(advice-add 'org-roam-capture--finalize :after 'delete-frame)
(org-roam-capture))

:init
(setq org-capture-templates `(
("p" "Protocol" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
Expand Down Expand Up @@ -522,12 +509,29 @@
(use-package org-roam-ui
:ensure t
:after org-roam
:bind ("C-c n g" . org-roam-ui-open)
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))

(use-package readwise
:ensure t
:autoload readwise-pull
:after org-roam
:custom
(readwise-sync-db-path "~/Dropbox/Documents/roam/highlights.org")
(readwise-api-token (auth-source-pick-first-password :host "readwise.io" :user "credentials")))

(use-package auth-source-1password
:ensure t
:custom
(auth-source-1password-vault "Private")
(auth-source-1password-executable "op")
:init
(auth-source-1passworqd-enable))

(use-package gnuplot
:ensure t
:defer t)
Expand Down
8 changes: 8 additions & 0 deletions modules/common/setup/emacs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ pkgs.emacsWithPackagesFromUsePackage {
rev = "e79dea640356eb4a8ed9df3808fe73c7c6db4cc4";
sha256 = "sha256-ybNqMHCGjzT2+4OfywS7hNw551kIzwI3QqC8tU/GsQI=";
}) "eglot-booster";
readwise = elisp (pkgs.fetchFromGitHub {
owner = "wdavew";
repo = "readwise-el";
rev = "5db1374a5c9129be35f8466d53d103fb520c20c6";
sha256 = "sha256-8oe/hVh0+fLyupBYaqxT7H8RHLlkN1l+7+CJIBYqFvA=";
}) "readwise";
};
extraEmacsPackages = epkgs: with epkgs; [
eglot-booster
readwise
auth-source-1password
my-config
];
}
10 changes: 5 additions & 5 deletions modules/common/setup/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let
emacs-darwin = mkCache "https://cachix.org/api/v1/cache/emacs" "emacs.cachix.org-1:b1SMJNLY/mZF6GxQE+eDBeps7WnkT0Po55TAyzwOxTY=";
in [ nixos peel cachix nix-community nix-tools ];
in {
nix.useSandbox = !pkgs.targetPlatform.isx86;
nix.sandboxPaths = [] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
nix.settings.sandbox = !pkgs.targetPlatform.isx86;
nix.settings.extra-sandbox-paths = [] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
"/System/Library/Frameworks"
"/System/Library/PrivateFrameworks"
"/usr/lib"
Expand All @@ -24,9 +24,9 @@ in {
"/usr/bin/env"
];

nix.binaryCaches = builtins.map (x: x.url) caches;
nix.binaryCachePublicKeys = builtins.map (x: x.key) caches;
nix.trustedUsers = [ "@admin" "root" "peel" ];
nix.settings.substituters = builtins.map (x: x.url) caches;
nix.settings.trusted-public-keys = builtins.map (x: x.key) caches;
nix.settings.trusted-users = [ "@admin" "root" "peel" ];

nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfreeRedistributable = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/darwin/setup/brew.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ in {
"PopClip" = 445189367;
"Tailscale" = 1475387142;
};
cleanup = "zap";
onActivation.cleanup = "zap";
};
}
2 changes: 1 addition & 1 deletion modules/darwin/setup/wm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ in {
yabai -m rule --add app="emacs" role="AXTextField" subrole="AXStandardWindow" manage="on"
# grid="<rows>:<cols>:<start-x>:<start-y>:<width>:<height>"
# yabai -m rule --add app="emacs" role="AXTextField" subrole="AXStandardWindow" title="^${captureTitle}$" manage="off" sticky="on" grid="1:2:1:1:4:4"
yabai -m rule --add app="emacs" role="AXTextField" subrole="AXStandardWindow" title="^${captureTitle}$" manage="off" sticky="on" grid="3:4:2:3:1:1"
yabai -m rule --add app="Synology Surveillance Station Client" sticky="on" grid="4:4:3:0:1:1"
yabai -m rule --add app="Dash" manage="off"
yabai -m rule --add app="1Password" manage="off"
Expand Down

0 comments on commit c10d133

Please sign in to comment.