From 8e1b90137238383e686fd689baaa2bcf8a6a74b9 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Mon, 22 Mar 2021 13:46:31 +0100 Subject: [PATCH] Use emacsclient to update mu index to make sure the db isn't locked --- configurations/i3.nix | 61 +-- configurations/mail.nix | 440 ++++++++++--------- configurations/sway.nix | 224 +++++----- configurations/sway/status-configuration.nix | 4 +- modules/emacs.nix | 37 +- modules/emacs/init.el | 12 +- 6 files changed, 401 insertions(+), 377 deletions(-) diff --git a/configurations/i3.nix b/configurations/i3.nix index 263ca546..61384b96 100644 --- a/configurations/i3.nix +++ b/configurations/i3.nix @@ -1,39 +1,42 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: let launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; }; - status-configuration = import ./sway/status-configuration.nix { inherit pkgs; }; + status-configuration = import ./sway/status-configuration.nix { inherit pkgs config; }; in { imports = [ ./base-x.nix ]; - home-manager.users.charlotte = { pkgs, ... }: { - xsession = { - windowManager.i3 = { - enable = true; - config = { - bars = [ - { - colors = { - background = "#fbffff"; - statusline = "#535c65"; - focusedWorkspace = { background = "#2b7ab2"; border = "#2b7ab2"; text = "#fbffff"; }; - activeWorkspace = { background = "#6d7782"; border = "#6d7782"; text = "#fbffff"; }; - inactiveWorkspace = { background = "#fbffff"; border = "#fbffff"; text = "535c65"; }; - urgentWorkspace = { background = "#ae5865"; border = "#ae5865"; text = "#fbffff"; }; - }; - fonts = [ "Fira Code Normal 9" ]; - position = "top"; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${status-configuration}"; - } - ]; - floating.criteria = [{ class = "launcher"; } { class = "accentor.Main"; }]; - fonts = [ "Fira Code Normal 9" ]; - menu = "${pkgs.kitty}/bin/kitty --class launcher -e ${launcher}/bin/launcher"; - modifier = "Mod4"; - terminal = "${pkgs.kitty}/bin/kitty"; - }; - extraConfig = '' + + config = { + home-manager.users.charlotte = { pkgs, ... }: { + xsession = { + windowManager.i3 = { + enable = true; + config = { + bars = [ + { + colors = { + background = "#fbffff"; + statusline = "#535c65"; + focusedWorkspace = { background = "#2b7ab2"; border = "#2b7ab2"; text = "#fbffff"; }; + activeWorkspace = { background = "#6d7782"; border = "#6d7782"; text = "#fbffff"; }; + inactiveWorkspace = { background = "#fbffff"; border = "#fbffff"; text = "535c65"; }; + urgentWorkspace = { background = "#ae5865"; border = "#ae5865"; text = "#fbffff"; }; + }; + fonts = [ "Fira Code Normal 9" ]; + position = "top"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${status-configuration}"; + } + ]; + floating.criteria = [{ class = "launcher"; } { class = "accentor.Main"; }]; + fonts = [ "Fira Code Normal 9" ]; + menu = "${pkgs.kitty}/bin/kitty --class launcher -e ${launcher}/bin/launcher"; + modifier = "Mod4"; + terminal = "${pkgs.kitty}/bin/kitty"; + }; + extraConfig = '' default_border pixel ''; + }; }; }; }; diff --git a/configurations/mail.nix b/configurations/mail.nix index 066627fd..79226beb 100644 --- a/configurations/mail.nix +++ b/configurations/mail.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, ... }: +{ config, pkgs, lib, ... }: let passwordScript = pkgs.writeShellScript "get_mail_password" ''${pkgs.pass}/bin/pass show "$@" | head -n1 | tr -d "\n"''; notifyScript = name: pkgs.writeShellScript "notify_${name}_mail" '' @@ -28,7 +28,7 @@ let enable = true; boxes = [ "INBOX" ]; onNotify = "${pkgs.isync}/bin/mbsync ${name}:INBOX"; - onNotifyPost = "${pkgs.mu}/bin/mu index && ${notifyScript name}"; + onNotifyPost = "${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\" && ${notifyScript name}"; }; mbsync = { enable = true; @@ -75,239 +75,241 @@ let toRecursiveINIBase 1; in { - chvp.zfs.homeLinks = [ - { path = "mail"; type = "data"; } - { path = ".cache/mu"; type = "cache"; } - { path = ".local/share/contacts"; type = "cache"; } - { path = ".local/share/calendars"; type = "cache"; } - { path = ".local/share/vdirsyncer"; type = "cache"; } - ]; - home-manager.users.charlotte = { ... }: { - accounts.email = { - maildirBasePath = "/data/home/charlotte/mail"; - accounts = { - personal = makeAccount { - name = "personal"; - address = "charlotte@vanpetegem.me"; - host = "mail.vanpetegem.me"; - passFile = "mail/Personal"; - extraConfig = { - folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; - primary = true; - }; - }; - work = makeAccount { - name = "work"; - address = "charlotte.vanpetegem@ugent.be"; - imapHost = "outlook.office365.com"; - smtpHost = "smtp.office365.com"; - passFile = "work/UGentNet"; - useStartTls = true; - extraConfig = { - folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Deleted Items"; }; - mbsync.extraConfig.account.PipelineDepth = "1"; - }; - }; - work-aap-we-fr = makeAccount { - name = "work-aap-we-fr"; - address = "aap-we-fr@ugent.be"; - imapHost = "owa.ugent.be"; - smtpHost = "smtp.ugent.be"; - passFile = "work/UGentNet"; - useStartTls = true; - extraConfig = { - folders = { drafts = "Concepten"; inbox = "INBOX"; sent = "Verzonden items"; trash = "Verwijderde items"; }; - mbsync.extraConfig.account.PipelineDepth = "1"; - userName = "UGENT\\\\ecvpeteg/aap-we-fr"; - }; - }; - posteo = makeAccount { - name = "posteo"; - address = "chvp@posteo.net"; - host = "posteo.de"; - passFile = "mail/Posteo"; - extraConfig = { - folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; - }; - }; - jonggroen = makeAccount { - name = "jonggroen"; - address = "charlotte@jonggroen.be"; - imapHost = "imap.gmail.com"; - smtpHost = "smtp.gmail.com"; - passFile = "jonggroen/GoogleAppMail"; - useStartTls = true; - extraConfig = { - flavor = "gmail.com"; - folders = { - drafts = "[Gmail].Drafts"; - inbox = "INBOX"; - sent = "INBOX"; - trash = "[Gmail].Bin"; + config = { + chvp.zfs.homeLinks = [ + { path = "mail"; type = "data"; } + { path = ".cache/mu"; type = "cache"; } + { path = ".local/share/contacts"; type = "cache"; } + { path = ".local/share/calendars"; type = "cache"; } + { path = ".local/share/vdirsyncer"; type = "cache"; } + ]; + home-manager.users.charlotte = { ... }: { + accounts.email = { + maildirBasePath = "/data/home/charlotte/mail"; + accounts = { + personal = makeAccount { + name = "personal"; + address = "charlotte@vanpetegem.me"; + host = "mail.vanpetegem.me"; + passFile = "mail/Personal"; + extraConfig = { + folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + primary = true; }; }; - }; - postbot = makeAccount { - name = "postbot"; - address = "postbot@vanpetegem.me"; - host = "mail.vanpetegem.me"; - passFile = "mail/Postbot"; - extraConfig = { - folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + work = makeAccount { + name = "work"; + address = "charlotte.vanpetegem@ugent.be"; + imapHost = "outlook.office365.com"; + smtpHost = "smtp.office365.com"; + passFile = "work/UGentNet"; + useStartTls = true; + extraConfig = { + folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Deleted Items"; }; + mbsync.extraConfig.account.PipelineDepth = "1"; + }; }; - }; - webmaster = makeAccount { - name = "webmaster"; - address = "webmaster@vanpetegem.me"; - host = "mail.vanpetegem.me"; - passFile = "mail/Webmaster"; - extraConfig = { - folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + work-aap-we-fr = makeAccount { + name = "work-aap-we-fr"; + address = "aap-we-fr@ugent.be"; + imapHost = "owa.ugent.be"; + smtpHost = "smtp.ugent.be"; + passFile = "work/UGentNet"; + useStartTls = true; + extraConfig = { + folders = { drafts = "Concepten"; inbox = "INBOX"; sent = "Verzonden items"; trash = "Verwijderde items"; }; + mbsync.extraConfig.account.PipelineDepth = "1"; + userName = "UGENT\\\\ecvpeteg/aap-we-fr"; + }; + }; + posteo = makeAccount { + name = "posteo"; + address = "chvp@posteo.net"; + host = "posteo.de"; + passFile = "mail/Posteo"; + extraConfig = { + folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + }; + }; + jonggroen = makeAccount { + name = "jonggroen"; + address = "charlotte@jonggroen.be"; + imapHost = "imap.gmail.com"; + smtpHost = "smtp.gmail.com"; + passFile = "jonggroen/GoogleAppMail"; + useStartTls = true; + extraConfig = { + flavor = "gmail.com"; + folders = { + drafts = "[Gmail].Drafts"; + inbox = "INBOX"; + sent = "INBOX"; + trash = "[Gmail].Bin"; + }; + }; + }; + postbot = makeAccount { + name = "postbot"; + address = "postbot@vanpetegem.me"; + host = "mail.vanpetegem.me"; + passFile = "mail/Postbot"; + extraConfig = { + folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + }; + }; + webmaster = makeAccount { + name = "webmaster"; + address = "webmaster@vanpetegem.me"; + host = "mail.vanpetegem.me"; + passFile = "mail/Webmaster"; + extraConfig = { + folders = { drafts = "Drafts"; inbox = "INBOX"; sent = "INBOX"; trash = "Trash"; }; + }; }; }; }; - }; - home = { - packages = [ pkgs.khal pkgs.khard ]; - file.".mailcap".text = '' - text/html; ${pkgs.firefox}/bin/firefox %s ; nametemplate=%s.html; needsterminal - text/html; ${pkgs.w3m}/bin/w3m -dump -o display_link_number=1 -o document_charset=%{charset} %s ; copiousoutput; nametemplate=%s.html - text/calendar; ${pkgs.khal}/bin/khal import %s; - application/pdf; ${pkgs.okular}/bin/okular %s - image/png; ${pkgs.okular}/bin/okular %s - image/jpeg; ${pkgs.okular}/bin/okular %s - ''; - }; - xdg.configFile = { - "khal/config".text = toRecursiveINI { - calendars = { - calendar = { - path = "~/.local/share/calendars/*"; - type = "discover"; - }; - }; - locale = { - timeformat = "%H:%M"; - dateformat = "%Y-%m-%d"; - longdateformat = "%Y-%m-%d"; - datetimeformat = "%Y-%m-%d %H:%M"; - longdatetimeformat = "%Y-%m-%d %H:%M"; - }; + home = { + packages = [ pkgs.khal pkgs.khard ]; + file.".mailcap".text = '' + text/html; ${pkgs.firefox}/bin/firefox %s ; nametemplate=%s.html; needsterminal + text/html; ${pkgs.w3m}/bin/w3m -dump -o display_link_number=1 -o document_charset=%{charset} %s ; copiousoutput; nametemplate=%s.html + text/calendar; ${pkgs.khal}/bin/khal import %s; + application/pdf; ${pkgs.okular}/bin/okular %s + image/png; ${pkgs.okular}/bin/okular %s + image/jpeg; ${pkgs.okular}/bin/okular %s + ''; }; - "khard/khard.conf".text = toRecursiveINI { - addressbooks = { - contacts = { - path = "~/.local/share/contacts/contacts"; + xdg.configFile = { + "khal/config".text = toRecursiveINI { + calendars = { + calendar = { + path = "~/.local/share/calendars/*"; + type = "discover"; + }; + }; + locale = { + timeformat = "%H:%M"; + dateformat = "%Y-%m-%d"; + longdateformat = "%Y-%m-%d"; + datetimeformat = "%Y-%m-%d %H:%M"; + longdatetimeformat = "%Y-%m-%d %H:%M"; }; }; - general = { - debug = "no"; - default_action = "list"; - editor = "emacs"; - merge_editor = "${pkgs.writeShellScript "ediff" ''emacs --eval "(ediff-merge-files \"$1\" \"$2\")"''}"; - }; - "contact table" = { - display = "formatted_name"; - group_by_addressbook = "no"; - reverse = "no"; - show_nicknames = "no"; - show_uids = "yes"; - sort = "last_name"; - localize_dates = "yes"; - preferred_phone_number_type = "pref, cell, home"; - preferred_email_address_type = "pref, work, home"; - }; - vcard = { - private_objects = ","; - preferred_version = "4.0"; - search_in_source_files = "no"; - skip_unparsable = "no"; + "khard/khard.conf".text = toRecursiveINI { + addressbooks = { + contacts = { + path = "~/.local/share/contacts/contacts"; + }; + }; + general = { + debug = "no"; + default_action = "list"; + editor = "emacs"; + merge_editor = "${pkgs.writeShellScript "ediff" ''emacs --eval "(ediff-merge-files \"$1\" \"$2\")"''}"; + }; + "contact table" = { + display = "formatted_name"; + group_by_addressbook = "no"; + reverse = "no"; + show_nicknames = "no"; + show_uids = "yes"; + sort = "last_name"; + localize_dates = "yes"; + preferred_phone_number_type = "pref, cell, home"; + preferred_email_address_type = "pref, work, home"; + }; + vcard = { + private_objects = ","; + preferred_version = "4.0"; + search_in_source_files = "no"; + skip_unparsable = "no"; + }; }; + "vdirsyncer/config".text = + let nextcloudConfig = type: { + inherit type; + url = "https://nextcloud.vanpetegem.me/remote.php/dav/"; + username = "chvp"; + "password.fetch" = [ "command" "${passwordScript}" "social/Nextcloud" ]; + }; in + lib.generators.toINI + { mkKeyValue = lib.generators.mkKeyValueDefault { mkValueString = builtins.toJSON; } "="; } + { + general.status_path = "~/.local/share/vdirsyncer"; + "pair nextcloud_contacts" = { + a = "nextcloud_contacts_local"; + b = "nextcloud_contacts_remote"; + collections = [ "from a" "from b" ]; + }; + "storage nextcloud_contacts_local" = { + type = "filesystem"; + path = "~/.local/share/contacts"; + fileext = ".vcf"; + }; + "storage nextcloud_contacts_remote" = nextcloudConfig "carddav"; + "pair nextcloud_calendars" = { + a = "nextcloud_calendars_local"; + b = "nextcloud_calendars_remote"; + collections = [ "from a" "from b" ]; + }; + "storage nextcloud_calendars_local" = { + type = "filesystem"; + path = "~/.local/share/calendars"; + fileext = ".ics"; + }; + "storage nextcloud_calendars_remote" = nextcloudConfig "caldav"; + }; + }; + programs = { + mbsync.enable = true; + msmtp.enable = true; + mu.enable = true; }; - "vdirsyncer/config".text = - let nextcloudConfig = type: { - inherit type; - url = "https://nextcloud.vanpetegem.me/remote.php/dav/"; - username = "chvp"; - "password.fetch" = [ "command" "${passwordScript}" "social/Nextcloud" ]; - }; in - lib.generators.toINI - { mkKeyValue = lib.generators.mkKeyValueDefault { mkValueString = builtins.toJSON; } "="; } - { - general.status_path = "~/.local/share/vdirsyncer"; - "pair nextcloud_contacts" = { - a = "nextcloud_contacts_local"; - b = "nextcloud_contacts_remote"; - collections = [ "from a" "from b" ]; - }; - "storage nextcloud_contacts_local" = { - type = "filesystem"; - path = "~/.local/share/contacts"; - fileext = ".vcf"; - }; - "storage nextcloud_contacts_remote" = nextcloudConfig "carddav"; - "pair nextcloud_calendars" = { - a = "nextcloud_calendars_local"; - b = "nextcloud_calendars_remote"; - collections = [ "from a" "from b" ]; - }; - "storage nextcloud_calendars_local" = { - type = "filesystem"; - path = "~/.local/share/calendars"; - fileext = ".ics"; - }; - "storage nextcloud_calendars_remote" = nextcloudConfig "caldav"; - }; - }; - programs = { - mbsync.enable = true; - msmtp.enable = true; - mu.enable = true; - }; - services = { - imapnotify.enable = true; - }; - systemd.user = { services = { - mbsync = { - Unit = { - Description = "MBSync email fetcher"; - After = "network-online.target"; - Wants = "network-online.target"; - }; - Service = { - Type = "oneshot"; - ExecStart = [ "${pkgs.isync}/bin/mbsync -a" "${pkgs.mu}/bin/mu index" ]; - }; - }; - vdirsyncer = { - Unit = { - Description = "VDirSyncer WebDAV syncer"; - After = "network-online.target"; - Wants = "network-online.target"; - }; - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer sync"; - }; - }; + imapnotify.enable = true; }; - timers = { - mbsync = { - Unit = { Description = "MBSync email fetcher"; }; - Timer = { - OnCalendar = "*:0/5"; - Unit = "mbsync.service"; + systemd.user = { + services = { + mbsync = { + Unit = { + Description = "MBSync email fetcher"; + After = "network-online.target"; + Wants = "network-online.target"; + }; + Service = { + Type = "oneshot"; + ExecStart = [ "${pkgs.isync}/bin/mbsync -a" "${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\"" ]; + }; + }; + vdirsyncer = { + Unit = { + Description = "VDirSyncer WebDAV syncer"; + After = "network-online.target"; + Wants = "network-online.target"; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer sync"; + }; }; - Install = { WantedBy = [ "timers.target" ]; }; }; - vdirsyncer = { - Unit = { Description = "VDirSyncer WebDAV syncer"; }; - Timer = { - OnCalendar = "*:0/5"; - Unit = "vdirsyncer.service"; + timers = { + mbsync = { + Unit = { Description = "MBSync email fetcher"; }; + Timer = { + OnCalendar = "*:0/5"; + Unit = "mbsync.service"; + }; + Install = { WantedBy = [ "timers.target" ]; }; + }; + vdirsyncer = { + Unit = { Description = "VDirSyncer WebDAV syncer"; }; + Timer = { + OnCalendar = "*:0/5"; + Unit = "vdirsyncer.service"; + }; + Install = { WantedBy = [ "timers.target" ]; }; }; - Install = { WantedBy = [ "timers.target" ]; }; }; }; }; diff --git a/configurations/sway.nix b/configurations/sway.nix index 97cb1238..682fef6e 100644 --- a/configurations/sway.nix +++ b/configurations/sway.nix @@ -1,123 +1,124 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: let launcher = import ./sway/launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; }; color-picker = import ./sway/color-picker.nix { inherit pkgs; }; screenshot = import ./sway/screenshot.nix { inherit pkgs; }; - status-configuration = import ./sway/status-configuration.nix { inherit pkgs; }; + status-configuration = import ./sway/status-configuration.nix { inherit pkgs config; }; in { - services.dbus.packages = with pkgs; [ gnome3.dconf ]; - security.pam.services.swaylock = { }; - xdg.portal = { - enable = true; - gtkUsePortal = true; - extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr ]; - }; - home-manager.users.charlotte = { pkgs, lib, ... }: { - home.packages = [ color-picker screenshot ]; - programs.mako = { + config = { + services.dbus.packages = with pkgs; [ gnome3.dconf ]; + security.pam.services.swaylock = { }; + xdg.portal = { enable = true; - font = "Fira Code Normal 9"; + gtkUsePortal = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr ]; }; - services.kanshi = { - enable = true; - profiles = { - "home-undocked" = { - outputs = [ - { criteria = "Unknown 0x2036 0x00000000"; position = "0,0"; mode = "2560x1440"; scale = 1.0; } - ]; - }; - "home-docked" = { - outputs = [ - { criteria = "Unknown 0x2036 0x00000000"; position = "0,0"; mode = "2560x1440"; scale = 1.0; } - { criteria = "Dell Inc. DELL U2718Q FN84K01T095L"; position = "2560,0"; mode = "3840x2160"; scale = 1.25; } - ]; - }; - "work-undocked" = { - outputs = [ - { criteria = "Chimei Innolux Corporation 0x14D3 0x00000000"; position = "0,0"; mode = "1920x1080"; scale = 1.0; } - ]; - }; - "work-docked" = { - outputs = [ - { criteria = "Chimei Innolux Corporation 0x14D3 0x00000000"; position = "0,0"; mode = "1920x1080"; scale = 1.0; } - { criteria = "Dell Inc. DELL U2718Q FN84K83Q1KHL"; position = "1920,0"; mode = "3840x2160"; scale = 1.25; } - ]; + home-manager.users.charlotte = { pkgs, lib, ... }: { + home.packages = [ color-picker screenshot ]; + programs.mako = { + enable = true; + font = "Fira Code Normal 9"; + }; + services.kanshi = { + enable = true; + profiles = { + "home-undocked" = { + outputs = [ + { criteria = "Unknown 0x2036 0x00000000"; position = "0,0"; mode = "2560x1440"; scale = 1.0; } + ]; + }; + "home-docked" = { + outputs = [ + { criteria = "Unknown 0x2036 0x00000000"; position = "0,0"; mode = "2560x1440"; scale = 1.0; } + { criteria = "Dell Inc. DELL U2718Q FN84K01T095L"; position = "2560,0"; mode = "3840x2160"; scale = 1.25; } + ]; + }; + "work-undocked" = { + outputs = [ + { criteria = "Chimei Innolux Corporation 0x14D3 0x00000000"; position = "0,0"; mode = "1920x1080"; scale = 1.0; } + ]; + }; + "work-docked" = { + outputs = [ + { criteria = "Chimei Innolux Corporation 0x14D3 0x00000000"; position = "0,0"; mode = "1920x1080"; scale = 1.0; } + { criteria = "Dell Inc. DELL U2718Q FN84K83Q1KHL"; position = "1920,0"; mode = "3840x2160"; scale = 1.25; } + ]; + }; }; }; - }; - wayland.windowManager.sway = { - enable = true; - config = rec { - modifier = "Mod4"; - left = "h"; - down = "j"; - up = "k"; - right = "l"; - terminal = "${pkgs.kitty}/bin/kitty"; - menu = "${terminal} --class launcher -e ${launcher}/bin/launcher"; - bars = [ - { - colors = { - background = "#ffffff"; - statusline = "#000000"; - activeWorkspace = { border = "#f2eff3"; background = "#f2eff3"; text = "#000000"; }; - focusedWorkspace = { border = "#6aaeff"; background = "#6aaeff"; text = "#000000"; }; - inactiveWorkspace = { border = "#ffffff"; background = "#ffffff"; text = "#000000"; }; - urgentWorkspace = { border = "#ff8892"; background = "#ff8892"; text = "#000000"; }; - }; - fonts = [ "Fira Code Normal 9" ]; - position = "top"; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${status-configuration}"; - extraConfig = '' + wayland.windowManager.sway = { + enable = true; + config = rec { + modifier = "Mod4"; + left = "h"; + down = "j"; + up = "k"; + right = "l"; + terminal = "${pkgs.kitty}/bin/kitty"; + menu = "${terminal} --class launcher -e ${launcher}/bin/launcher"; + bars = [ + { + colors = { + background = "#ffffff"; + statusline = "#000000"; + activeWorkspace = { border = "#f2eff3"; background = "#f2eff3"; text = "#000000"; }; + focusedWorkspace = { border = "#6aaeff"; background = "#6aaeff"; text = "#000000"; }; + inactiveWorkspace = { border = "#ffffff"; background = "#ffffff"; text = "#000000"; }; + urgentWorkspace = { border = "#ff8892"; background = "#ff8892"; text = "#000000"; }; + }; + fonts = [ "Fira Code Normal 9" ]; + position = "top"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${status-configuration}"; + extraConfig = '' status_padding 0 icon_theme Arc ''; - } - ]; - output = { - "Unknown 0x2036 0x00000000" = { position = "0,0"; mode = "2560x1440"; scale = "1.0"; }; - "Dell Inc. DELL U2718Q FN84K01T095L" = { position = "2560,0"; mode = "3840x2160"; scale = "1.25"; }; - "Chimei Innolux Corporation 0x14D3 0x00000000" = { position = "0,0"; mode = "1920x1080"; scale = "1.0"; }; - "Dell Inc. DELL U2718Q FN84K83Q1KHL" = { position = "1920,0"; mode = "3840x2160"; scale = "1.25"; }; + } + ]; + output = { + "Unknown 0x2036 0x00000000" = { position = "0,0"; mode = "2560x1440"; scale = "1.0"; }; + "Dell Inc. DELL U2718Q FN84K01T095L" = { position = "2560,0"; mode = "3840x2160"; scale = "1.25"; }; + "Chimei Innolux Corporation 0x14D3 0x00000000" = { position = "0,0"; mode = "1920x1080"; scale = "1.0"; }; + "Dell Inc. DELL U2718Q FN84K83Q1KHL" = { position = "1920,0"; mode = "3840x2160"; scale = "1.25"; }; + }; + startup = [ + { + command = "${pkgs.swayidle}/bin/swayidle -w timeout 300 '${pkgs.swaylock}/bin/swaylock -f -c 000000' timeout 150 '${pkgs.sway}/bin/swaymsg \"output * dpms off\"' resume '${pkgs.sway}/bin/swaymsg \"output * dpms on\"' before-sleep '${pkgs.swaylock}/bin/swaylock -f -c 000000'"; + } + ]; + window.commands = [ + { command = "floating enable"; criteria = { app_id = "launcher"; }; } + { command = "floating enable"; criteria = { title = "Quick Format Citation"; class = "Zotero"; }; } + ]; + input = { + "type:keyboard" = { xkb_layout = "us"; xkb_variant = "altgr-intl"; xkb_numlock = "enabled"; xkb_options = "compose:caps"; }; + "type:touchpad" = { drag = "enabled"; dwt = "enabled"; scroll_method = "two_finger"; tap = "enabled"; }; + }; + modes = { }; # Unset default "resize" mode + keybindings = lib.mkOptionDefault { + "${modifier}+Shift+q" = "nop Unset default kill"; + "${modifier}+r" = "nop Unset default resize mode"; + "${modifier}+Shift+c" = "kill"; + "${modifier}+Shift+r" = "reload"; + "${modifier}+c" = "exec ${pkgs.swaylock}/bin/swaylock -f -c 000000"; + "${modifier}+i" = "inhibit_idle open; border normal; mark --add inhibiting_idle"; + "${modifier}+Shift+i" = "inhibit_idle none; border pixel; unmark inhibiting_idle"; + "Print" = "exec ${screenshot}/bin/screenshot"; + "Alt+Print" = "exec ${screenshot}/bin/screenshot -d"; + "Shift+Print" = "exec ${screenshot}/bin/screenshot -r"; + "Alt+Shift+Print" = "exec ${screenshot}/bin/screenshot -r -d"; + "XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%"; + "XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%"; + "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; + "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%"; + "${modifier}+Alt+Left" = "move workspace to output left"; + "${modifier}+Alt+Right" = "move workspace to output right"; + }; }; - startup = [ - { - command = "${pkgs.swayidle}/bin/swayidle -w timeout 300 '${pkgs.swaylock}/bin/swaylock -f -c 000000' timeout 150 '${pkgs.sway}/bin/swaymsg \"output * dpms off\"' resume '${pkgs.sway}/bin/swaymsg \"output * dpms on\"' before-sleep '${pkgs.swaylock}/bin/swaylock -f -c 000000'"; - } - ]; - window.commands = [ - { command = "floating enable"; criteria = { app_id = "launcher"; }; } - { command = "floating enable"; criteria = { title = "Quick Format Citation"; class = "Zotero"; }; } - ]; - input = { - "type:keyboard" = { xkb_layout = "us"; xkb_variant = "altgr-intl"; xkb_numlock = "enabled"; xkb_options = "compose:caps"; }; - "type:touchpad" = { drag = "enabled"; dwt = "enabled"; scroll_method = "two_finger"; tap = "enabled"; }; - }; - modes = { }; # Unset default "resize" mode - keybindings = lib.mkOptionDefault { - "${modifier}+Shift+q" = "nop Unset default kill"; - "${modifier}+r" = "nop Unset default resize mode"; - "${modifier}+Shift+c" = "kill"; - "${modifier}+Shift+r" = "reload"; - "${modifier}+c" = "exec ${pkgs.swaylock}/bin/swaylock -f -c 000000"; - "${modifier}+i" = "inhibit_idle open; border normal; mark --add inhibiting_idle"; - "${modifier}+Shift+i" = "inhibit_idle none; border pixel; unmark inhibiting_idle"; - "Print" = "exec ${screenshot}/bin/screenshot"; - "Alt+Print" = "exec ${screenshot}/bin/screenshot -d"; - "Shift+Print" = "exec ${screenshot}/bin/screenshot -r"; - "Alt+Shift+Print" = "exec ${screenshot}/bin/screenshot -r -d"; - "XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%"; - "XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%"; - "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; - "XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; - "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; - "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%"; - "${modifier}+Alt+Left" = "move workspace to output left"; - "${modifier}+Alt+Right" = "move workspace to output right"; - }; - }; - extraConfig = '' + extraConfig = '' workspace 1 output eDP-1 workspace 2 output DP-3 DP-4 DP-5 HDMI-A-1 eDP-1 workspace 3 output DP-3 DP-4 DP-5 HDMI-A-1 eDP-1 @@ -140,7 +141,7 @@ in default_border pixel ''; - extraSessionCommands = '' + extraSessionCommands = '' export XDG_SESSION_TYPE=wayland export XDG_CURRENT_DESKTOP=sway export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 @@ -151,11 +152,12 @@ in export MOZ_ENABLE_WAYLAND=1 export _JAVA_AWT_WM_NONREPARENTING=1 ''; - wrapperFeatures = { - base = true; - gtk = true; + wrapperFeatures = { + base = true; + gtk = true; + }; + xwayland = true; }; - xwayland = true; }; }; } diff --git a/configurations/sway/status-configuration.nix b/configurations/sway/status-configuration.nix index d8a93d06..f2b95ac2 100644 --- a/configurations/sway/status-configuration.nix +++ b/configurations/sway/status-configuration.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: let mic-status = pkgs.writeShellScript "mic-status" '' if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ] @@ -95,7 +95,7 @@ pkgs.writeText "configuration.toml" '' json = true command = "${mail-status}" interval = 1 - on_click = "${pkgs.isync}/bin/mbsync -a" + on_click = "${pkgs.isync}/bin/mbsync -a && ${config.chvp.emacs.package}/bin/emacsclient --eval \"(mu4e-update-index)\"" [[block]] block = "time" diff --git a/modules/emacs.nix b/modules/emacs.nix index 34e129d5..cb7003c2 100644 --- a/modules/emacs.nix +++ b/modules/emacs.nix @@ -1,32 +1,49 @@ { config, lib, pkgs, ... }: +let + emacsPkg = pkgs.emacsWithPackagesFromUsePackage { + config = ./emacs/init.el; + package = pkgs.emacsPgtk; + alwaysEnsure = true; + extraEmacsPackages = epkgs: [ + # mu4e is included in the mu package and should be used from there + pkgs.mu + ]; + }; +in { options.chvp.emacs = { enable = lib.mkOption { default = true; example = false; }; + package = lib.mkOption { }; }; config = lib.mkIf config.chvp.emacs.enable { + chvp = { + emacs.package = emacsPkg; + zfs.homeLinks = [ + { path = ".emacs.d"; type = "cache"; } + ]; + }; + home-manager.users.charlotte = { ... }: { - programs.emacs = { + services.emacs = { enable = true; - package = pkgs.emacsWithPackagesFromUsePackage { - config = ./emacs/init.el; - package = pkgs.emacsPgtk; - alwaysEnsure = true; - extraEmacsPackages = epkgs: [ - # mu4e is included in the mu package and should be used from there - pkgs.mu - ]; - }; + client.enable = true; + package = emacsPkg; }; home = { file = { ".emacs.d/early-init.el".source = ./emacs/early-init.el; ".emacs.d/init.el".source = ./emacs/init.el; }; + packages = [ + (pkgs.writeShellScriptBin "emacs" '' + ${emacsPkg}/bin/emacsclient -c $@ + '') + ]; sessionVariables = { EDITOR = "emacs"; }; }; }; diff --git a/modules/emacs/init.el b/modules/emacs/init.el index cb977d53..fc6c1687 100644 --- a/modules/emacs/init.el +++ b/modules/emacs/init.el @@ -35,7 +35,7 @@ "hv" '(describe-variable :which-key "variable") "q" '(:ignore t :which-key "quit") - "qq" '(save-buffers-kill-emacs :which-key "quit") + "qq" '(delete-frame :which-key "quit") "s" '(:ignore t :which-key "search") @@ -394,14 +394,14 @@ (setq inhibit-startup-screen t) ;; Font configuration -(when window-system (set-frame-font "Fira Code 9")) -(defun emoji-fonts () - "Setup emoji font priorities." +(defun font-settings () + "Setup font settings." + (when window-system (set-frame-font "Fira Code 9")) (set-fontset-font t 'symbol "Noto Color Emoji") (set-fontset-font t 'symbol "Symbola" nil 'append)) (if (daemonp) - (add-hook 'server-after-make-frame-hook #'emoji-fonts) - (emoji-fonts)) + (add-hook 'server-after-make-frame-hook #'font-settings) + (font-settings)) (provide 'init) ;;; init.el ends here