nix config
1{ user, config, pkgs, ... }:
2
3let
4 xdg_configHome = "${config.users.users.${user}.home}/.config";
5 xdg_dataHome = "${config.users.users.${user}.home}/.local/share";
6 xdg_stateHome = "${config.users.users.${user}.home}/.local/state"; in
7{
8
9 # Raycast script so that "Run Emacs" is available and uses Emacs daemon
10 "${xdg_dataHome}/bin/emacsclient" = {
11 executable = true;
12 text = ''
13 #!/bin/zsh
14 #
15 # Required parameters:
16 # @raycast.schemaVersion 1
17 # @raycast.title Run Emacs
18 # @raycast.mode silent
19 #
20 # Optional parameters:
21 # @raycast.packageName Emacs
22 # @raycast.icon ${xdg_dataHome}/img/icons/Emacs.icns
23 # @raycast.iconDark ${xdg_dataHome}/img/icons/Emacs.icns
24
25 if [[ $1 = "-t" ]]; then
26 # Terminal mode
27 ${pkgs.emacs}/bin/emacsclient -t $@
28 else
29 # GUI mode
30 ${pkgs.emacs}/bin/emacsclient -c -n $@
31 fi
32 '';
33 };
34
35 # Script to import Drafts into Emacs org-roam
36 "${xdg_dataHome}/bin/import-drafts" = {
37 executable = true;
38 text = ''
39 #!/bin/sh
40
41 for f in ${xdg_stateHome}/drafts/*
42 do
43 if [[ ! "$f" =~ "done" ]]; then
44 echo "Importing $f"
45 filename="$(head -c 10 $f)"
46 output="${xdg_dataHome}/org-roam/daily/$filename.org"
47 echo '\n' >> "$output"
48 tail -n +3 $f >> "$output"
49 mv $f done
50 fi
51 done
52 '';
53 };
54}