From 6eb110370b664c3b373dfafbaf35585f643131c0 Mon Sep 17 00:00:00 2001 From: willemml Date: Thu, 12 Jan 2023 17:06:58 -0800 Subject: [PATCH] re-add spotify --- emacs.nix | 138 ++++++++++++++++++++++++++++++++++++------------ packages.nix | 1 + spotify-mac.nix | 42 +++++++++++++++ 3 files changed, 148 insertions(+), 33 deletions(-) create mode 100644 spotify-mac.nix diff --git a/emacs.nix b/emacs.nix index badcd9d..8bf31bf 100644 --- a/emacs.nix +++ b/emacs.nix @@ -390,31 +390,64 @@ in { (my/org-force-open-current-window))) ''; init = '' - (setq org-src-window-setup 'current-window) - (setq org-confirm-babel-evaluate nil) - (setq org-src-fontify-natively t) - (setq org-src-tab-acts-natively t) - (setq org-src-preserve-indentation t) + (defvar my/org-dir "~/Documents/org/") - (setq org-export-with-tags nil) + (require 'oc) - (setq org-publish-project-alist - '(("Root" - :base-directory "~/Documents/org/roam/" - :publishing-function org-html-publish-to-html - :publishing-directory "~/public_html" - :section-numbers nil - :with-author nil - :with-creator t - :with-toc t - :time-stamp-file nil))) + (setq org-src-window-setup 'current-window) + (setq org-confirm-babel-evaluate nil) + (setq org-src-fontify-natively t) + (setq org-src-tab-acts-natively t) + (setq org-src-preserve-indentation t) - ;; Configure HTML export - (setq org-html-validation-link nil) - (setq org-html-head-include-scripts nil) - (setq org-html-head-include-default-style nil) - (setq org-html-head "") - (setq org-html-section) + (setq org-export-with-tags nil) + + (setq org-publish-project-alist + '(("root" + :base-directory (expand-file-name my/org-dir) + :publishing-function org-html-publish-to-html + :publishing-directory (expand-file-name "~/public_html") + :section-numbers nil + + :with-author nil + :with-creator t + :with-toc t + :time-stamp-file nil))) + + ;; Configure HTML export + (setq org-html-validation-link nil) + (setq org-html-head-include-scripts nil) + (setq org-html-head-include-default-style nil) + (setq org-html-head "") + (setq org-html-section) + + (setq bibtex-completion-notes-path (expand-file-name "notes.org" my/org-dir)) + + (setq org-cite-follow-processor 'ivy-bibtex-org-cite-follow) + + (setq bibtex-completion-pdf-open-function + (lambda (fpath) + (call-process "open" nil 0 nil "-a" "/Applications/Preview.app" fpath))) + + (defun org-export-latex-no-toc (depth) + (when depth + (format "%% Org-mode is exporting headings to %s levels.\n" + depth))) + (setq org-export-latex-format-toc-function 'org-export-latex-no-toc) + + (add-to-list 'org-latex-classes + '("apa6" + "\\documentclass{apa6}" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + + (setq org-latex-pdf-process + '("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f")) + + (add-to-list 'exec-path "/Users/willem/.nix-profile/bin") ''; hook = [ "(org-babel-after-execute . org-redisplay-inline-images)" ]; @@ -490,15 +523,6 @@ in { ''; }; - org-ref = { - enable = true; - config = '' - (setq org-ref-insert-cite-function - (lambda () - (org-cite-insert nil))) - ''; - }; - calibredb = { enable = true; extraPackages = [ pkgs.sqlite ]; @@ -620,10 +644,10 @@ in { }; exec-path-from-shell = { - enable = true; + enable = false; init = '' - (dolist (var '("SSH_AUTH_SOCK" "LANG" "LC_CTYPE" "LC_MESSAGES" "NIX_SSL_CERT_FILE" "NIX_PROFILES" "JAVA_HOME" "GNUPGHOME")) + (dolist (var '("LANG" "LC_CTYPE" "LC_MESSAGES" "NIX_SSL_CERT_FILE" "NIX_PROFILES" "JAVA_HOME" "GNUPGHOME")) (add-to-list 'exec-path-from-shell-variables var)) (when (memq window-system '(mac ns x)) @@ -635,6 +659,54 @@ in { (add-to-list 'exec-path "/Users/willem/.nix-profile/bin") ''; }; + + ivy-bibtext = { + enable = true; + init = '' + (autoload 'ivy-bibtex "ivy-bibtex" "" t) + + ;; ivy-bibtex requires ivy's `ivy--regex-ignore-order` regex builder, which + ;; ignores the order of regexp tokens when searching for matching candidates. + (setq ivy-re-builders-alist + '((ivy-bibtex . ivy--regex-ignore-order) + (t . ivy--regex-plus))) + + (setq ivy-bibtex-bibliography '("~/Documents/org/zotero.bib")) + (setq reftex-default-bibliography '("~/Documents/org/zotero.bib")) + (setq bibtex-completion-pdf-field "file") + ''; + + hook = [ + ''(Tex . (lambda () (define-key Tex-mode-map "C-ch" 'ivy-bibtex)))'' + ]; + }; + + org-ref = { + enable = true; + + init = '' + (setq org-ref-insert-cite-function + (lambda () + (org-cite-insert nil))) + (setq org-ref-default-bibliography "~/Documents/org/zotero.bib") + ''; + }; + + pdf-tools = { + enable = true; + + init = '' + (pdf-tools-install) + + (setq-default pdf-view-display-size 'fit-width) + + (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) + + (setq pdf-annot-activate-created-annotations t) + ''; + + extraPackages = [ pkgs.poppler pkgs.automake ]; + }; }; }; } diff --git a/packages.nix b/packages.nix index d9aecd3..0d88688 100644 --- a/packages.nix +++ b/packages.nix @@ -11,6 +11,7 @@ iterm2 zoom-us karabiner-elements + (pkgs.callPackage ./spotify-mac.nix { inherit config lib pkgs; }) ] ++ [ discord pkgsCustom.vlc pkgsCustom.qbittorrent ] ++ [ docker docker-compose ] ++ [ comma diff --git a/spotify-mac.nix b/spotify-mac.nix new file mode 100644 index 0000000..a538612 --- /dev/null +++ b/spotify-mac.nix @@ -0,0 +1,42 @@ +{ stdenv, lib, config, pkgs, ... }: + +stdenv.mkDerivation { + name = "spotify-mac-app"; + + sourceRoot = "."; + + nativeBuildInputs = [ pkgs.undmg pkgs.makeWrapper pkgs.perl pkgs.unzip pkgs.zip ]; + + src = pkgs.fetchurl { + url = "https://download.scdn.co/Spotify.dmg"; + hash = "sha256-9Ts6064YaZdjbRN28qkZcrwTH+63drC/jUfTGLvpBNc="; + }; + + spotxsrc = pkgs.fetchFromGitHub { + name = "spotx-mac-src"; + owner = "willemml"; + repo = "SpotX-Mac"; + rev = "03ea3aa59e135b9e2f68b6c8f4d4debe2b207830"; + hash = "sha256-H3QxmM0ALtz58MKaQ6pFcK6wP8oMWufvQ2q2ZjpO5Gs="; + }; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + cp -r "Spotify.app" $out/Applications + + # wrap executable to $out/bin + mkdir -p $out/bin + makeWrapper "$out/Applications/Spotify.app/Contents/MacOS/Spotify" "$out/bin/Spotify" + + cp "$spotxsrc/install.sh" install.sh + + chmod +x install.sh + + ./install.sh -a "$out/Applications/Spotify.app" + + runHook postInstall + ''; +} +