From 6f9db5e3a4c1faa40d82a557adef82dcfcb58f26 Mon Sep 17 00:00:00 2001 From: derped Date: Mon, 11 Sep 2023 20:23:04 +0200 Subject: [PATCH] Format the entire project. --- config/etc.nix | 12 +- config/etc/i3/config.nix | 528 ++++++------ config/etc/rofi.rasi.nix | 40 +- config/fonts.nix | 83 +- config/locale.nix | 15 +- config/networking.nix | 18 +- config/nix.nix | 30 +- config/security.nix | 20 +- config/users.nix | 51 +- config/zsh.nix | 68 +- configuration.nix | 60 +- flake.nix | 62 +- fn.nix | 129 ++- machines/Lilim/configuration.nix | 46 +- machines/Lilim/hardware-configuration.nix | 51 +- machines/Lilim/options.nix | 37 +- machines/Lilim/sops.nix | 6 +- machines/Marid/configuration.nix | 4 +- machines/Marid/hardware-configuration.nix | 35 +- machines/Marid/options.nix | 26 +- machines/Marid/sops.nix | 6 +- machines/Ophanim/configuration.nix | 15 +- machines/Ophanim/hardware-configuration.nix | 28 +- machines/Ophanim/options.nix | 61 +- machines/Ophanim/sops.nix | 6 +- options/copySysConf.nix | 33 +- options/emacs-init-defaults.nix | 11 +- options/emacs-init.nix | 277 +++--- options/machine.nix | 28 +- options/mailman3/core.nix | 38 +- options/mailman3/extraPackages/aiosmtpd.nix | 26 +- options/mailman3/extraPackages/atpublic.nix | 24 +- .../mailman3/extraPackages/flufl_bounce.nix | 13 +- options/mailman3/extraPackages/flufl_i18n.nix | 12 +- options/mailman3/extraPackages/flufl_lock.nix | 12 +- .../mailman3/extraPackages/lazr_config.nix | 12 +- .../mailman3/extraPackages/lazr_delegates.nix | 13 +- options/mailman3/options.nix | 45 +- options/mailman3/release.nix | 16 +- pkgs/flat-remix/default.nix | 11 +- pkgs/nixpkgs.nix | 22 +- pkgs/pyluxafor/default.nix | 10 +- pkgs/sddm_midnight/default.nix | 11 +- pkgs/systemPackages.nix | 24 +- pkgs/xdiskusage/default.nix | 9 +- pkgsets/base.nix | 12 +- pkgsets/cpp.nix | 6 +- pkgsets/dict.nix | 10 +- pkgsets/emacs.nix | 28 +- pkgsets/emacs/company.nix | 159 ++-- pkgsets/emacs/direnv.nix | 25 +- pkgsets/emacs/docker.nix | 38 +- pkgsets/emacs/dockerfile.nix | 18 +- pkgsets/emacs/doom-modeline.nix | 41 +- pkgsets/emacs/doom-themes.nix | 31 +- pkgsets/emacs/elfeed.nix | 273 +++--- pkgsets/emacs/elpy.nix | 75 +- pkgsets/emacs/fcitx.nix | 30 +- pkgsets/emacs/flycheck.nix | 58 +- pkgsets/emacs/flyspell.nix | 58 +- pkgsets/emacs/latex.nix | 49 +- pkgsets/emacs/lsp.nix | 104 +-- pkgsets/emacs/magit.nix | 22 +- pkgsets/emacs/mu4e.nix | 203 ++--- pkgsets/emacs/nix-mode.nix | 22 +- pkgsets/emacs/org.nix | 802 +++++++++--------- pkgsets/emacs/php-mode.nix | 25 +- pkgsets/emacs/powerline.nix | 32 +- pkgsets/emacs/rust.nix | 86 +- pkgsets/emacs/solarized-theme.nix | 20 +- pkgsets/emacs/telega.nix | 30 +- pkgsets/emacs/transmission.nix | 89 +- pkgsets/emacs/undo-tree.nix | 32 +- pkgsets/emacs/web-mode.nix | 188 ++-- pkgsets/emacs/yaml-mode.nix | 21 +- pkgsets/emacs/yasnippet.nix | 33 +- pkgsets/extra.nix | 6 +- pkgsets/haskell-tools.nix | 8 +- pkgsets/haskell.nix | 10 +- pkgsets/latex.nix | 10 +- pkgsets/mail_utils.nix | 6 +- pkgsets/nodejs.nix | 49 +- pkgsets/php.nix | 18 +- pkgsets/python3.nix | 19 +- pkgsets/rustpkgs.nix | 57 +- pkgsets/server.nix | 6 +- pkgsets/tracking.nix | 10 +- pkgsets/uniProgs.nix | 8 +- pkgsets/xpkgs.nix | 14 +- services/acme.nix | 29 +- services/bind.nix | 56 +- services/containers.nix | 29 +- services/cups.nix | 23 +- services/desktop.nix | 58 +- services/desktop/i3.nix | 39 +- services/desktop/sway.nix | 70 +- services/docker.nix | 25 +- services/fail2ban.nix | 184 ++-- services/fprintd.nix | 38 +- services/gitea.nix | 90 +- services/hydra.nix | 122 +-- services/mailserver.nix | 113 +-- services/mariaDB.nix | 21 +- services/mullvad.nix | 14 +- services/nextcloud.nix | 114 +-- services/nginx.nix | 88 +- services/nginx_vHosts/cache.nix | 36 +- services/nginx_vHosts/gitea.nix | 54 +- services/nginx_vHosts/hydra.nix | 36 +- services/nginx_vHosts/mail.nix | 26 +- services/nginx_vHosts/nextcloud.nix | 26 +- services/nginx_vHosts/simple.nix | 19 +- services/openssh.nix | 64 +- services/podman.nix | 38 +- services/udev.nix | 15 +- 115 files changed, 3451 insertions(+), 2901 deletions(-) diff --git a/config/etc.nix b/config/etc.nix index 2eb6121..9c0485d 100644 --- a/config/etc.nix +++ b/config/etc.nix @@ -1,10 +1,12 @@ -{ config, lib, pkgs, ... }: - -with lib; - { + config, + lib, + pkgs, + ... +}: +with lib; { environment.etc = mkIf (elem "etcfiles" config.machine.conffiles) { - "rofi.rasi".source = (import ./etc/rofi.rasi.nix { inherit pkgs; }); + "rofi.rasi".source = import ./etc/rofi.rasi.nix {inherit pkgs;}; "i3/py3status".source = ./etc/i3/py3status; "sway/config".source = mkDefault ./etc/sway/config; "mpv/input.conf".source = ./etc/mpv/input.conf; diff --git a/config/etc/i3/config.nix b/config/etc/i3/config.nix index 85ac971..03b1cb1 100644 --- a/config/etc/i3/config.nix +++ b/config/etc/i3/config.nix @@ -1,286 +1,284 @@ -{ pkgs, ... }: +{pkgs, ...}: (pkgs.writeText "config" '' + # i3 config file (v4) + # + # Please see http://i3wm.org/docs/userguide.html for a complete reference! -(pkgs.writeText "config" '' -# i3 config file (v4) -# -# Please see http://i3wm.org/docs/userguide.html for a complete reference! + exec redshift-gtk -l 51.0504:13.7373 -exec redshift-gtk -l 51.0504:13.7373 + ### START USER CONFIG ### + set $mod Mod4 + workspace "HDMI" output HDMI1 + workspace_auto_back_and_forth yes + new_window pixel + hide_edge_borders both -### START USER CONFIG ### -set $mod Mod4 -workspace "HDMI" output HDMI1 -workspace_auto_back_and_forth yes -new_window pixel -hide_edge_borders both + exec setxkbmap de -exec setxkbmap de + #exec compton -f + exec ${pkgs.feh}/bin/feh --bg-scale $(xdg-user-dir PICTURES)/wallpaper.jpg + #exec pulseaudio -D + exec fcitx5 + #exec env=LC_CTYPE=zh_CN.UTF-8 emacs --daemon + #exec conky -c $HOME/.my_little_conky/.conkyrc + #exec xsnow -nosanta -norudolf -notrees + #exec $LOCK -#exec compton -f -exec ${pkgs.feh}/bin/feh --bg-scale $(xdg-user-dir PICTURES)/wallpaper.jpg -#exec pulseaudio -D -exec fcitx5 -#exec env=LC_CTYPE=zh_CN.UTF-8 emacs --daemon -#exec conky -c $HOME/.my_little_conky/.conkyrc -#exec xsnow -nosanta -norudolf -notrees -#exec $LOCK + ### END USER CONFIG ### -### END USER CONFIG ### + ### START USER PROGRAMMS ### -### START USER PROGRAMMS ### + ### END USER PROGRAMMS ### -### END USER PROGRAMMS ### + ### START MEDIA BINDSYM ### -### START MEDIA BINDSYM ### + bindsym XF86AudioPlay exec ${pkgs.playerctl}/bin/playerctl play + bindsym XF86AudioPause exec ${pkgs.playerctl}/bin/playerctl pause + bindsym XF86AudioNext exec ${pkgs.playerctl}/bin/playerctl next + bindsym XF86AudioPrev exec ${pkgs.playerctl}/bin/playerctl previous -bindsym XF86AudioPlay exec ${pkgs.playerctl}/bin/playerctl play -bindsym XF86AudioPause exec ${pkgs.playerctl}/bin/playerctl pause -bindsym XF86AudioNext exec ${pkgs.playerctl}/bin/playerctl next -bindsym XF86AudioPrev exec ${pkgs.playerctl}/bin/playerctl previous + bindsym $mod+Mod1+space exec ${pkgs.playerctl}/bin/playerctl play-pause + bindsym $mod+Mod1+Left exec ${pkgs.playerctl}/bin/playerctl position 10- + bindsym $mod+Mod1+Right exec ${pkgs.playerctl}/bin/playerctl position 10+ + bindsym $mod+Mod1+Down exec ${pkgs.playerctl}/bin/playerctl next + bindsym $mod+Mod1+Up exec ${pkgs.playerctl}/bin/playerctl previous -bindsym $mod+Mod1+space exec ${pkgs.playerctl}/bin/playerctl play-pause -bindsym $mod+Mod1+Left exec ${pkgs.playerctl}/bin/playerctl position 10- -bindsym $mod+Mod1+Right exec ${pkgs.playerctl}/bin/playerctl position 10+ -bindsym $mod+Mod1+Down exec ${pkgs.playerctl}/bin/playerctl next -bindsym $mod+Mod1+Up exec ${pkgs.playerctl}/bin/playerctl previous + bindsym $mod+Shift+w sticky toggle + bindsym $mod+Shift+B floating enable; border none; resize set 900 600; move position 1020 19 -bindsym $mod+Shift+w sticky toggle -bindsym $mod+Shift+B floating enable; border none; resize set 900 600; move position 1020 19 - -### END MEDIA BINDSYM ### + ### END MEDIA BINDSYM ### -### START BINDSYM ### + ### START BINDSYM ### -bindsym $mod+b border toggle -bindsym $mod+m bar mode toggle -bindsym $mod+y move container to output left -bindsym $mod+x move container to output right -bindsym $mod+Shift+y move workspace to output left -bindsym $mod+Shift+x move workspace to output right -bindsym $mod+l exec ${pkgs.i3lock}/bin/i3lock -efc 000000 -bindsym $mod+minus exec ${pkgs.alsa-utils}/bin/amixer -c 0 sset Master 1%- -bindsym $mod+plus exec ${pkgs.alsa-utils}/bin/amixer -c 0 sset Master 1%+ -bindsym $mod+Mod1+minus exec ${pkgs.alsa-utils}/bin/amixer -D pulse sset Master 1%- -bindsym $mod+Mod1+plus exec ${pkgs.alsa-utils}/bin/amixer -D pulse sset Master 1%+ -bindsym $mod+Shift+minus exec ${pkgs.acpilight}/bin/xbacklight -5 -bindsym $mod+Shift+plus exec ${pkgs.acpilight}/bin/xbacklight +5 -bindsym $mod+Ctrl+0 exec ${pkgs.acpilight}/bin/xbacklight -set 0 -bindsym $mod+Ctrl+1 exec ${pkgs.acpilight}/bin/xbacklight -set 10 -bindsym $mod+Ctrl+2 exec ${pkgs.acpilight}/bin/xbacklight -set 20 -bindsym $mod+Ctrl+3 exec ${pkgs.acpilight}/bin/xbacklight -set 30 -bindsym $mod+Ctrl+4 exec ${pkgs.acpilight}/bin/xbacklight -set 40 -bindsym $mod+Ctrl+5 exec ${pkgs.acpilight}/bin/xbacklight -set 50 -bindsym $mod+Ctrl+6 exec ${pkgs.acpilight}/bin/xbacklight -set 60 -bindsym $mod+Ctrl+7 exec ${pkgs.acpilight}/bin/xbacklight -set 70 -bindsym $mod+Ctrl+8 exec ${pkgs.acpilight}/bin/xbacklight -set 80 -bindsym $mod+Ctrl+9 exec ${pkgs.acpilight}/bin/xbacklight -set 90 -bindsym $mod+p move scratchpad -bindsym $mod+Shift+p scratchpad show -bindsym --release $mod+Ctrl+s exec scrot -bindsym --release $mod+Ctrl+d exec "scrot --select" -bindsym --release $mod+Ctrl+a exec "scrot -s '/tmp/%F_%T_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f && rm $f'" -bindsym $mod+o exec pcmanfm -bindsym $mod+Mod1+1 exec luxa fade --speed 50 '00ff00' -bindsym $mod+Mod1+2 exec luxa fade --speed 50 'ffff00' -bindsym $mod+Mod1+3 exec luxa fade --speed 50 'ff0000' -bindsym $mod+Mod1+4 exec luxa fade --speed 50 '0000ff' -bindsym $mod+Mod1+5 exec luxa fade --speed 50 'ffffff' -### END BINDSYM ### + bindsym $mod+b border toggle + bindsym $mod+m bar mode toggle + bindsym $mod+y move container to output left + bindsym $mod+x move container to output right + bindsym $mod+Shift+y move workspace to output left + bindsym $mod+Shift+x move workspace to output right + bindsym $mod+l exec ${pkgs.i3lock}/bin/i3lock -efc 000000 + bindsym $mod+minus exec ${pkgs.alsa-utils}/bin/amixer -c 0 sset Master 1%- + bindsym $mod+plus exec ${pkgs.alsa-utils}/bin/amixer -c 0 sset Master 1%+ + bindsym $mod+Mod1+minus exec ${pkgs.alsa-utils}/bin/amixer -D pulse sset Master 1%- + bindsym $mod+Mod1+plus exec ${pkgs.alsa-utils}/bin/amixer -D pulse sset Master 1%+ + bindsym $mod+Shift+minus exec ${pkgs.acpilight}/bin/xbacklight -5 + bindsym $mod+Shift+plus exec ${pkgs.acpilight}/bin/xbacklight +5 + bindsym $mod+Ctrl+0 exec ${pkgs.acpilight}/bin/xbacklight -set 0 + bindsym $mod+Ctrl+1 exec ${pkgs.acpilight}/bin/xbacklight -set 10 + bindsym $mod+Ctrl+2 exec ${pkgs.acpilight}/bin/xbacklight -set 20 + bindsym $mod+Ctrl+3 exec ${pkgs.acpilight}/bin/xbacklight -set 30 + bindsym $mod+Ctrl+4 exec ${pkgs.acpilight}/bin/xbacklight -set 40 + bindsym $mod+Ctrl+5 exec ${pkgs.acpilight}/bin/xbacklight -set 50 + bindsym $mod+Ctrl+6 exec ${pkgs.acpilight}/bin/xbacklight -set 60 + bindsym $mod+Ctrl+7 exec ${pkgs.acpilight}/bin/xbacklight -set 70 + bindsym $mod+Ctrl+8 exec ${pkgs.acpilight}/bin/xbacklight -set 80 + bindsym $mod+Ctrl+9 exec ${pkgs.acpilight}/bin/xbacklight -set 90 + bindsym $mod+p move scratchpad + bindsym $mod+Shift+p scratchpad show + bindsym --release $mod+Ctrl+s exec scrot + bindsym --release $mod+Ctrl+d exec "scrot --select" + bindsym --release $mod+Ctrl+a exec "scrot -s '/tmp/%F_%T_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f && rm $f'" + bindsym $mod+o exec pcmanfm + bindsym $mod+Mod1+1 exec luxa fade --speed 50 '00ff00' + bindsym $mod+Mod1+2 exec luxa fade --speed 50 'ffff00' + bindsym $mod+Mod1+3 exec luxa fade --speed 50 'ff0000' + bindsym $mod+Mod1+4 exec luxa fade --speed 50 '0000ff' + bindsym $mod+Mod1+5 exec luxa fade --speed 50 'ffffff' + ### END BINDSYM ### -### START MODES ### + ### START MODES ### -mode "ACPI Events" { - bindsym p exec systemctl poweroff; mode "default" - bindsym h exec systemctl hibernate; mode "default" - bindsym s exec systemctl suspend; mode "default" - bindsym r exec systemctl reboot; mode "default" - bindsym h exec systemctl halt; mode "default" - bindsym e exec systemctl exit; mode "default" - bindsym l exec $LOCK; mode "default" + mode "ACPI Events" { + bindsym p exec systemctl poweroff; mode "default" + bindsym h exec systemctl hibernate; mode "default" + bindsym s exec systemctl suspend; mode "default" + bindsym r exec systemctl reboot; mode "default" + bindsym h exec systemctl halt; mode "default" + bindsym e exec systemctl exit; mode "default" + bindsym l exec $LOCK; mode "default" - bindsym Return mode "default" - bindsym Escape mode "default" -} - -mode "Power Mode"{ - bindsym s exec xbacklight -set 5; exec rfkill block all ; exec xset -b +dpms; mode "default" - bindsym p exec xbacklight -set 100; exec rfkill unblock all; exec xset -dpms; mode "default" - - bindsym Return mode "default" - bindsym Escape mode "default" -} - -mode "No Keybinds" { - bindsym $mod+Shift+Escape mode "default" -} - -bindsym $mod+F12 mode "ACPI Events" -bindsym $mod+F11 mode "No Keybinds" -bindsym $mod+F10 mode "Power Mode" - -### END MODES ### - -# Font for window titles. Will also be used by the bar unless a different font -# is used in the bar {} block below. -#font pango:monospace 8 -#font pango:System San Francisco Display 8 - -# This font is widely installed, provides lots of unicode glyphs, right-to-left -# text rendering and scalability on retina/hidpi displays (thanks to pango). -font pango:DejaVu Sans Mono 8 - -# Before i3 v4.8, we used to recommend this one as the default: -# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 -# The font above is very space-efficient, that is, it looks good, sharp and -# clear in small sizes. However, its unicode glyph coverage is limited, the old -# X core fonts rendering does not support right-to-left and this being a bitmap -# font, it doesn’t scale on retina/hidpi displays. - -# Use Mouse+$mod to drag floating windows to their wanted position -floating_modifier $mod - -# start a terminal -bindsym $mod+Shift+Return exec emacsclient -c -bindsym $mod+Mod1+Return exec emacsclient -c -e '(eshell t)' -bindsym $mod+Return exec alacritty - -# kill focused window -bindsym $mod+Shift+q kill - -# start dmenu (a program launcher) -bindsym $mod+d exec ${pkgs.rofi}/bin/rofi -config /etc/rofi.rasi -show combi -# There also is the (new) i3-dmenu-desktop which only displays applications -# shipping a .desktop file. It is a wrapper around dmenu, so you need that -# installed. -# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop - -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right - -# move focused window -bindsym $mod+Shift+j move left -bindsym $mod+Shift+k move down -bindsym $mod+Shift+l move up -bindsym $mod+Shift+odiaeresis move right -#bindsym $mod+Shift+semicolon1 move right - -# alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right - -# split in horizontal orientation -bindsym $mod+h split h - -# split in vertical orientation -bindsym $mod+v split v - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen toggle - -# change container layout (stacked, tabbed, toggle split) -bindsym $mod+q layout stacking -bindsym $mod+w layout tabbed -bindsym $mod+e layout toggle split - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+space focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -bindsym $mod+s focus child - -# switch to workspace -bindsym $mod+1 workspace 1 -bindsym $mod+2 workspace 2 -bindsym $mod+3 workspace 3 -bindsym $mod+4 workspace 4 -bindsym $mod+5 workspace 5 -bindsym $mod+6 workspace 6 -bindsym $mod+7 workspace 7 -bindsym $mod+8 workspace 8 -bindsym $mod+9 workspace 9 -bindsym $mod+0 workspace 10 - -# move focused container to workspace -bindsym $mod+Shift+1 move container to workspace 1 -bindsym $mod+Shift+2 move container to workspace 2 -bindsym $mod+Shift+3 move container to workspace 3 -bindsym $mod+Shift+4 move container to workspace 4 -bindsym $mod+Shift+5 move container to workspace 5 -bindsym $mod+Shift+6 move container to workspace 6 -bindsym $mod+Shift+7 move container to workspace 7 -bindsym $mod+Shift+8 move container to workspace 8 -bindsym $mod+Shift+9 move container to workspace 9 -bindsym $mod+Shift+0 move container to workspace 10 - -# reload the configuration file -bindsym $mod+Shift+c reload -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) -bindsym $mod+Shift+r restart -# exit i3 (logs you out of your X session) -bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" - -# resize window (you can also use the mouse for that) -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the window’s width. - # Pressing right will grow the window’s width. - # Pressing up will shrink the window’s height. - # Pressing down will grow the window’s height. - bindsym j resize shrink width 10 px or 10 ppt - bindsym k resize grow height 10 px or 10 ppt - bindsym l resize shrink height 10 px or 10 ppt - bindsym semicolon resize grow width 10 px or 10 ppt - - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} - -bindsym $mod+r mode "resize" - -# Start i3bar to display a workspace bar (plus the system information i3status -# finds out, if available) -bar { - position top - status_command py3status -c /etc/i3/py3status - tray_output primary - # status_command i3status - colors { - separator #586e75 - background #002b36 - statusline #aea79f - focused_workspace #586e75 #586e75 #ffffff - active_workspace #073642 #073642 #ffffff - inactive_workspace #002b36 #002b36 #aea79f - urgent_workspace #77216f #77216f #ffffff + bindsym Return mode "default" + bindsym Escape mode "default" } -} -client.focused #008666 #000000 #ffffff -client.focused_inactive #000000 #222222 #ffffff -client.unfocused #002b36 #333333 #ffffff #ffffff -client.urgent #aa0000 y#990000 #ffffff -#client.focused #586e75 #586e75 #fdf6e3 #268bd2 -#client.focused_inactive #073642 #073642 #93a1a1 #002b36 -#client.unfocused #002b36 #002b36 #586e75 #002b36 -#client.urgent #dc322f #dc322f #fdf6e3 #dc322f + mode "Power Mode"{ + bindsym s exec xbacklight -set 5; exec rfkill block all ; exec xset -b +dpms; mode "default" + bindsym p exec xbacklight -set 100; exec rfkill unblock all; exec xset -dpms; mode "default" + + bindsym Return mode "default" + bindsym Escape mode "default" + } + + mode "No Keybinds" { + bindsym $mod+Shift+Escape mode "default" + } + + bindsym $mod+F12 mode "ACPI Events" + bindsym $mod+F11 mode "No Keybinds" + bindsym $mod+F10 mode "Power Mode" + + ### END MODES ### + + # Font for window titles. Will also be used by the bar unless a different font + # is used in the bar {} block below. + #font pango:monospace 8 + #font pango:System San Francisco Display 8 + + # This font is widely installed, provides lots of unicode glyphs, right-to-left + # text rendering and scalability on retina/hidpi displays (thanks to pango). + font pango:DejaVu Sans Mono 8 + + # Before i3 v4.8, we used to recommend this one as the default: + # font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 + # The font above is very space-efficient, that is, it looks good, sharp and + # clear in small sizes. However, its unicode glyph coverage is limited, the old + # X core fonts rendering does not support right-to-left and this being a bitmap + # font, it doesn’t scale on retina/hidpi displays. + + # Use Mouse+$mod to drag floating windows to their wanted position + floating_modifier $mod + + # start a terminal + bindsym $mod+Shift+Return exec emacsclient -c + bindsym $mod+Mod1+Return exec emacsclient -c -e '(eshell t)' + bindsym $mod+Return exec alacritty + + # kill focused window + bindsym $mod+Shift+q kill + + # start dmenu (a program launcher) + bindsym $mod+d exec ${pkgs.rofi}/bin/rofi -config /etc/rofi.rasi -show combi + # There also is the (new) i3-dmenu-desktop which only displays applications + # shipping a .desktop file. It is a wrapper around dmenu, so you need that + # installed. + # bindsym $mod+d exec --no-startup-id i3-dmenu-desktop + + # alternatively, you can use the cursor keys: + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + + # move focused window + bindsym $mod+Shift+j move left + bindsym $mod+Shift+k move down + bindsym $mod+Shift+l move up + bindsym $mod+Shift+odiaeresis move right + #bindsym $mod+Shift+semicolon1 move right + + # alternatively, you can use the cursor keys: + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right + + # split in horizontal orientation + bindsym $mod+h split h + + # split in vertical orientation + bindsym $mod+v split v + + # enter fullscreen mode for the focused container + bindsym $mod+f fullscreen toggle + + # change container layout (stacked, tabbed, toggle split) + bindsym $mod+q layout stacking + bindsym $mod+w layout tabbed + bindsym $mod+e layout toggle split + + # toggle tiling / floating + bindsym $mod+Shift+space floating toggle + + # change focus between tiling / floating windows + bindsym $mod+space focus mode_toggle + + # focus the parent container + bindsym $mod+a focus parent + + # focus the child container + bindsym $mod+s focus child + + # switch to workspace + bindsym $mod+1 workspace 1 + bindsym $mod+2 workspace 2 + bindsym $mod+3 workspace 3 + bindsym $mod+4 workspace 4 + bindsym $mod+5 workspace 5 + bindsym $mod+6 workspace 6 + bindsym $mod+7 workspace 7 + bindsym $mod+8 workspace 8 + bindsym $mod+9 workspace 9 + bindsym $mod+0 workspace 10 + + # move focused container to workspace + bindsym $mod+Shift+1 move container to workspace 1 + bindsym $mod+Shift+2 move container to workspace 2 + bindsym $mod+Shift+3 move container to workspace 3 + bindsym $mod+Shift+4 move container to workspace 4 + bindsym $mod+Shift+5 move container to workspace 5 + bindsym $mod+Shift+6 move container to workspace 6 + bindsym $mod+Shift+7 move container to workspace 7 + bindsym $mod+Shift+8 move container to workspace 8 + bindsym $mod+Shift+9 move container to workspace 9 + bindsym $mod+Shift+0 move container to workspace 10 + + # reload the configuration file + bindsym $mod+Shift+c reload + # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) + bindsym $mod+Shift+r restart + # exit i3 (logs you out of your X session) + bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + + # resize window (you can also use the mouse for that) + mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym j resize shrink width 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize shrink height 10 px or 10 ppt + bindsym semicolon resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" + } + + bindsym $mod+r mode "resize" + + # Start i3bar to display a workspace bar (plus the system information i3status + # finds out, if available) + bar { + position top + status_command py3status -c /etc/i3/py3status + tray_output primary + # status_command i3status + colors { + separator #586e75 + background #002b36 + statusline #aea79f + focused_workspace #586e75 #586e75 #ffffff + active_workspace #073642 #073642 #ffffff + inactive_workspace #002b36 #002b36 #aea79f + urgent_workspace #77216f #77216f #ffffff + } + } + client.focused #008666 #000000 #ffffff + client.focused_inactive #000000 #222222 #ffffff + client.unfocused #002b36 #333333 #ffffff #ffffff + client.urgent #aa0000 y#990000 #ffffff + + #client.focused #586e75 #586e75 #fdf6e3 #268bd2 + #client.focused_inactive #073642 #073642 #93a1a1 #002b36 + #client.unfocused #002b36 #002b36 #586e75 #002b36 + #client.urgent #dc322f #dc322f #fdf6e3 #dc322f '') diff --git a/config/etc/rofi.rasi.nix b/config/etc/rofi.rasi.nix index b1e8513..57a7d6c 100644 --- a/config/etc/rofi.rasi.nix +++ b/config/etc/rofi.rasi.nix @@ -1,25 +1,23 @@ -{ pkgs }: - -let +{pkgs}: let tabMode = pkgs.writeScript "tab-finder.sh" (with pkgs; '' - #!/usr/bin/env bash - if [ -z ''${1} ]; then - ${brotab}/bin/bt list; - else - TARGET_TAB=$(sed "s/\t.*$//g" <<< ''${1}); - # activate window as focused to it is easy to switch to - ${brotab}/bin/bt activate --focused ''${TARGET_TAB} > /dev/null 2>&1; - ${i3}/bin/i3-msg -t run_command "[urgent=latest] focus" > /dev/null 2>&1; - fi - exit 0; + #!/usr/bin/env bash + if [ -z ''${1} ]; then + ${brotab}/bin/bt list; + else + TARGET_TAB=$(sed "s/\t.*$//g" <<< ''${1}); + # activate window as focused to it is easy to switch to + ${brotab}/bin/bt activate --focused ''${TARGET_TAB} > /dev/null 2>&1; + ${i3}/bin/i3-msg -t run_command "[urgent=latest] focus" > /dev/null 2>&1; + fi + exit 0; ''); in (pkgs.writeText "rofi.rasi" '' -configuration { - modi: "combi,window,drun,ssh,tabFinder:${tabMode}"; - font: "hack 10"; - combi-modi: "window,drun,ssh,tabFinder"; - icon-theme: "Papirus"; - show-icons: true; -} -@theme "solarized" + configuration { + modi: "combi,window,drun,ssh,tabFinder:${tabMode}"; + font: "hack 10"; + combi-modi: "window,drun,ssh,tabFinder"; + icon-theme: "Papirus"; + show-icons: true; + } + @theme "solarized" '') diff --git a/config/fonts.nix b/config/fonts.nix index f4bf476..bffeb90 100644 --- a/config/fonts.nix +++ b/config/fonts.nix @@ -1,42 +1,45 @@ -{ pkgs, lib, config, ... }: - +{ + pkgs, + lib, + config, + ... +}: with lib; - -mkIf (elem "fonts" config.machine.conffiles) { - fonts = { - fontDir.enable = true; - enableGhostscriptFonts = true; - fontconfig = { - enable = true; - # deprecated (will eventually be completely removed) - # ultimate.enable = true; - includeUserConf = false; + mkIf (elem "fonts" config.machine.conffiles) { + fonts = { + fontDir.enable = true; + enableGhostscriptFonts = true; + fontconfig = { + enable = true; + # deprecated (will eventually be completely removed) + # ultimate.enable = true; + includeUserConf = false; + }; + packages = with pkgs; [ + arphic-ukai + arphic-uming + crimson + corefonts # Microsoft free fonts + dejavu_fonts + font-awesome + inconsolata # monospaced + inter + manrope + montserrat + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + noto-fonts-extra + powerline-fonts + source-han-sans-japanese + source-han-sans-korean + source-han-sans-simplified-chinese + source-han-sans-traditional-chinese + # source-sans-pro + symbola + ubuntu_font_family + wqy_microhei + wqy_zenhei + ]; }; - packages = with pkgs; [ - arphic-ukai - arphic-uming - crimson - corefonts # Microsoft free fonts - dejavu_fonts - font-awesome - inconsolata # monospaced - inter - manrope - montserrat - noto-fonts - noto-fonts-cjk - noto-fonts-emoji - noto-fonts-extra - powerline-fonts - source-han-sans-japanese - source-han-sans-korean - source-han-sans-simplified-chinese - source-han-sans-traditional-chinese -# source-sans-pro - symbola - ubuntu_font_family - wqy_microhei - wqy_zenhei - ]; - }; -} + } diff --git a/config/locale.nix b/config/locale.nix index f427566..249c233 100644 --- a/config/locale.nix +++ b/config/locale.nix @@ -1,13 +1,18 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { console.keyMap = "de"; i18n = { defaultLocale = "en_US.UTF-8"; - supportedLocales = [ "all" ]; + supportedLocales = ["all"]; inputMethod = { - enabled = if config.services.xserver.enable then "fcitx5" else null; - fcitx5.addons = with pkgs; [ fcitx5-chinese-addons fcitx5-mozc fcitx5-table-extra ]; + enabled = + if config.services.xserver.enable + then "fcitx5" + else null; + fcitx5.addons = with pkgs; [fcitx5-chinese-addons fcitx5-mozc fcitx5-table-extra]; }; }; } diff --git a/config/networking.nix b/config/networking.nix index 874df3c..f6f7660 100644 --- a/config/networking.nix +++ b/config/networking.nix @@ -1,10 +1,11 @@ -{ config, lib, ... }: - -with lib; - -let +{ + config, + lib, + ... +}: +with lib; let networkD = config.machine.networkD; -in{ +in { networking = { hostName = config.machine.hostName; useNetworkd = networkD.enable; @@ -20,7 +21,7 @@ in{ DHCP = "yes"; DNSSEC = "yes"; DNSOverTLS = "yes"; - DNS = [ "1.1.1.1" "1.0.0.1" ]; + DNS = ["1.1.1.1" "1.0.0.1"]; }; in { "40-wired" = { @@ -58,7 +59,8 @@ in{ systemd.services."systemd-networkd-wait-online" = { enable = mkForce networkD.waitOnline; serviceConfig.ExecStart = [ - "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" + "" + "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" ]; }; } diff --git a/config/nix.nix b/config/nix.nix index f964444..afa6235 100644 --- a/config/nix.nix +++ b/config/nix.nix @@ -1,6 +1,12 @@ -{ nixpkgs, nixpkgs-git, nixpkgs-stable, pkgs, config, lib, ... }: - -let +{ + nixpkgs, + nixpkgs-git, + nixpkgs-stable, + pkgs, + config, + lib, + ... +}: let cfg = config.machine; emptyGlobalRegistry = pkgs.writeText "registry.json" ''{ "flakes": [], "version": 2 }''; in { @@ -16,15 +22,19 @@ in { cores = 1; sandbox = true; auto-optimise-store = true; - trusted-substituters = [ - "https://cache.nixos.org" - ] ++ cfg.binaryCaches; + trusted-substituters = + [ + "https://cache.nixos.org" + ] + ++ cfg.binaryCaches; # TODO: integrate into sops # trusted-public-keys = [ (lib.fileContents "${cfg.secretPath}/hydra_cache.pub") ]; - substituters = [ - "https://cache.nixos.org" - ] ++ cfg.binaryCaches; - allowed-users = [ "root" ] ++ (map (n: n.name) cfg.administrators); + substituters = + [ + "https://cache.nixos.org" + ] + ++ cfg.binaryCaches; + allowed-users = ["root"] ++ (map (n: n.name) cfg.administrators); }; extraOptions = '' build-timeout = 86400 # 24 hours diff --git a/config/security.nix b/config/security.nix index 8211002..2af82fa 100644 --- a/config/security.nix +++ b/config/security.nix @@ -1,10 +1,12 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "security" config.machine.conffiles) { - security = { - audit.enable = true; - auditd.enable = true; - }; -} + mkIf (elem "security" config.machine.conffiles) { + security = { + audit.enable = true; + auditd.enable = true; + }; + } diff --git a/config/users.nix b/config/users.nix index 5ad3bfd..b80174c 100644 --- a/config/users.nix +++ b/config/users.nix @@ -1,8 +1,11 @@ -{ config, lib, fn, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + fn, + pkgs, + ... +}: +with lib; let withDocker = config.virtualisation.docker.enable; withPodman = config.virtualisation.podman.enable; administrators = user: { @@ -13,16 +16,23 @@ let in { isNormalUser = true; name = user.name; - uid = user.id; - subUidRanges = (optional withPodman { startUid = 100000; count = 65536; }); - subGidRanges = (optional withPodman { startGid = 100000; count = 65536; }); + uid = user.id; + subUidRanges = optional withPodman { + startUid = 100000; + count = 65536; + }; + subGidRanges = optional withPodman { + startGid = 100000; + count = 65536; + }; home = builtins.toPath "/home/${user.name}"; createHome = true; description = "Administrative user ${user.name}."; group = user.name; - extraGroups = [ "audio" "wheel" "network" ] + extraGroups = + ["audio" "wheel" "network"] ++ (optionals cfg.xserver.enable ["input" "video"]) - ++ (optionals cfg.printing.enable [ "cups" "lp" ]) + ++ (optionals cfg.printing.enable ["cups" "lp"]) ++ (optional (withDocker && !withPodman) "docker") ++ (optional withPodman "podman"); shell = "${pkgs.zsh}/bin/zsh"; @@ -30,19 +40,20 @@ let }; }; - mkusergroup = user: { - name = user.name; - value = { - name = user.name; - gid = user.id; - members = [ user.name ]; - }; - }; + mkusergroup = user: { + name = user.name; + value = { + name = user.name; + gid = user.id; + members = [user.name]; + }; + }; in { - sops.secrets = (fn.sopsHelper + sops.secrets = + fn.sopsHelper (user: "users/${user.name}/password") config.machine.administrators - { neededForUsers = true; }); + {neededForUsers = true;}; users = { mutableUsers = false; users = listToAttrs (map administrators config.machine.administrators); diff --git a/config/zsh.nix b/config/zsh.nix index 5897896..fc7d73f 100644 --- a/config/zsh.nix +++ b/config/zsh.nix @@ -1,36 +1,38 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "zsh" config.machine.conffiles) { - programs.zsh = { - enable = true; - autosuggestions.enable = true; - syntaxHighlighting.enable = true; - shellAliases = { - cat = ''bat --paging=never --theme="Solarized (dark)"''; - less = ''bat --paging=always --style=changes --color=always --theme="Solarized (dark)"''; - ls = "exa"; - l = "exa -abgHhl@ --git --color=always --group-directories-first"; - tree = "exa --tree --color=always"; - ustrip = "sed -e '/\.service\|\.timer\|\.target\|\.socket\|\.slice\|\.scope\|\.path\|\.mount\|\.device)/!d' -e 's/loaded.*$//g' -e 's/^ \|^● //g'"; - lsunits = "systemctl list-units | ustrip"; - }; - - shellInit = '' - function ll() { exa -abgHhl@ --git --color=always --group-directories-first $@ | bat --paging=always --style=changes --color=always --theme="Solarized (dark)" } - function lln() { exa -abgHhl@ --git --color=always --group-directories-first $@ | bat --paging=always --style=changes --color=always --theme="Solarized (dark)" -n } - function lszip() { unzip -l $@ 2>&1 | sed -e "1,3d" -e "s/^.*:.. *//g" | head --lines=-2 } - function rwhich() { realpath $(which $@) } - function cdf() { cd $(rwhich $@ | sed "s/$@$//") } - function sfu() { lsunits | rg -i $@ } - function map() { for f in "$\{@:2\}"; do; eval $1 \"$f\"; done } - ''; - - ohMyZsh = { + mkIf (elem "zsh" config.machine.conffiles) { + programs.zsh = { enable = true; - plugins = [ "cabal" "docker" "gitfast" "python" "pip" "sudo" "systemd" "man" ]; - theme = "gentoo"; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + shellAliases = { + cat = ''bat --paging=never --theme="Solarized (dark)"''; + less = ''bat --paging=always --style=changes --color=always --theme="Solarized (dark)"''; + ls = "exa"; + l = "exa -abgHhl@ --git --color=always --group-directories-first"; + tree = "exa --tree --color=always"; + ustrip = "sed -e '/\.service\|\.timer\|\.target\|\.socket\|\.slice\|\.scope\|\.path\|\.mount\|\.device)/!d' -e 's/loaded.*$//g' -e 's/^ \|^● //g'"; + lsunits = "systemctl list-units | ustrip"; + }; + + shellInit = '' + function ll() { exa -abgHhl@ --git --color=always --group-directories-first $@ | bat --paging=always --style=changes --color=always --theme="Solarized (dark)" } + function lln() { exa -abgHhl@ --git --color=always --group-directories-first $@ | bat --paging=always --style=changes --color=always --theme="Solarized (dark)" -n } + function lszip() { unzip -l $@ 2>&1 | sed -e "1,3d" -e "s/^.*:.. *//g" | head --lines=-2 } + function rwhich() { realpath $(which $@) } + function cdf() { cd $(rwhich $@ | sed "s/$@$//") } + function sfu() { lsunits | rg -i $@ } + function map() { for f in "$\{@:2\}"; do; eval $1 \"$f\"; done } + ''; + + ohMyZsh = { + enable = true; + plugins = ["cabal" "docker" "gitfast" "python" "pip" "sudo" "systemd" "man"]; + theme = "gentoo"; + }; }; - }; -} + } diff --git a/configuration.nix b/configuration.nix index 554bdfc..19f2150 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,33 +1,47 @@ -{ lib, ... }: - +{lib, ...}: with builtins; -with lib; - -let - fn = import (toString ./fn.nix) { inherit lib; }; +with lib; let + fn = import (toString ./fn.nix) {inherit lib;}; # Cannot use here as those evaluations only work with existing paths >.< # hostName and secretPtah can be set with -I hostName=$HOSTNAME and -I secretPath=$SECRETPATH respectively # , defaults to the contents of /secret/hostName - secretPath = fn.ifelse ((tryEval (toString )).value != false) + secretPath = + fn.ifelse ((tryEval (toString )).value != false) (toString ) (toString /secret); - hostName = ( - findFirst + hostName = + ( + findFirst (elem: elem.prefix == "hostName") - { path = (fileContents "${secretPath}/hostName"); } + {path = fileContents "${secretPath}/hostName";} nixPath - ).path; - machinePath = (builtins.toPath (./machines + ("/" + hostName))); - machineFiles = fn.lst { p = machinePath; b = true; }; - configFiles = fn.lst { p = (toString ./config); b = true; }; - pkgsFiles = fn.lst { p = (toString ./pkgs); b = true; }; - serviceFiles = fn.lst { p = (toString ./services); b = true; }; + ) + .path; + machinePath = builtins.toPath (./machines + ("/" + hostName)); + machineFiles = fn.lst { + p = machinePath; + b = true; + }; + configFiles = fn.lst { + p = toString ./config; + b = true; + }; + pkgsFiles = fn.lst { + p = toString ./pkgs; + b = true; + }; + serviceFiles = fn.lst { + p = toString ./services; + b = true; + }; in { - imports = [ - ./options/machine.nix - ./services/mailserver/default.nix - ] ++ machineFiles - ++ configFiles - ++ pkgsFiles - ++ serviceFiles; + imports = + [ + ./options/machine.nix + ./services/mailserver/default.nix + ] + ++ machineFiles + ++ configFiles + ++ pkgsFiles + ++ serviceFiles; } diff --git a/flake.nix b/flake.nix index 9cfe238..7c4d047 100644 --- a/flake.nix +++ b/flake.nix @@ -15,31 +15,57 @@ inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, alejandra, mailserver, sops-nix, ... }@attrs: let + outputs = { + self, + nixpkgs, + alejandra, + mailserver, + sops-nix, + ... + } @ attrs: let lib = nixpkgs.lib; - fn = import ./fn.nix { inherit lib; }; + fn = import ./fn.nix {inherit lib;}; mappedFormatter = builtins.mapAttrs (arch: packages: packages.default) alejandra.packages; system = "x86_64-linux"; - machineList = fn.lst { p = (toString ./machines); t = "directory"; b = false; }; - configFiles = fn.lst { p = (toString ./config); b = true; }; - pkgsFiles = fn.lst { p = (toString ./pkgs); b = true; }; - serviceFiles = fn.lst { p = (toString ./services); b = true; }; + machineList = fn.lst { + p = toString ./machines; + t = "directory"; + b = false; + }; + configFiles = fn.lst { + p = toString ./config; + b = true; + }; + pkgsFiles = fn.lst { + p = toString ./pkgs; + b = true; + }; + serviceFiles = fn.lst { + p = toString ./services; + b = true; + }; nixosSystemFor = machine: { name = machine; value = let machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine]; - machineFiles = lib.filter (name: lib.strings.hasSuffix ".nix" name) (fn.lst { p = machinePath; b = true; }); - in nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = attrs // { fn = fn; }; - modules = [ - (toString ./options/machine.nix) - sops-nix.nixosModules.sops - ] ++ machineFiles - ++ configFiles - ++ pkgsFiles - ++ serviceFiles; - }; + machineFiles = lib.filter (name: lib.strings.hasSuffix ".nix" name) (fn.lst { + p = machinePath; + b = true; + }); + in + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = attrs // {fn = fn;}; + modules = + [ + (toString ./options/machine.nix) + sops-nix.nixosModules.sops + ] + ++ machineFiles + ++ configFiles + ++ pkgsFiles + ++ serviceFiles; + }; }; in { formatter = mappedFormatter; diff --git a/fn.nix b/fn.nix index 13e201b..72d2c59 100644 --- a/fn.nix +++ b/fn.nix @@ -1,84 +1,121 @@ -{ lib }: - +{lib}: with builtins; -with lib; - -rec { - ifelse = a: b: c: if a then b else c; +with lib; rec { + ifelse = a: b: c: + if a + then b + else c; fileContentsOr = a: b: (ifelse (pathIsRegularFile a) - a b); + a + b); cwd = builtins.getEnv "PWD"; # lst (string PATH) (string FILETYPE) (bool RETURNFULLPATH) - lst = { p ? cwd, t ? "regular", b ? false }: (lists.forEach + lst = { + p ? cwd, + t ? "regular", + b ? false, + }: (lists.forEach (attrNames (filterAttrs (n: v: v == t) (readDir p))) - (v: ((optionalString b "${p}/") + v))); - lsf = p: (lst { p = p; }); - lsd = p: (lst { p = p; t = "directory"; b = true; }); - lsfRec = p: b: flatten ((map (np: lsfRec np b) (lsd p)) ++ (lst { p = p; b = b; })); + (v: ((optionalString b "${p}/") + v))); + lsf = p: (lst {p = p;}); + lsd = p: (lst { + p = p; + t = "directory"; + b = true; + }); + lsfRec = p: b: + flatten ((map (np: lsfRec np b) (lsd p)) + ++ (lst { + p = p; + b = b; + })); hasAttrs = aList: d: (map - (a: - (ifelse (isList a) - (hasAttrByPath a d) - (hasAttr a d))) + (a: (ifelse (isList a) + (hasAttrByPath a d) + (hasAttr a d))) aList); # Not sure how list operations are implemented in Nix # This might be a tad bit inefficient. # TODO: look for better implementation (map is a builtin function so checking that probably won't help) # Sequentially checks elements of list (l) for condition (cond) and executes do on first match. - meetsConDo = cond: do: l: ifelse (l == []) false + meetsConDo = cond: do: l: + ifelse (l == []) false (let - h = (head l); - t = (tail l); - in ifelse (cond h) (do h) - (meetsConDo (cond) (do) (t))); - deps = p: ifelse (isAttrs p) (filter (p: isAttrs p) - (p.buildInputs ++ p.nativeBuildInputs ++ p.propagatedBuildInputs ++ p.propagatedNativeBuildInputs) - ) []; + h = head l; + t = tail l; + in + ifelse (cond h) (do h) + (meetsConDo cond do t)); + deps = p: + ifelse (isAttrs p) ( + filter (p: isAttrs p) + (p.buildInputs ++ p.nativeBuildInputs ++ p.propagatedBuildInputs ++ p.propagatedNativeBuildInputs) + ) []; importFilter = l: p: filter (n: elem (nameFromURL (toString n) ".") l) p; depsRec = ld: ifelse (ld == []) [] ((toList ld) ++ (depsRec (lists.unique (lists.flatten (map (d: deps d) (toList ld)))))); - isBroken = p: meetsConDo (s: ((hasAttrByPath s.path p) && (s.check (getAttrFromPath s.path p)))) (s: s.msg) - [ - { path = ["meta" "broken"]; msg = (warn "Package ${p.name} is marked as broken." true); check = m: m; } - { path = ["meta" "knownVulnerabilities" ]; msg = (warn "Package ${p.name} has known Vulnerabilities.." true); check = m: m != []; } - { path = ["name"]; msg = (warn "${p.name}: python2 is depricated." false); check = m: (strings.hasInfix "python2" m) || (strings.hasInfix "python-2" m); } - # not sure if the following test creates false positives (AFAIK every derivation/package needs to have an outPath) - # , definitely should catch all corner cases/everything that fails to evaluate. - { path = [ "outPath" ]; msg = (warn "Package ${p.name} has no outPath" true); check = m: !(tryEval m).success; } - ]; + isBroken = p: + meetsConDo (s: ((hasAttrByPath s.path p) && (s.check (getAttrFromPath s.path p)))) (s: s.msg) + [ + { + path = ["meta" "broken"]; + msg = warn "Package ${p.name} is marked as broken." true; + check = m: m; + } + { + path = ["meta" "knownVulnerabilities"]; + msg = warn "Package ${p.name} has known Vulnerabilities.." true; + check = m: m != []; + } + { + path = ["name"]; + msg = warn "${p.name}: python2 is depricated." false; + check = m: (strings.hasInfix "python2" m) || (strings.hasInfix "python-2" m); + } + # not sure if the following test creates false positives (AFAIK every derivation/package needs to have an outPath) + # , definitely should catch all corner cases/everything that fails to evaluate. + { + path = ["outPath"]; + msg = warn "Package ${p.name} has no outPath" true; + check = m: !(tryEval m).success; + } + ]; depsBroken = p: lists.any (p: (isBroken p)) (deps p); # No more magic 🧙 here 😢 # But at least it now (hopefully) checks ONLY dependencies (and all of them at that). - depsBrokenRec = p: (meetsConDo + depsBrokenRec = p: ( + meetsConDo (p: ifelse (depsBroken p) true (depsBrokenRec (deps p))) (p: true) (deps p) ); sopsHelper = template: names: options: let optionsIsFunction = (typeOf options) == "lambda"; - in listToAttrs (map - (name: { - name = template name; - value = ifelse optionsIsFunction (options name) options; - }) - names); + in + listToAttrs (map + (name: { + name = template name; + value = ifelse optionsIsFunction (options name) options; + }) + names); pkgFilter = ld: (filter (p: ( ifelse (isBroken p) - false - (ifelse (depsBrokenRec p) - (warn "Dependency of ${p.name} is marked as broken." false) - true) + false + (ifelse (depsBrokenRec p) + (warn "Dependency of ${p.name} is marked as broken." false) + true) )) ld); - makeOptionTypeList = path: (lists.forEach + makeOptionTypeList = path: ( + lists.forEach # get a list of all files ending in .nix in path (filter (filePath: hasSuffix ".nix" filePath) (lsfRec path true)) # remove leading path and trailing ".nix", replace every slash with "::" - (replaceStrings [ "${path}/" "/" ".nix" ] [ "" "::" "" ]) + (replaceStrings ["${path}/" "/" ".nix"] ["" "::" ""]) ); } diff --git a/machines/Lilim/configuration.nix b/machines/Lilim/configuration.nix index b55b4a4..c3b9bbc 100644 --- a/machines/Lilim/configuration.nix +++ b/machines/Lilim/configuration.nix @@ -1,6 +1,8 @@ -{ pkgs, lib, ... }: - { + pkgs, + lib, + ... +}: { services.cron.enable = false; networking.dhcpcd.extraConfig = "noarp"; @@ -8,10 +10,30 @@ # low latency audio stuff security.pam.loginLimits = [ - { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; } - { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; } - { domain = "@audio"; item = "nofile"; type = "soft"; value = "99999"; } - { domain = "@audio"; item = "nofile"; type = "hard"; value = "99999"; } + { + domain = "@audio"; + item = "memlock"; + type = "-"; + value = "unlimited"; + } + { + domain = "@audio"; + item = "rtprio"; + type = "-"; + value = "99"; + } + { + domain = "@audio"; + item = "nofile"; + type = "soft"; + value = "99999"; + } + { + domain = "@audio"; + item = "nofile"; + type = "hard"; + value = "99999"; + } ]; environment = { etc = { @@ -20,11 +42,11 @@ ''; }; variables = { - DSSI_PATH = "$HOME/.dssi:$HOME/.nix-profile/lib/dssi:/run/current-system/sw/lib/dssi"; + DSSI_PATH = "$HOME/.dssi:$HOME/.nix-profile/lib/dssi:/run/current-system/sw/lib/dssi"; LADSPA_PATH = "$HOME/.ladspa:$HOME/.nix-profile/lib/ladspa:/run/current-system/sw/lib/ladspa"; - LV2_PATH = "$HOME/.lv2:$HOME/.nix-profile/lib/lv2:/run/current-system/sw/lib/lv2"; - LXVST_PATH = "$HOME/.lxvst:$HOME/.nix-profile/lib/lxvst:/run/current-system/sw/lib/lxvst"; - VST_PATH = "$HOME/.vst:$HOME/.nix-profile/lib/vst:/run/current-system/sw/lib/vst"; + LV2_PATH = "$HOME/.lv2:$HOME/.nix-profile/lib/lv2:/run/current-system/sw/lib/lv2"; + LXVST_PATH = "$HOME/.lxvst:$HOME/.nix-profile/lib/lxvst:/run/current-system/sw/lib/lxvst"; + VST_PATH = "$HOME/.vst:$HOME/.nix-profile/lib/vst:/run/current-system/sw/lib/vst"; }; }; services = { @@ -38,8 +60,8 @@ }; }; boot = { - kernelModules = [ "snd-usb-audio" "snd-aloop" "snd-seq" "snd-rawmidi" ]; - kernelParams = [ "threadirq" ]; + kernelModules = ["snd-usb-audio" "snd-aloop" "snd-seq" "snd-rawmidi"]; + kernelParams = ["threadirq"]; extraModprobeConfig = '' options snd-usb-audio nrpacks=1 ''; diff --git a/machines/Lilim/hardware-configuration.nix b/machines/Lilim/hardware-configuration.nix index 70ac573..ea05ba1 100644 --- a/machines/Lilim/hardware-configuration.nix +++ b/machines/Lilim/hardware-configuration.nix @@ -1,32 +1,35 @@ -{ nixpkgs, config, pkgs, ... }: - -let +{ + nixpkgs, + config, + pkgs, + ... +}: let cfg = config.machine; in { - imports = [ "${nixpkgs}/nixos/modules/installer/scan/not-detected.nix" ]; + imports = ["${nixpkgs}/nixos/modules/installer/scan/not-detected.nix"]; boot = { loader.systemd-boot = { enable = true; -# signed = true; -# signing-key = "${cfg.secretPath}/secureboot/db.key"; -# signing-certificate = "${cfg.secretPath}/secureboot/db.crt"; + # signed = true; + # signing-key = "${cfg.secretPath}/secureboot/db.key"; + # signing-certificate = "${cfg.secretPath}/secureboot/db.crt"; }; loader.efi.canTouchEfiVariables = true; tmp = { useTmpfs = true; - cleanOnBoot= true; + cleanOnBoot = true; }; kernelPackages = pkgs.linuxPackages_latest; - initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "rtsx_pci_sdmmc" ]; - kernelModules = [ "acpi_call" "i915" "kvm-intel" "uinput" ]; + initrd.availableKernelModules = ["xhci_pci" "ahci" "sd_mod" "rtsx_pci_sdmmc"]; + kernelModules = ["acpi_call" "i915" "kvm-intel" "uinput"]; # 5_10 breaks my touchpad/mouse buttons # https://bbs.archlinux.org/viewtopic.php?id=254885 # maybe modprobe hid_rmi or i2c_i801 # blacklistedKernelModules = [ "i2c_i801" ]; - extraModulePackages = with config.boot.kernelPackages; [ acpi_call ]; #pkgs.gitpkgs.linuxPackages_latest.hid-nintendo ]; - kernelParams = [ "intel_iommu=on" ]; + extraModulePackages = with config.boot.kernelPackages; [acpi_call]; #pkgs.gitpkgs.linuxPackages_latest.hid-nintendo ]; + kernelParams = ["intel_iommu=on"]; extraModprobeConfig = '' options i915 enable_fbc=1 enable_guc=3 ''; @@ -37,26 +40,26 @@ in { }; }; - fileSystems."/" = - { device = "/dev/disk/by-uuid/b37b48a8-5dcb-4f4d-ad71-1b26500b3e5f"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/b37b48a8-5dcb-4f4d-ad71-1b26500b3e5f"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/546A-A3D1"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/546A-A3D1"; + fsType = "vfat"; + }; hardware = { - firmware = with pkgs; [ firmwareLinuxNonfree ]; + firmware = with pkgs; [firmwareLinuxNonfree]; cpu.intel.updateMicrocode = true; enableAllFirmware = false; ksm.enable = true; opengl = { driSupport = true; - extraPackages = with pkgs; [ intel-media-driver libvdpau-va-gl libva (vaapiIntel.override {enableHybridCodec = true;}) vaapiVdpau intel-media-driver ]; + extraPackages = with pkgs; [intel-media-driver libvdpau-va-gl libva (vaapiIntel.override {enableHybridCodec = true;}) vaapiVdpau intel-media-driver]; driSupport32Bit = true; - extraPackages32 = with pkgs.pkgsi686Linux; [ libvdpau-va-gl libva (vaapiIntel.override {enableHybridCodec = true;}) vaapiVdpau ]; + extraPackages32 = with pkgs.pkgsi686Linux; [libvdpau-va-gl libva (vaapiIntel.override {enableHybridCodec = true;}) vaapiVdpau]; }; pulseaudio = { @@ -81,7 +84,7 @@ in { }; services = { upower.enable = true; - xserver.videoDrivers = [ "intel" ]; + xserver.videoDrivers = ["intel"]; }; time.timeZone = "Europe/Berlin"; diff --git a/machines/Lilim/options.nix b/machines/Lilim/options.nix index 6f64dd9..90c7b04 100644 --- a/machines/Lilim/options.nix +++ b/machines/Lilim/options.nix @@ -1,8 +1,9 @@ -{ pkgs, lib, ... }: - -with lib; - { + pkgs, + lib, + ... +}: +with lib; { imports = [ ../../options/copySysConf.nix ]; @@ -13,7 +14,12 @@ with lib; enable = true; waitOnline = false; }; - administrators = [ { name = "derped"; id = 1337; } ]; + administrators = [ + { + name = "derped"; + id = 1337; + } + ]; conffiles = [ "etcfiles" "etcvars" @@ -59,15 +65,26 @@ with lib; "cups" "mullvad" "mariaDB" - "docker" "podman" + "docker" + "podman" ]; firewall = { enable = true; allowPing = true; - allowedUDPPorts = [ 24642 ]; - allowedTCPPorts = [ 24642 ]; - allowedUDPPortRanges = [ { from = 1714; to = 1764; } ]; - allowedTCPPortRanges = [ { from = 1714; to = 1764; } ]; + allowedUDPPorts = [24642]; + allowedTCPPorts = [24642]; + allowedUDPPortRanges = [ + { + from = 1714; + to = 1764; + } + ]; + allowedTCPPortRanges = [ + { + from = 1714; + to = 1764; + } + ]; }; }; diff --git a/machines/Lilim/sops.nix b/machines/Lilim/sops.nix index 85c8b25..3da6c4c 100644 --- a/machines/Lilim/sops.nix +++ b/machines/Lilim/sops.nix @@ -1,6 +1,8 @@ -{ config, lib, ... }: - { + config, + lib, + ... +}: { sops = { defaultSopsFile = ./secrets.yaml; age = { diff --git a/machines/Marid/configuration.nix b/machines/Marid/configuration.nix index a15a7f1..9833363 100644 --- a/machines/Marid/configuration.nix +++ b/machines/Marid/configuration.nix @@ -1,6 +1,4 @@ -{ pkgs, ... }: - -{ +{pkgs, ...}: { services.cron.enable = false; security.pki.certificateFiles = [ ./certs/proxy diff --git a/machines/Marid/hardware-configuration.nix b/machines/Marid/hardware-configuration.nix index 72ccd78..af21d61 100644 --- a/machines/Marid/hardware-configuration.nix +++ b/machines/Marid/hardware-configuration.nix @@ -1,9 +1,12 @@ -{ config, pkgs, modulesPath, ... }: - -let +{ + config, + pkgs, + modulesPath, + ... +}: let cfg = config.machine; in { - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + imports = [(modulesPath + "/installer/scan/not-detected.nix")]; boot = { loader.systemd-boot = { @@ -12,12 +15,12 @@ in { loader.efi.canTouchEfiVariables = true; tmp = { useTmpfs = true; - cleanOnBoot= true; + cleanOnBoot = true; }; kernelPackages = pkgs.linuxPackages_latest; - initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; - kernelModules = [ "kvm-amd" ]; + initrd.availableKernelModules = ["nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc"]; + kernelModules = ["kvm-amd"]; kernelParams = [ # get backlight service to work part one (fixes systemd backlight service) "acpi_backlight=native" @@ -29,18 +32,18 @@ in { }; }; - fileSystems."/" = - { device = "/dev/disk/by-uuid/cf8db7d5-5da7-4fb9-818d-ed5dd2815f0d"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/cf8db7d5-5da7-4fb9-818d-ed5dd2815f0d"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/96E4-9DF3"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/96E4-9DF3"; + fsType = "vfat"; + }; hardware = { - firmware = with pkgs; [ firmwareLinuxNonfree ]; + firmware = with pkgs; [firmwareLinuxNonfree]; enableAllFirmware = true; ksm.enable = true; opengl = { diff --git a/machines/Marid/options.nix b/machines/Marid/options.nix index 70e472e..1e239ee 100644 --- a/machines/Marid/options.nix +++ b/machines/Marid/options.nix @@ -1,15 +1,21 @@ -{ pkgs, lib, ... }: - -with lib; - { + pkgs, + lib, + ... +}: +with lib; { imports = [ ../../options/copySysConf.nix ]; config.machine = { allowUnfree = true; hostName = "Marid"; - administrators = [ { name = "derped"; id = 1337; } ]; + administrators = [ + { + name = "derped"; + id = 1337; + } + ]; conffiles = [ "etcfiles" "etcvars" @@ -37,7 +43,7 @@ with lib; "emacs::org" "emacs::php-mode" "emacs::web-mode" - "emacs::yasnippet" + "emacs::yasnippet" "extra" "mail_utils" "python3" @@ -53,10 +59,10 @@ with lib; firewall = { enable = true; allowPing = true; - allowedUDPPorts = [ ]; - allowedTCPPorts = [ ]; - allowedUDPPortRanges = [ ]; - allowedTCPPortRanges = [ ]; + allowedUDPPorts = []; + allowedTCPPorts = []; + allowedUDPPortRanges = []; + allowedTCPPortRanges = []; }; }; diff --git a/machines/Marid/sops.nix b/machines/Marid/sops.nix index 85c8b25..3da6c4c 100644 --- a/machines/Marid/sops.nix +++ b/machines/Marid/sops.nix @@ -1,6 +1,8 @@ -{ config, lib, ... }: - { + config, + lib, + ... +}: { sops = { defaultSopsFile = ./secrets.yaml; age = { diff --git a/machines/Ophanim/configuration.nix b/machines/Ophanim/configuration.nix index 3bb954d..5a38bc1 100644 --- a/machines/Ophanim/configuration.nix +++ b/machines/Ophanim/configuration.nix @@ -1,17 +1,16 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). - { system.autoUpgrade.enable = false; -# services.vsftp = { -# enable = true; -# ssl_sslv3 = true; -# forceLocalDataSSL = true; -# writeEnable = false; -# userlist = []; -# }; + # services.vsftp = { + # enable = true; + # ssl_sslv3 = true; + # forceLocalDataSSL = true; + # writeEnable = false; + # userlist = []; + # }; services.haveged.enable = true; programs.zsh.promptInit = ''PROMPT="%(!.%B%F{magenta}.%B%F{cyan}%n@)%m %F{blue}%(!.%1~.%~) ''${vcs_info_msg_0_}%F{blue}%(!.#.$)%k%b%f "''; diff --git a/machines/Ophanim/hardware-configuration.nix b/machines/Ophanim/hardware-configuration.nix index ceb6e68..c9c6410 100644 --- a/machines/Ophanim/hardware-configuration.nix +++ b/machines/Ophanim/hardware-configuration.nix @@ -1,15 +1,17 @@ -{ nixpkgs, pkgs, ... }: - { - imports = - [ "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" - ]; + nixpkgs, + pkgs, + ... +}: { + imports = [ + "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" + ]; boot = { - initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" "sr_mod" ]; + initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" "sr_mod"]; kernelPackages = pkgs.linuxPackages_latest; - kernelModules = [ ]; - extraModulePackages = [ ]; + kernelModules = []; + extraModulePackages = []; loader.grub = { enable = true; device = "/dev/sda"; # or "nodev" for efi only @@ -18,10 +20,10 @@ time.timeZone = "Europe/Berlin"; - fileSystems."/" = - { device = "/dev/disk/by-uuid/fa0c2ff3-59f9-4c00-8153-c2c2ef0f0e84"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/fa0c2ff3-59f9-4c00-8153-c2c2ef0f0e84"; + fsType = "ext4"; + }; - swapDevices = [ ]; + swapDevices = []; } diff --git a/machines/Ophanim/options.nix b/machines/Ophanim/options.nix index 25fa46e..f6d90cf 100644 --- a/machines/Ophanim/options.nix +++ b/machines/Ophanim/options.nix @@ -1,15 +1,26 @@ -{ config, lib, ... }: - -with lib; - -let +{ + config, + lib, + ... +}: +with lib; let cfg = config.machine; in { config.machine = rec { hostName = "Ophanim"; domain = "ophanim.de"; - administrators = [ { name = "derped"; id = 1337; } ]; - mailAccounts = [ { name = "derped"; aliases = [ "postmaster" "baensch" ]; } ]; + administrators = [ + { + name = "derped"; + id = 1337; + } + ]; + mailAccounts = [ + { + name = "derped"; + aliases = ["postmaster" "baensch"]; + } + ]; allowUnfree = true; conffiles = [ "etcvars" @@ -23,26 +34,40 @@ in { services = [ "acme" "gitea" -# "hydra" + # "hydra" "mailserver" "mariaDB" "nextcloud" "nginx" "openssh" ]; - vHosts = (let base = domain; in [ - { domain = base; service = "simple"; } -# { domain = "builder.${base}"; service = "hydra"; } -# { domain = "cache.${base}"; service = "cache"; } - { domain = "storage.${base}"; service = "nextcloud"; } - { domain = "mail.${base}"; service = "mail"; } - { domain = "git.${base}"; service = "gitea"; } - ]); + vHosts = let + base = domain; + in [ + { + domain = base; + service = "simple"; + } + # { domain = "builder.${base}"; service = "hydra"; } + # { domain = "cache.${base}"; service = "cache"; } + { + domain = "storage.${base}"; + service = "nextcloud"; + } + { + domain = "mail.${base}"; + service = "mail"; + } + { + domain = "git.${base}"; + service = "gitea"; + } + ]; firewall = { enable = true; allowPing = false; - allowedUDPPorts = [ 22 80 443 7776 ]; - allowedTCPPorts = [ 80 443 7776 ]; + allowedUDPPorts = [22 80 443 7776]; + allowedTCPPorts = [80 443 7776]; }; }; } diff --git a/machines/Ophanim/sops.nix b/machines/Ophanim/sops.nix index 85c8b25..3da6c4c 100644 --- a/machines/Ophanim/sops.nix +++ b/machines/Ophanim/sops.nix @@ -1,6 +1,8 @@ -{ config, lib, ... }: - { + config, + lib, + ... +}: { sops = { defaultSopsFile = ./secrets.yaml; age = { diff --git a/options/copySysConf.nix b/options/copySysConf.nix index a6a7888..c7eb5ad 100644 --- a/options/copySysConf.nix +++ b/options/copySysConf.nix @@ -1,21 +1,26 @@ -{ config, pkgs, lib, ... }: - -with lib; - -let +{ + config, + pkgs, + lib, + ... +}: +with lib; let cfg = config.system.copySysConf; cfgPath = ../.; - copySysConf = if !(isStorePath cfgPath) then pkgs.stdenv.mkDerivation rec { - name = "NixOS_Configuration-${version}"; - version = commitIdFromGitRepo (cfgPath + "/.git"); + copySysConf = + if !(isStorePath cfgPath) + then + pkgs.stdenv.mkDerivation rec { + name = "NixOS_Configuration-${version}"; + version = commitIdFromGitRepo (cfgPath + "/.git"); - src = cleanSource cfgPath; - - installPhase = '' - cp -R ./. $out - ''; - } else (builtins.toPath ../.); + src = cleanSource cfgPath; + installPhase = '' + cp -R ./. $out + ''; + } + else (builtins.toPath ../.); in { options.system.copySysConf = { enable = mkOption { diff --git a/options/emacs-init-defaults.nix b/options/emacs-init-defaults.nix index 261cd09..0e755e9 100644 --- a/options/emacs-init-defaults.nix +++ b/options/emacs-init-defaults.nix @@ -1,20 +1,15 @@ # Original Source: # https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init-defaults.nix (49ff2d63e867c09e658c959c0d8a73d641061c30) - # MIT License - # Copyright (c) 2019 Robert Helgesson - # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: - # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. - # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,11 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - - -{ pkgs, ... }: - -{ +{pkgs, ...}: { programs.emacs.init.usePackage = { deadgrep = { config = '' diff --git a/options/emacs-init.nix b/options/emacs-init.nix index c39699c..2cc13dc 100644 --- a/options/emacs-init.nix +++ b/options/emacs-init.nix @@ -1,20 +1,15 @@ # Original Source: # https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init.nix (d27525db3358b9463fab1b4a7739cb77e27b768c) - # MIT License - # Copyright (c) 2019 Robert Helgesson - # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: - # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. - # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,14 +17,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - - -{ config, lib, pkgs, ... }: - -with lib; - -let - +{ + config, + lib, + pkgs, + ... +}: +with lib; let cfg = config.programs.emacs.init; packageFunctionType = mkOptionType { @@ -39,15 +33,19 @@ let merge = mergeOneOption; }; - usePackageType = types.submodule ({ name, config, ... }: { + usePackageType = types.submodule ({ + name, + config, + ... + }: { options = { enable = mkEnableOption "Emacs package ${name}"; package = mkOption { type = types.either - (types.str // { description = "name of package"; }) - packageFunctionType; + (types.str // {description = "name of package";}) + packageFunctionType; default = name; description = '' The package to use for this module. Either the package name @@ -83,7 +81,10 @@ let chords = mkOption { type = types.attrsOf types.str; default = {}; - example = { "jj" = "ace-jump-char-mode"; "jk" = "ace-jump-word-mode"; }; + example = { + "jj" = "ace-jump-char-mode"; + "jk" = "ace-jump-word-mode"; + }; description = '' The entries to use for . ''; @@ -108,7 +109,10 @@ let bind = mkOption { type = types.attrsOf types.str; default = {}; - example = { "M-" = "drag-stuff-up"; "M-" = "drag-stuff-down"; }; + example = { + "M-" = "drag-stuff-up"; + "M-" = "drag-stuff-down"; + }; description = '' The entries to use for . ''; @@ -117,7 +121,7 @@ let bindLocal = mkOption { type = types.attrsOf (types.attrsOf types.str); default = {}; - example = { helm-command-map = { "C-c h" = "helm-execute-persistent-action"; }; }; + example = {helm-command-map = {"C-c h" = "helm-execute-persistent-action";};}; description = '' The entries to use for local keymaps in . ''; @@ -126,7 +130,7 @@ let bindKeyMap = mkOption { type = types.attrsOf types.str; default = {}; - example = { "C-c p" = "projectile-command-map"; }; + example = {"C-c p" = "projectile-command-map";}; description = '' The entries to use for . ''; @@ -181,51 +185,51 @@ let }; config = mkIf config.enable { - assembly = - let - quoted = v: ''"${escape ["\""] v}"''; - mkBindHelper = cmd: prefix: bs: - optionals (bs != {}) ( - [ ":${cmd} (${prefix}" ] - ++ mapAttrsToList (n: v: " (${quoted n} . ${v})") bs - ++ [ ")" ] + assembly = let + quoted = v: ''"${escape ["\""] v}"''; + mkBindHelper = cmd: prefix: bs: + optionals (bs != {}) ( + [":${cmd} (${prefix}"] + ++ mapAttrsToList (n: v: " (${quoted n} . ${v})") bs + ++ [")"] ); - mkAfter = vs: optional (vs != []) ":after (${toString vs})"; - mkCommand = vs: optional (vs != []) ":commands (${toString vs})"; - mkDiminish = vs: optional (vs != []) ":diminish (${toString vs})"; - mkMode = map (v: ":mode ${v}"); - mkBind = mkBindHelper "bind" ""; - mkBindLocal = bs: - let - mkMap = n: v: mkBindHelper "bind" ":map ${n}" v; - in - flatten (mapAttrsToList mkMap bs); - mkBindKeyMap = mkBindHelper "bind-keymap" ""; - mkChords = mkBindHelper "chords" ""; - mkHook = map (v: ":hook ${v}"); - mkDefer = v: - if isBool v then optional v ":defer t" - else [ ":defer ${toString v}" ]; - mkDemand = v: optional v ":demand t"; + mkAfter = vs: optional (vs != []) ":after (${toString vs})"; + mkCommand = vs: optional (vs != []) ":commands (${toString vs})"; + mkDiminish = vs: optional (vs != []) ":diminish (${toString vs})"; + mkMode = map (v: ":mode ${v}"); + mkBind = mkBindHelper "bind" ""; + mkBindLocal = bs: let + mkMap = n: v: mkBindHelper "bind" ":map ${n}" v; in - concatStringsSep "\n " ( - [ "(use-package ${name}" ] - ++ mkAfter config.after - ++ mkBind config.bind - ++ mkBindKeyMap config.bindKeyMap - ++ mkBindLocal config.bindLocal - ++ mkChords config.chords - ++ mkCommand config.command - ++ mkDefer config.defer - ++ mkDemand config.demand - ++ mkDiminish config.diminish - ++ mkHook config.hook - ++ mkMode config.mode - ++ optionals (config.init != "") [ ":init" config.init ] - ++ optionals (config.config != "") [ ":config" config.config ] - ++ optional (config.extraConfig != "") config.extraConfig - ) + ")"; + flatten (mapAttrsToList mkMap bs); + mkBindKeyMap = mkBindHelper "bind-keymap" ""; + mkChords = mkBindHelper "chords" ""; + mkHook = map (v: ":hook ${v}"); + mkDefer = v: + if isBool v + then optional v ":defer t" + else [":defer ${toString v}"]; + mkDemand = v: optional v ":demand t"; + in + concatStringsSep "\n " ( + ["(use-package ${name}"] + ++ mkAfter config.after + ++ mkBind config.bind + ++ mkBindKeyMap config.bindKeyMap + ++ mkBindLocal config.bindLocal + ++ mkChords config.chords + ++ mkCommand config.command + ++ mkDefer config.defer + ++ mkDemand config.demand + ++ mkDiminish config.diminish + ++ mkHook config.hook + ++ mkMode config.mode + ++ optionals (config.init != "") [":init" config.init] + ++ optionals (config.config != "") [":config" config.config] + ++ optional (config.extraConfig != "") config.extraConfig + ) + + ")"; }; }); @@ -234,17 +238,20 @@ let ${pkgConfStr}) ''; - mkRecommendedOption = type: extraDescription: mkOption { - type = types.bool; - default = false; - example = true; - description = '' - Whether to enable recommended ${type} settings. - '' + optionalString (extraDescription != "") '' - - ${extraDescription} - ''; - }; + mkRecommendedOption = type: extraDescription: + mkOption { + type = types.bool; + default = false; + example = true; + description = + '' + Whether to enable recommended ${type} settings. + '' + + optionalString (extraDescription != "") '' + + ${extraDescription} + ''; + }; # Recommended GC settings. gcSettings = '' @@ -285,7 +292,7 @@ let hasBind = any (p: p.bind != {}) (attrValues cfg.usePackage); # Whether the configuration makes use of `:chords`. - hasChords = any ( p: p.chords != {}) (attrValues cfg.usePackage); + hasChords = any (p: p.chords != {}) (attrValues cfg.usePackage); usePackageSetup = '' @@ -300,8 +307,10 @@ let ;; To help fixing issues during startup. (setq use-package-verbose ${ - if cfg.usePackageVerbose then "t" else "nil" - })) + if cfg.usePackageVerbose + then "t" + else "nil" + })) '' + optionalString hasDiminish '' ;; For :diminish in (use-package). @@ -317,53 +326,51 @@ let :config (key-chord-mode 1)) ''; - initFile = '' - ;;; hm-init.el --- Emacs configuration à la Home Manager. - ;; - ;; -*- lexical-binding: t; -*- - ;; - ;;; Commentary: - ;; - ;; A configuration generated from a Nix based configuration by - ;; Home Manager. - ;; - ;;; Code: + initFile = + '' + ;;; hm-init.el --- Emacs configuration à la Home Manager. + ;; + ;; -*- lexical-binding: t; -*- + ;; + ;;; Commentary: + ;; + ;; A configuration generated from a Nix based configuration by + ;; Home Manager. + ;; + ;;; Code: - ${optionalString cfg.startupTimer '' - ;; Remember when configuration started. See bottom for rest of this. - ;; Idea taken from http://writequit.org/org/settings.html. - (defconst emacs-start-time (current-time)) - ''} + ${optionalString cfg.startupTimer '' + ;; Remember when configuration started. See bottom for rest of this. + ;; Idea taken from http://writequit.org/org/settings.html. + (defconst emacs-start-time (current-time)) + ''} - ${optionalString cfg.recommendedGcSettings gcSettings} + ${optionalString cfg.recommendedGcSettings gcSettings} - ${cfg.prelude} + ${cfg.prelude} - ${usePackageSetup} - '' - + concatStringsSep "\n\n" + ${usePackageSetup} + '' + + concatStringsSep "\n\n" (map (getAttr "assembly") - (filter (getAttr "enable") - (attrValues cfg.usePackage))) - + '' + (filter (getAttr "enable") + (attrValues cfg.usePackage))) + + '' - ${cfg.postlude} + ${cfg.postlude} - ${optionalString cfg.startupTimer '' - ;; Make a note of how long the configuration part of the start took. - (let ((elapsed (float-time (time-subtract (current-time) - emacs-start-time)))) - (message "Loading settings...done (%.3fs)" elapsed)) - ''} + ${optionalString cfg.startupTimer '' + ;; Make a note of how long the configuration part of the start took. + (let ((elapsed (float-time (time-subtract (current-time) + emacs-start-time)))) + (message "Loading settings...done (%.3fs)" elapsed)) + ''} - (provide 'hm-init) - ;; hm-init.el ends here - ''; - -in - -{ - imports = [ ./emacs-init-defaults.nix ]; + (provide 'hm-init) + ;; hm-init.el ends here + ''; +in { + imports = [./emacs-init-defaults.nix]; options.programs.emacs.init = { enable = mkEnableOption "Emacs configuration"; @@ -412,29 +419,31 @@ in }; config = mkIf cfg.enable { - machine.pkgsets.emacs.pkgs = epkgs: - let - getPkg = v: - if isFunction v then [ (v epkgs) ] - else optional (isString v && hasAttr v epkgs) epkgs.${v}; - in - [ epkgs.use-package ] - ++ optional hasBind epkgs.bind-key - ++ optional hasDiminish epkgs.diminish - ++ optional hasChords epkgs.use-package-chords - ++ ( - concatMap (v: getPkg (v.package)) - (builtins.attrValues cfg.usePackage) - ); + machine.pkgsets.emacs.pkgs = epkgs: let + getPkg = v: + if isFunction v + then [(v epkgs)] + else optional (isString v && hasAttr v epkgs) epkgs.${v}; + in + [epkgs.use-package] + ++ optional hasBind epkgs.bind-key + ++ optional hasDiminish epkgs.diminish + ++ optional hasChords epkgs.use-package-chords + ++ ( + concatMap (v: getPkg (v.package)) + (builtins.attrValues cfg.usePackage) + ); # use lucid as toolkit; emacs will otherwise crash quite frequently when run in daemon mode # https://gitlab.gnome.org/GNOME/gtk/issues/221 machine.pkgsets.emacs.pkgwrap = let - emacsWithPackages = (pkgs.emacsPackagesFor - (pkgs.emacs.override { - withGTK2 = false; - withGTK3 = false; - })).emacsWithPackages; + emacsWithPackages = + (pkgs.emacsPackagesFor + (pkgs.emacs.override { + withGTK2 = false; + withGTK3 = false; + })) + .emacsWithPackages; in (emacsWithPackages config.machine.pkgsets.emacs.pkgs); environment.systemPackages = [ diff --git a/options/machine.nix b/options/machine.nix index a61c467..bbb1ca4 100644 --- a/options/machine.nix +++ b/options/machine.nix @@ -1,9 +1,11 @@ -{ config, lib, fn, ... }: - +{ + config, + lib, + fn, + ... +}: with builtins; -with lib; - -let +with lib; let cfg = config.machine; pkgsetList = fn.makeOptionTypeList (toString ../pkgsets); serviceList = fn.makeOptionTypeList (toString ../services); @@ -11,8 +13,8 @@ let name = pname; value = rec { pkgwrap = mkOption { - type = with types; oneOf [ package (listOf package) ]; - default = (fn.pkgFilter cfg.pkgsets."${pname}".pkgs); + type = with types; oneOf [package (listOf package)]; + default = fn.pkgFilter cfg.pkgsets."${pname}".pkgs; description = '' Package Wrapper for packages using a wrapper function (like python, emacs, haskell, ...) ''; @@ -29,8 +31,8 @@ let in { options.machine = { pkgs = mkOption { - type = (types.listOf (types.enum pkgsetList)); - default = [ "base" ]; + type = types.listOf (types.enum pkgsetList); + default = ["base"]; description = '' The list of metapackages to be installed. ''; @@ -38,7 +40,7 @@ in { # Package names containing '::' are sub packages and should not have their own pkgset. pkgsets = listToAttrs (map pkgOption (lists.filter (v: !(strings.hasInfix "::" v)) pkgsetList)); services = mkOption { - type = (types.listOf (types.enum serviceList)); + type = types.listOf (types.enum serviceList); default = []; description = '' List of services to be enabled. @@ -46,7 +48,7 @@ in { }; conffiles = mkOption { type = types.listOf types.str; - default = [ "zsh" ]; + default = ["zsh"]; description = '' List of configuration files to be enabled. ''; @@ -116,7 +118,7 @@ in { }; }; imports = [ - (mkAliasOptionModule [ "machine" "firewall" ] [ "networking" "firewall" ]) - (mkAliasOptionModule [ "machine" "allowUnfree" ] [ "nixpkgs" "config" "allowUnfree" ]) + (mkAliasOptionModule ["machine" "firewall"] ["networking" "firewall"]) + (mkAliasOptionModule ["machine" "allowUnfree"] ["nixpkgs" "config" "allowUnfree"]) ]; } diff --git a/options/mailman3/core.nix b/options/mailman3/core.nix index dcb61e7..41afd0f 100644 --- a/options/mailman3/core.nix +++ b/options/mailman3/core.nix @@ -1,10 +1,29 @@ -{ stdenv, buildPythonPackage, fetchgit -, aiosmtpd, alembic, atpublic, click, dnspython, falcon, flufl_bounce, flufl_i18n, flufl_lock -, importlib-resources, lazr_config, passlib, requests, sqlalchemy -, zope_component, zope_configuration, zope_event, zope_interface -# optional database dependencies -, pymysql, psycopg2 }: - +{ + stdenv, + buildPythonPackage, + fetchgit, + aiosmtpd, + alembic, + atpublic, + click, + dnspython, + falcon, + flufl_bounce, + flufl_i18n, + flufl_lock, + importlib-resources, + lazr_config, + passlib, + requests, + sqlalchemy, + zope_component, + zope_configuration, + zope_event, + zope_interface, + # optional database dependencies + pymysql, + psycopg2, +}: buildPythonPackage rec { name = "mailman3_core-${version}"; version = "3.2.2"; @@ -33,7 +52,8 @@ buildPythonPackage rec { zope_configuration zope_event zope_interface - pymysql psycopg2 + pymysql + psycopg2 ]; doCheck = false; @@ -48,7 +68,7 @@ buildPythonPackage rec { meta = with stdenv.lib; { description = "GNU Mailman, a mailing list management system"; license = licenses.gpl3; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; []; homepage = http://list.org/; }; } diff --git a/options/mailman3/extraPackages/aiosmtpd.nix b/options/mailman3/extraPackages/aiosmtpd.nix index 7eac2a8..e72a047 100644 --- a/options/mailman3/extraPackages/aiosmtpd.nix +++ b/options/mailman3/extraPackages/aiosmtpd.nix @@ -1,14 +1,18 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, atpublic }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + atpublic, +}: buildPythonPackage rec { - pname = "aiosmtpd"; - version = "1.2"; + pname = "aiosmtpd"; + version = "1.2"; - src = fetchPypi { - inherit pname version; - sha256 = "1xdfk741pjmz1cm8dsi4n5vq4517i175rm94696m3f7kcgk7xsmp"; - }; - doCheck = false; - propagatedBuildInputs = [ atpublic ]; + src = fetchPypi { + inherit pname version; + sha256 = "1xdfk741pjmz1cm8dsi4n5vq4517i175rm94696m3f7kcgk7xsmp"; + }; + doCheck = false; + propagatedBuildInputs = [atpublic]; } diff --git a/options/mailman3/extraPackages/atpublic.nix b/options/mailman3/extraPackages/atpublic.nix index a243c98..a23a8a2 100644 --- a/options/mailman3/extraPackages/atpublic.nix +++ b/options/mailman3/extraPackages/atpublic.nix @@ -1,13 +1,17 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, +}: buildPythonPackage rec { - pname = "atpublic"; - version = "1.0"; + pname = "atpublic"; + version = "1.0"; - src = fetchPypi { - inherit pname version; - sha256 = "0i3sbxkdlbb4560rrlmwwd5y4ps7k73lp4d8wnmd7ag9k426gjkx"; - }; - doCheck = false; -# propagatedBuildInputs = []; + src = fetchPypi { + inherit pname version; + sha256 = "0i3sbxkdlbb4560rrlmwwd5y4ps7k73lp4d8wnmd7ag9k426gjkx"; + }; + doCheck = false; + # propagatedBuildInputs = []; } diff --git a/options/mailman3/extraPackages/flufl_bounce.nix b/options/mailman3/extraPackages/flufl_bounce.nix index 567c628..7ed3bef 100644 --- a/options/mailman3/extraPackages/flufl_bounce.nix +++ b/options/mailman3/extraPackages/flufl_bounce.nix @@ -1,6 +1,11 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, atpublic, zope_interface }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + atpublic, + zope_interface, +}: buildPythonPackage rec { name = "${pname}-${version}"; pname = "flufl.bounce"; @@ -11,7 +16,7 @@ buildPythonPackage rec { sha256 = "0k5kjqa3x6gvwwxyzb2vwi1g1i6asm1zw5fivylxz3d583y4kid2"; }; - propagatedBuildInputs = [ atpublic zope_interface ]; + propagatedBuildInputs = [atpublic zope_interface]; doCheck = false; } diff --git a/options/mailman3/extraPackages/flufl_i18n.nix b/options/mailman3/extraPackages/flufl_i18n.nix index c2f3f5d..fa29a29 100644 --- a/options/mailman3/extraPackages/flufl_i18n.nix +++ b/options/mailman3/extraPackages/flufl_i18n.nix @@ -1,6 +1,10 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, atpublic }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + atpublic, +}: buildPythonPackage rec { name = "${pname}-${version}"; pname = "flufl.i18n"; @@ -11,7 +15,7 @@ buildPythonPackage rec { sha256 = "1csgds59nx0ann9v2alqr69lakp1cnc1ikmbgn96l6n23js7c2ah"; }; - propagatedBuildInputs = [ atpublic ]; + propagatedBuildInputs = [atpublic]; doCheck = false; } diff --git a/options/mailman3/extraPackages/flufl_lock.nix b/options/mailman3/extraPackages/flufl_lock.nix index cb82853..e3fcf8a 100644 --- a/options/mailman3/extraPackages/flufl_lock.nix +++ b/options/mailman3/extraPackages/flufl_lock.nix @@ -1,6 +1,10 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, atpublic }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + atpublic, +}: buildPythonPackage rec { name = "${pname}-${version}"; pname = "flufl.lock"; @@ -11,7 +15,7 @@ buildPythonPackage rec { sha256 = "0nzzd6l30ff6cwsrlrb94xzfja4wkyrqv3ydc6cz0hdbr766mmm8"; }; - propagatedBuildInputs = [ atpublic ]; + propagatedBuildInputs = [atpublic]; doCheck = false; } diff --git a/options/mailman3/extraPackages/lazr_config.nix b/options/mailman3/extraPackages/lazr_config.nix index 23e912f..8216e01 100644 --- a/options/mailman3/extraPackages/lazr_config.nix +++ b/options/mailman3/extraPackages/lazr_config.nix @@ -1,6 +1,10 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, lazr_delegates }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + lazr_delegates, +}: buildPythonPackage rec { name = "${pname}-${version}"; pname = "lazr.config"; @@ -11,7 +15,7 @@ buildPythonPackage rec { sha256 = "1s7pyvlq06qjrkaw9r6nc290lb095n25ybzgavvy51ygpxkgqxwn"; }; - propagatedBuildInputs = [ lazr_delegates ]; + propagatedBuildInputs = [lazr_delegates]; doCheck = false; } diff --git a/options/mailman3/extraPackages/lazr_delegates.nix b/options/mailman3/extraPackages/lazr_delegates.nix index ee12fc2..ace5efa 100644 --- a/options/mailman3/extraPackages/lazr_delegates.nix +++ b/options/mailman3/extraPackages/lazr_delegates.nix @@ -1,6 +1,11 @@ -{ stdenv, lib, fetchPypi, buildPythonPackage -, nose, zope_interface }: - +{ + stdenv, + lib, + fetchPypi, + buildPythonPackage, + nose, + zope_interface, +}: buildPythonPackage rec { name = "${pname}-${version}"; pname = "lazr.delegates"; @@ -11,7 +16,7 @@ buildPythonPackage rec { sha256 = "1rdnl85j9ayp8n85l0ciip621j9dcziz5qnmv2m7krgwgcn31vfx"; }; - propagatedBuildInputs = [ nose zope_interface ]; + propagatedBuildInputs = [nose zope_interface]; doCheck = false; } diff --git a/options/mailman3/options.nix b/options/mailman3/options.nix index 570bb42..be92022 100644 --- a/options/mailman3/options.nix +++ b/options/mailman3/options.nix @@ -1,9 +1,11 @@ -{ pkgs, lib, config, ... }: - -with lib; - -let - mailman3 = import ./release.nix { }; +{ + pkgs, + lib, + config, + ... +}: +with lib; let + mailman3 = import ./release.nix {}; cfg = config.services.mailman3; usePostgresql = cfg.database.type == "postgresql"; useSqlite = cfg.database.type == "sqlite3"; @@ -102,7 +104,7 @@ in { database = { type = mkOption { - type = types.enum [ "sqlite3" "mysql" "postgres" ]; + type = types.enum ["sqlite3" "mysql" "postgres"]; default = "sqlite3"; example = "mysql"; description = '' @@ -271,7 +273,7 @@ in { mta = { # TODO: add Sentmail and qmail type = mkOption { - type = types.enum [ "postfix" "exim4" ]; + type = types.enum ["postfix" "exim4"]; default = "postfix"; example = "exim4"; description = '' @@ -357,7 +359,6 @@ in { }; }; - config = mkIf cfg.enable { users = mkIf (cfg.user == "mailman3") { users.mailman3 = { @@ -365,7 +366,7 @@ in { home = cfg.paths.var_dir; createHome = true; useDefaultShell = true; - packages = [ mailman3.core ]; + packages = [mailman3.core]; }; }; @@ -374,25 +375,25 @@ in { services.postfix.mapFiles."local_recipient_maps" = mkIf usePostfix (mkDefault "${cfg.paths.data_dir}/postfix_lmtp"); services.postfix.mapFiles."relay_domains" = mkIf usePostfix (mkDefault "${cfg.paths.data_dir}/postfix_domains"); - warnings = optional (cfg.database.password != "") - ''config.services.mailman3.database.password will be stored as plaintext - in the Nix store. Use database.passwordFile instead.''; + warnings = + optional (cfg.database.password != "") + '' config.services.mailman3.database.password will be stored as plaintext + in the Nix store. Use database.passwordFile instead.''; # Create database passwordFile default when password is configured. - services.mailman3.database.passwordFile = - (mkDefault (toString (pkgs.writeTextFile { - name = "mailman3-database-password"; - text = cfg.database.password; - }))); + services.mailman3.database.passwordFile = mkDefault (toString (pkgs.writeTextFile { + name = "mailman3-database-password"; + text = cfg.database.password; + })); systemd.services.mailman3 = { description = "GNU Mailing List Manager"; - after = [ "network.target" ] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service"; - wantedBy = [ "multi-user.target" ]; + after = ["network.target"] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service"; + wantedBy = ["multi-user.target"]; preStart = let - dbpass = (fileContents cfg.database.passwordFile); - smtppass = (fileContents cfg.mta.smtp_passFile); + dbpass = fileContents cfg.database.passwordFile; + smtppass = fileContents cfg.mta.smtp_passFile; in '' mkdir -p ${cfg.paths.etc_dir} cp ${configFile} ${cfg.paths.etc_dir}/mailman.cfg diff --git a/options/mailman3/release.nix b/options/mailman3/release.nix index 4fcc213..96e70fb 100644 --- a/options/mailman3/release.nix +++ b/options/mailman3/release.nix @@ -1,8 +1,9 @@ -{ pkgs ? import {}, python3Packages ? pkgs.python3Packages }: - -let +{ + pkgs ? import {}, + python3Packages ? pkgs.python3Packages, +}: let mailman3 = { - core = python3Packages.callPackage ./core.nix ( with deps; { + core = python3Packages.callPackage ./core.nix (with deps; { inherit aiosmtpd atpublic flufl_bounce flufl_i18n flufl_lock lazr_config; }); }; @@ -10,7 +11,7 @@ let aiosmtpd = python3Packages.callPackage ./extraPackages/aiosmtpd.nix { inherit atpublic; }; - atpublic = python3Packages.callPackage ./extraPackages/atpublic.nix { }; + atpublic = python3Packages.callPackage ./extraPackages/atpublic.nix {}; flufl_bounce = python3Packages.callPackage ./extraPackages/flufl_bounce.nix { inherit atpublic; }; @@ -23,6 +24,7 @@ let lazr_config = python3Packages.callPackage ./extraPackages/lazr_config.nix { inherit lazr_delegates; }; - lazr_delegates = python3Packages.callPackage ./extraPackages/lazr_delegates.nix { }; + lazr_delegates = python3Packages.callPackage ./extraPackages/lazr_delegates.nix {}; }; -in mailman3 +in + mailman3 diff --git a/pkgs/flat-remix/default.nix b/pkgs/flat-remix/default.nix index 5b2dc25..8807997 100644 --- a/pkgs/flat-remix/default.nix +++ b/pkgs/flat-remix/default.nix @@ -1,5 +1,8 @@ -{ stdenv, fetchFromGitHub, gtk-engine-murrine }: - +{ + stdenv, + fetchFromGitHub, + gtk-engine-murrine, +}: stdenv.mkDerivation { version = "1.0"; name = "Flat-Remix-GTK"; @@ -10,6 +13,6 @@ stdenv.mkDerivation { sha256 = "0rfv75w9yr8drc3x9g4iz2cb88ixy1lqbflvmb7farw4dz74fk5f"; fetchSubmodules = true; }; - makeFlags = [ "PREFIX=$(out)" ]; - propagatedUserEnvPkgs = [ gtk-engine-murrine ]; + makeFlags = ["PREFIX=$(out)"]; + propagatedUserEnvPkgs = [gtk-engine-murrine]; } diff --git a/pkgs/nixpkgs.nix b/pkgs/nixpkgs.nix index 4253871..93f5e27 100644 --- a/pkgs/nixpkgs.nix +++ b/pkgs/nixpkgs.nix @@ -1,20 +1,24 @@ -{ config, lib, pkgs, - nixpkgs-unstable, nixpkgs-stable, nixpkgs-git, - ... }: - -let +{ + config, + lib, + pkgs, + nixpkgs-unstable, + nixpkgs-stable, + nixpkgs-git, + ... +}: let callPackage = pkgs.callPackage; in { nixpkgs = { config = { allowUnfree = true; - mpv.vaapiSupport = (lib.elem "xserver" config.machine.services); + mpv.vaapiSupport = lib.elem "xserver" config.machine.services; packageOverrides = { pyluxafor = pkgs.python3Packages.callPackage ./pyluxafor {}; - theme_flat-remix = callPackage ./flat-remix { }; - theme_sddm_midnight = callPackage ./sddm_midnight { }; - xdiskusage = callPackage ./xdiskusage { }; + theme_flat-remix = callPackage ./flat-remix {}; + theme_sddm_midnight = callPackage ./sddm_midnight {}; + xdiskusage = callPackage ./xdiskusage {}; }; }; overlays = [ diff --git a/pkgs/pyluxafor/default.nix b/pkgs/pyluxafor/default.nix index 8e1da3b..d71565f 100644 --- a/pkgs/pyluxafor/default.nix +++ b/pkgs/pyluxafor/default.nix @@ -1,5 +1,9 @@ -{ fetchFromGitHub, buildPythonApplication, click, pyusb }: - +{ + fetchFromGitHub, + buildPythonApplication, + click, + pyusb, +}: buildPythonApplication rec { pname = "pyluxafor"; version = "0.1.0"; @@ -14,5 +18,5 @@ buildPythonApplication rec { substituteInPlace setup.py --replace '"click>=6.0,<=6.7.99",' "" substituteInPlace setup.py --replace '"pyusb==1.0.0",' "" ''; - propagatedBuildInputs = [ click pyusb ]; + propagatedBuildInputs = [click pyusb]; } diff --git a/pkgs/sddm_midnight/default.nix b/pkgs/sddm_midnight/default.nix index d03ea82..842004e 100644 --- a/pkgs/sddm_midnight/default.nix +++ b/pkgs/sddm_midnight/default.nix @@ -1,17 +1,20 @@ -{ stdenv, fetchFromGitHub, qtstyleplugin-kvantum-qt4 }: - +{ + stdenv, + fetchFromGitHub, + qtstyleplugin-kvantum-qt4, +}: stdenv.mkDerivation { name = "sddm_midnight"; version = 1.0; src = fetchFromGitHub { - owner = "Rokin05"; + owner = "Rokin05"; repo = "midnight-kde"; rev = "1a4771146a8d6f3b45b1da32877495c9e562d193"; sha256 = "10br96pf4dppk9nk7yvf7h9zja40k4c6rhwmqcaxxcjlhpvjmhkj"; }; - buildInputs = [ qtstyleplugin-kvantum-qt4 ]; + buildInputs = [qtstyleplugin-kvantum-qt4]; patchPhase = '' substituteInPlace sddm/themes/Midnight/Main.qml --replace /usr $out diff --git a/pkgs/systemPackages.nix b/pkgs/systemPackages.nix index 56843df..ac07b34 100644 --- a/pkgs/systemPackages.nix +++ b/pkgs/systemPackages.nix @@ -1,18 +1,26 @@ -{ config, lib, fn, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + fn, + pkgs, + ... +}: +with lib; let cfg = config.machine; - pkgsets = fn.lst { p = (toString ../pkgsets); b = true;}; + pkgsets = fn.lst { + p = toString ../pkgsets; + b = true; + }; in { imports = pkgsets; - environment.systemPackages = flatten + environment.systemPackages = + flatten (lists.forEach (attrVals (filter - (v: !(strings.hasInfix "::" v)) cfg.pkgs) + (v: !(strings.hasInfix "::" v)) + cfg.pkgs) cfg.pkgsets) (v: v.pkgwrap)); diff --git a/pkgs/xdiskusage/default.nix b/pkgs/xdiskusage/default.nix index 17a425f..03757c5 100644 --- a/pkgs/xdiskusage/default.nix +++ b/pkgs/xdiskusage/default.nix @@ -1,10 +1,13 @@ -{ stdenv, fetchurl, fltk }: - +{ + stdenv, + fetchurl, + fltk, +}: stdenv.mkDerivation rec { name = "xdiskusage"; version = "1.51"; - buildInputs = [ fltk ]; + buildInputs = [fltk]; src = fetchurl { url = "http://xdiskusage.sourceforge.net/${name}-${version}.tgz"; diff --git a/pkgsets/base.nix b/pkgsets/base.nix index c26c5bf..04c1891 100644 --- a/pkgsets/base.nix +++ b/pkgsets/base.nix @@ -1,9 +1,12 @@ # Programms I'm likely to want on every machine and/or may execute as root -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.base.pkgs = with pkgs; [ - age sops + age + sops bat ccze cryptsetup @@ -54,7 +57,8 @@ whois wirelesstools wpa_supplicant - zip unzipNLS + zip + unzipNLS zlib zsh ]; diff --git a/pkgsets/cpp.nix b/pkgsets/cpp.nix index 02ca4df..b45ef08 100644 --- a/pkgsets/cpp.nix +++ b/pkgsets/cpp.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.cpp.pkgs = with pkgs; [ clang cmake diff --git a/pkgsets/dict.nix b/pkgsets/dict.nix index a8f1492..dd8ec60 100644 --- a/pkgsets/dict.nix +++ b/pkgsets/dict.nix @@ -1,9 +1,11 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.dict.pkgs = with pkgs; [ translate-shell - ( hunspellWithDicts (with pkgs.hunspellDicts; [ de-de en-us ] )) - ( aspellWithDicts (d: with d; [ de en en-computers en-science ] )) + (hunspellWithDicts (with pkgs.hunspellDicts; [de-de en-us])) + (aspellWithDicts (d: with d; [de en en-computers en-science])) ]; } diff --git a/pkgsets/emacs.nix b/pkgsets/emacs.nix index 4623150..ef1b739 100644 --- a/pkgsets/emacs.nix +++ b/pkgsets/emacs.nix @@ -1,16 +1,24 @@ -{ config, lib, fn, pkgs, ... }: - -with lib; - -let - modefiles = fn.lst { p = (toString ./emacs); b = true; }; +{ + config, + lib, + fn, + pkgs, + ... +}: +with lib; let + modefiles = fn.lst { + p = toString ./emacs; + b = true; + }; in rec { - imports = [ - ../options/emacs-init.nix - ] ++ modefiles; + imports = + [ + ../options/emacs-init.nix + ] + ++ modefiles; programs.emacs.init = { - enable = (elem "emacs" config.machine.pkgs); + enable = elem "emacs" config.machine.pkgs; recommendedGcSettings = true; prelude = '' diff --git a/pkgsets/emacs/company.nix b/pkgsets/emacs/company.nix index d751cf0..3a31d4b 100644 --- a/pkgsets/emacs/company.nix +++ b/pkgsets/emacs/company.nix @@ -1,8 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let # Source: https://github.com/Henry/dot-emacs/blob/master/my-lisp/company-pcomplete.el company-pcomplete = pkgs.writeText "company-pcomplete.el" '' ;;; company-pcomplete.el --- company-mode pcomplete backend -*- lexical-binding: t -*- @@ -95,77 +97,80 @@ let (provide 'company-pcomplete) ''; -in mkIf (elem "emacs::company" config.machine.pkgs) { - programs.emacs.init.usePackage = { - company = { - enable = true; - package = epkgs: [ epkgs.company epkgs.company-web ]; - diminish = [ "company-mode" ]; - hook = [ "(after-init . global-company-mode)" ] - ++ optional (elem "emacs::rust" config.machine.pkgs) - ''(rust-mode . (lambda () (setq company-backends '((company-capf :with company-yasnippet)))))'' - ++ optional (elem "emacs::web-mode" config.machine.pkgs) - ''(web-mode . (lambda () (set (make-local-variable 'company-backends) '(company-web-html company-css)) - (company-mode t)))''; - bind = { "\t" = "'company-complete-common"; }; - init = ''(require 'ffap)''; - config = '' - ;; (setq company-tooltip-align-annotations t) - (setq company-idle-delay 0.3 - company-show-numbers t) +in + mkIf (elem "emacs::company" config.machine.pkgs) { + programs.emacs.init.usePackage = { + company = { + enable = true; + package = epkgs: [epkgs.company epkgs.company-web]; + diminish = ["company-mode"]; + hook = + ["(after-init . global-company-mode)"] + ++ optional (elem "emacs::rust" config.machine.pkgs) + ''(rust-mode . (lambda () (setq company-backends '((company-capf :with company-yasnippet)))))'' + ++ optional (elem "emacs::web-mode" config.machine.pkgs) + '' (web-mode . (lambda () (set (make-local-variable 'company-backends) '(company-web-html company-css)) + (company-mode t)))''; + bind = {"\t" = "'company-complete-common";}; + init = ''(require 'ffap)''; + config = '' + ;; (setq company-tooltip-align-annotations t) + (setq company-idle-delay 0.3 + company-show-numbers t) - ${optionalString - (elem "emacs::org" config.machine.pkgs) '' - (load-file "${company-pcomplete}")'' - } - ''; - extraConfig = '' - :bind (:map company-mode-map - ([remap completion-at-point] . company-complete-common) - ([remap complete-symbol] . company-complete-common)) - ''; + ${ + optionalString + (elem "emacs::org" config.machine.pkgs) '' + (load-file "${company-pcomplete}")'' + } + ''; + extraConfig = '' + :bind (:map company-mode-map + ([remap completion-at-point] . company-complete-common) + ([remap complete-symbol] . company-complete-common)) + ''; + }; + + company-box = { + enable = true; + hook = ["(company-mode . (lambda () (company-box-mode)))"]; + config = '' + (setq company-box-icons-alist 'company-box-icons-all-the-icons) + + + (setq company-box-icons-lsp + `(( 1 . ,(all-the-icons-faicon "file-text-o" :v-adjust -0.0575)) ; Text + ( 2 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Method + ( 3 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Function + ( 4 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Constructor + ( 5 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Field + ( 6 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Variable + ( 7 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Class + ( 8 . ,(all-the-icons-faicon "cogs" :v-adjust -0.0575)) ; Interface + ( 9 . ,(all-the-icons-alltheicon "less")) ; Module + (10 . ,(all-the-icons-faicon "wrench" :v-adjust -0.0575)) ; Property + (11 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Unit + (12 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Value + (13 . ,(all-the-icons-material "content_copy" :v-adjust -0.2)) ; Enum + (14 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Keyword + (15 . ,(all-the-icons-material "content_paste" :v-adjust -0.2)) ; Snippet + (16 . ,(all-the-icons-material "palette" :v-adjust -0.2)) ; Color + (17 . ,(all-the-icons-faicon "file" :v-adjust -0.0575)) ; File + (18 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Reference + (19 . ,(all-the-icons-faicon "folder" :v-adjust -0.0575)) ; Folder + (20 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; EnumMember + (21 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Constant + (22 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Struct + (23 . ,(all-the-icons-faicon "bolt" :v-adjust -0.0575)) ; Event + (24 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Operator + (25 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; TypeParameter + )) + ''; + }; + all-the-icons = {enable = true;}; + company-jedi = { + enable = elem "emacs::elpy" config.machine.pkgs; + }; }; - - company-box = { - enable = true; - hook = [ "(company-mode . (lambda () (company-box-mode)))" ]; - config = '' - (setq company-box-icons-alist 'company-box-icons-all-the-icons) - - - (setq company-box-icons-lsp - `(( 1 . ,(all-the-icons-faicon "file-text-o" :v-adjust -0.0575)) ; Text - ( 2 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Method - ( 3 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Function - ( 4 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Constructor - ( 5 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Field - ( 6 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Variable - ( 7 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Class - ( 8 . ,(all-the-icons-faicon "cogs" :v-adjust -0.0575)) ; Interface - ( 9 . ,(all-the-icons-alltheicon "less")) ; Module - (10 . ,(all-the-icons-faicon "wrench" :v-adjust -0.0575)) ; Property - (11 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Unit - (12 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Value - (13 . ,(all-the-icons-material "content_copy" :v-adjust -0.2)) ; Enum - (14 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Keyword - (15 . ,(all-the-icons-material "content_paste" :v-adjust -0.2)) ; Snippet - (16 . ,(all-the-icons-material "palette" :v-adjust -0.2)) ; Color - (17 . ,(all-the-icons-faicon "file" :v-adjust -0.0575)) ; File - (18 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Reference - (19 . ,(all-the-icons-faicon "folder" :v-adjust -0.0575)) ; Folder - (20 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; EnumMember - (21 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Constant - (22 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Struct - (23 . ,(all-the-icons-faicon "bolt" :v-adjust -0.0575)) ; Event - (24 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Operator - (25 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; TypeParameter - )) - ''; - }; - all-the-icons = { enable = true; }; - company-jedi = { - enable = (elem "emacs::elpy" config.machine.pkgs); - }; - }; - fonts.packages = pkgs.emacs-all-the-icons-fonts.all; -} + fonts.packages = pkgs.emacs-all-the-icons-fonts.all; + } diff --git a/pkgsets/emacs/direnv.nix b/pkgsets/emacs/direnv.nix index fc0ec66..818cf7b 100644 --- a/pkgsets/emacs/direnv.nix +++ b/pkgsets/emacs/direnv.nix @@ -1,12 +1,15 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "emacs::direnv" config.machine.pkgs) { - programs.emacs.init.usePackage.direnv = { - enable = true; - config = ''(direnv-mode)''; - }; - services.lorri.enable = true; - environment.systemPackages = with pkgs; [ lorri direnv ]; -} + mkIf (elem "emacs::direnv" config.machine.pkgs) { + programs.emacs.init.usePackage.direnv = { + enable = true; + config = ''(direnv-mode)''; + }; + services.lorri.enable = true; + environment.systemPackages = with pkgs; [lorri direnv]; + } diff --git a/pkgsets/emacs/docker.nix b/pkgsets/emacs/docker.nix index 1a78a55..a2e9cd8 100644 --- a/pkgsets/emacs/docker.nix +++ b/pkgsets/emacs/docker.nix @@ -1,20 +1,22 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::docker" config.machine.pkgs) { - programs.emacs.init.usePackage = { - dockerfile-mode = { - enable = true; + mkIf (elem "emacs::docker" config.machine.pkgs) { + programs.emacs.init.usePackage = { + dockerfile-mode = { + enable = true; + }; + docker = { + enable = true; + }; + docker-compose-mode = { + enable = true; + }; + docker-tramp = { + enable = true; + }; }; - docker = { - enable = true; - }; - docker-compose-mode = { - enable = true; - }; - docker-tramp = { - enable = true; - }; - }; -} + } diff --git a/pkgsets/emacs/dockerfile.nix b/pkgsets/emacs/dockerfile.nix index a67624b..ed6f27b 100644 --- a/pkgsets/emacs/dockerfile.nix +++ b/pkgsets/emacs/dockerfile.nix @@ -1,9 +1,11 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::dockerfile" config.machine.pkgs) { - programs.emacs.init.usePackage.dockerfile-mode = { - enable = true; - }; -} + mkIf (elem "emacs::dockerfile" config.machine.pkgs) { + programs.emacs.init.usePackage.dockerfile-mode = { + enable = true; + }; + } diff --git a/pkgsets/emacs/doom-modeline.nix b/pkgsets/emacs/doom-modeline.nix index 18c9017..c79cae9 100644 --- a/pkgsets/emacs/doom-modeline.nix +++ b/pkgsets/emacs/doom-modeline.nix @@ -1,21 +1,24 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::doom-modeline" config.machine.pkgs) { + programs.emacs.init.usePackage.doom-modeline = { + enable = true; + hook = ["(after-init . doom-modeline-mode)"]; + config = '' + (setq doom-modeline-icon t) + (setq doom-modeline-height 25) + (setq doom-modeline-bar-width 3) + ;; The default priority of detection is `ffip' > `projectile' > `project'. + (setq doom-modeline-project-detection 'project) + (setq doom-modeline-buffer-file-name-style 'truncate-upto-project) + (setq doom-modeline-unicode-fallback nil) -mkIf (elem "emacs::doom-modeline" config.machine.pkgs) { - programs.emacs.init.usePackage.doom-modeline = { - enable = true; - hook = [ "(after-init . doom-modeline-mode)" ]; - config = '' - (setq doom-modeline-icon t) - (setq doom-modeline-height 25) - (setq doom-modeline-bar-width 3) - ;; The default priority of detection is `ffip' > `projectile' > `project'. - (setq doom-modeline-project-detection 'project) - (setq doom-modeline-buffer-file-name-style 'truncate-upto-project) - (setq doom-modeline-unicode-fallback nil) - - (setq doom-modeline--battery-status t) -''; - }; -} + (setq doom-modeline--battery-status t) + ''; + }; + } diff --git a/pkgsets/emacs/doom-themes.nix b/pkgsets/emacs/doom-themes.nix index a7abe73..8c7d4cf 100644 --- a/pkgsets/emacs/doom-themes.nix +++ b/pkgsets/emacs/doom-themes.nix @@ -1,16 +1,19 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::doom-themes" config.machine.pkgs) { + programs.emacs.init.usePackage.doom-themes = { + enable = true; + config = '' + ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme + ;; may have their own settings. + (load-theme 'doom-solarized-dark t) -mkIf (elem "emacs::doom-themes" config.machine.pkgs) { - programs.emacs.init.usePackage.doom-themes = { - enable = true; - config = '' - ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme - ;; may have their own settings. - (load-theme 'doom-solarized-dark t) - - ;; ${optionalString (elem "emacs::org" config.machine.pkgs) "(doom-themes-org-config)"} - ''; - }; -} + ;; ${optionalString (elem "emacs::org" config.machine.pkgs) "(doom-themes-org-config)"} + ''; + }; + } diff --git a/pkgsets/emacs/elfeed.nix b/pkgsets/emacs/elfeed.nix index 4f1780b..4f23497 100644 --- a/pkgsets/emacs/elfeed.nix +++ b/pkgsets/emacs/elfeed.nix @@ -1,148 +1,151 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::elfeed" config.machine.pkgs) { + programs.emacs.init.usePackage = { + elfeed = let + pyEnv = pkgs.python3.withPackages (ps: with ps; [beautifulsoup4 lxml requests]); + pyScript = pkgs.writeScript "elfeedFetcher.py" '' + #!${pyEnv}/bin/python3 + import sys + from requests import get + from bs4 import BeautifulSoup -mkIf (elem "emacs::elfeed" config.machine.pkgs) { - programs.emacs.init.usePackage = { - elfeed = let - pyEnv = pkgs.python3.withPackages (ps: with ps; [ beautifulsoup4 lxml requests ]); - pyScript = pkgs.writeScript "elfeedFetcher.py" '' - #!${pyEnv}/bin/python3 - import sys - from requests import get - from bs4 import BeautifulSoup + header_agent = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0'} + with get(sys.argv[1], headers=header_agent) as r: + soup = BeautifulSoup(r.text, 'lxml') + abstract = soup.find('dd', {"id": "abstract"}).text.replace('"', '\\"') + article = '\n\n'.join( + [soup.find('p', {"id": "first"}, class_="lead").text] + + [ + p.text for p in + soup.find('div', {"id": "text"}).findAll('p') + ]).replace('"', '\\"') + print(f"(setq abstract \"{abstract}\") (setq article \"{article}\")") + ''; + in { + enable = true; + hook = [''(elfeed-new-entry . elfeed-content-fetcher)'']; + config = '' + (load-file "~/.emacs.d/elfeed.el") - header_agent = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0'} - with get(sys.argv[1], headers=header_agent) as r: - soup = BeautifulSoup(r.text, 'lxml') - abstract = soup.find('dd', {"id": "abstract"}).text.replace('"', '\\"') - article = '\n\n'.join( - [soup.find('p', {"id": "first"}, class_="lead").text] + - [ - p.text for p in - soup.find('div', {"id": "text"}).findAll('p') - ]).replace('"', '\\"') - print(f"(setq abstract \"{abstract}\") (setq article \"{article}\")") - ''; - in { - enable = true; - hook = [ ''(elfeed-new-entry . elfeed-content-fetcher)'' ]; - config = '' - (load-file "~/.emacs.d/elfeed.el") + (defun elfeed-play-with-mpv (entry) + "Play entry link with mpv." + (interactive (elfeed-search-selected :single)) + (start-process "elfeed-mpv" nil "mpv" "--ytdl-format=[height<=1080]" (elfeed-entry-link entry))) - (defun elfeed-play-with-mpv (entry) - "Play entry link with mpv." - (interactive (elfeed-search-selected :single)) - (start-process "elfeed-mpv" nil "mpv" "--ytdl-format=[height<=1080]" (elfeed-entry-link entry))) + (defun elfeed-search-show-entry-custom (entry) + "Custom actions for various sources." + (interactive (list (elfeed-search-selected :ignore-region))) + (if (equal (car (elfeed-entry-id entry)) "www.youtube.com") (elfeed-play-with-mpv entry) + (elfeed-show-entry entry))) + (define-key elfeed-search-mode-map [remap elfeed-search-show-entry] 'elfeed-search-show-entry-custom) - (defun elfeed-search-show-entry-custom (entry) - "Custom actions for various sources." - (interactive (list (elfeed-search-selected :ignore-region))) - (if (equal (car (elfeed-entry-id entry)) "www.youtube.com") (elfeed-play-with-mpv entry) - (elfeed-show-entry entry))) - (define-key elfeed-search-mode-map [remap elfeed-search-show-entry] 'elfeed-search-show-entry-custom) + (defun elfeed-get-yt-description (url) + (shell-command-to-string (format "${pkgs.youtube-dl}/bin/youtube-dl --get-description \"%s\" 2> /dev/null" url))) - (defun elfeed-get-yt-description (url) - (shell-command-to-string (format "${pkgs.youtube-dl}/bin/youtube-dl --get-description \"%s\" 2> /dev/null" url))) + (defun elfeed-get-sd-article (url) + (eval-string (shell-command-to-string (format "${pyEnv}/bin/python3 ${pyScript} \"%s\" 2> /dev/null" url)))) - (defun elfeed-get-sd-article (url) - (eval-string (shell-command-to-string (format "${pyEnv}/bin/python3 ${pyScript} \"%s\" 2> /dev/null" url)))) + (defun eval-string (string) + (eval (car (read-from-string (format "(progn %s)" string))))) - (defun eval-string (string) - (eval (car (read-from-string (format "(progn %s)" string))))) + (defun elfeed-content-fetcher (entry) + "Fetches content for various entries (currently only sciencedaily)." + (interactive (list (elfeed-search-selected :ignore-region))) - (defun elfeed-content-fetcher (entry) - "Fetches content for various entries (currently only sciencedaily)." - (interactive (list (elfeed-search-selected :ignore-region))) + (let ((url (elfeed-entry-link entry)) + (feed-id (elfeed-deref (elfeed-entry-feed-id entry))) + ) + (when (equal (car (elfeed-entry-id entry)) "www.sciencedaily.com") + (elfeed-get-sd-article (cdr (elfeed-entry-id entry))) + ;; (setf (elfeed-entry-content entry) (elfeed-ref article)) + (setf (elfeed-meta entry :content) (elfeed-ref article)) + (setf (elfeed-meta entry :abstract) abstract) + (makunbound 'abstract) + (makunbound 'article)))) - (let ((url (elfeed-entry-link entry)) - (feed-id (elfeed-deref (elfeed-entry-feed-id entry))) - ) - (when (equal (car (elfeed-entry-id entry)) "www.sciencedaily.com") - (elfeed-get-sd-article (cdr (elfeed-entry-id entry))) - ;; (setf (elfeed-entry-content entry) (elfeed-ref article)) - (setf (elfeed-meta entry :content) (elfeed-ref article)) - (setf (elfeed-meta entry :abstract) abstract) - (makunbound 'abstract) - (makunbound 'article)))) - - (defun elfeed-show-refresh--mail-style () - "Update the buffer to match the selected entry, using a mail-style." - (interactive) - (let* ((inhibit-read-only t) - (title (elfeed-entry-title elfeed-show-entry)) - (date (seconds-to-time (elfeed-entry-date elfeed-show-entry))) - (authors (elfeed-meta elfeed-show-entry :authors)) - (link (elfeed-entry-link elfeed-show-entry)) - (tags (elfeed-entry-tags elfeed-show-entry)) - (tagsstr (mapconcat #'symbol-name tags ", ")) - (nicedate (format-time-string "%a, %e %b %Y %T %Z" date)) - (content (if (elfeed-meta elfeed-show-entry :content) (elfeed-deref (elfeed-meta elfeed-show-entry :content)) (elfeed-deref (elfeed-entry-content elfeed-show-entry)))) - (type (elfeed-entry-content-type elfeed-show-entry)) - (feed (elfeed-entry-feed elfeed-show-entry)) - (feed-title (elfeed-feed-title feed)) - (base (and feed (elfeed-compute-base (elfeed-feed-url feed))))) - (erase-buffer) - (insert (format (propertize "Title: %s\n" 'face 'message-header-name) - (propertize title 'face 'message-header-subject))) - (when elfeed-show-entry-author - (dolist (author authors) - (let ((formatted (elfeed--show-format-author author))) - (insert - (format (propertize "Author: %s\n" 'face 'message-header-name) - (propertize formatted 'face 'message-header-to)))))) - (insert (format (propertize "Date: %s\n" 'face 'message-header-name) - (propertize nicedate 'face 'message-header-other))) - (insert (format (propertize "Feed: %s\n" 'face 'message-header-name) - (propertize feed-title 'face 'message-header-other))) - (when tags - (insert (format (propertize "Tags: %s\n" 'face 'message-header-name) - (propertize tagsstr 'face 'message-header-other)))) - (insert (propertize "Link: " 'face 'message-header-name)) - (elfeed-insert-link link link) - (insert "\n") - (cl-loop for enclosure in (elfeed-entry-enclosures elfeed-show-entry) - do (insert (propertize "Enclosure: " 'face 'message-header-name)) - do (elfeed-insert-link (car enclosure)) - do (insert "\n")) - (insert "\n") - (if content - (if (eq type 'html) - (elfeed-insert-html content base) - (insert content)) - (insert (propertize "(empty)\n" 'face 'italic))) - (goto-char (point-min)))) + (defun elfeed-show-refresh--mail-style () + "Update the buffer to match the selected entry, using a mail-style." + (interactive) + (let* ((inhibit-read-only t) + (title (elfeed-entry-title elfeed-show-entry)) + (date (seconds-to-time (elfeed-entry-date elfeed-show-entry))) + (authors (elfeed-meta elfeed-show-entry :authors)) + (link (elfeed-entry-link elfeed-show-entry)) + (tags (elfeed-entry-tags elfeed-show-entry)) + (tagsstr (mapconcat #'symbol-name tags ", ")) + (nicedate (format-time-string "%a, %e %b %Y %T %Z" date)) + (content (if (elfeed-meta elfeed-show-entry :content) (elfeed-deref (elfeed-meta elfeed-show-entry :content)) (elfeed-deref (elfeed-entry-content elfeed-show-entry)))) + (type (elfeed-entry-content-type elfeed-show-entry)) + (feed (elfeed-entry-feed elfeed-show-entry)) + (feed-title (elfeed-feed-title feed)) + (base (and feed (elfeed-compute-base (elfeed-feed-url feed))))) + (erase-buffer) + (insert (format (propertize "Title: %s\n" 'face 'message-header-name) + (propertize title 'face 'message-header-subject))) + (when elfeed-show-entry-author + (dolist (author authors) + (let ((formatted (elfeed--show-format-author author))) + (insert + (format (propertize "Author: %s\n" 'face 'message-header-name) + (propertize formatted 'face 'message-header-to)))))) + (insert (format (propertize "Date: %s\n" 'face 'message-header-name) + (propertize nicedate 'face 'message-header-other))) + (insert (format (propertize "Feed: %s\n" 'face 'message-header-name) + (propertize feed-title 'face 'message-header-other))) + (when tags + (insert (format (propertize "Tags: %s\n" 'face 'message-header-name) + (propertize tagsstr 'face 'message-header-other)))) + (insert (propertize "Link: " 'face 'message-header-name)) + (elfeed-insert-link link link) + (insert "\n") + (cl-loop for enclosure in (elfeed-entry-enclosures elfeed-show-entry) + do (insert (propertize "Enclosure: " 'face 'message-header-name)) + do (elfeed-insert-link (car enclosure)) + do (insert "\n")) + (insert "\n") + (if content + (if (eq type 'html) + (elfeed-insert-html content base) + (insert content)) + (insert (propertize "(empty)\n" 'face 'italic))) + (goto-char (point-min)))) - (defun elfeed-db-gc (&optional stats-p) - "Clean up unused content from the content database. - If STATS is true, return the space cleared in bytes." - (elfeed-db-gc-empty-feeds) - (let* ((data (expand-file-name "data" elfeed-db-directory)) - (dirs (directory-files data t "^[0-9a-z]\\{2\\}$")) - (ids (cl-mapcan (lambda (d) (directory-files d nil nil t)) dirs)) - (table (make-hash-table :test 'equal))) - (dolist (id ids) - (setf (gethash id table) nil)) - (with-elfeed-db-visit (entry _) - (let ((content (elfeed-entry-content entry)) - (meta-content (elfeed-meta entry :content))) - (when (elfeed-ref-p content) - (setf (gethash (elfeed-ref-id content) table) t)) - (when (elfeed-ref-p (meta-content)) - (setf (gethash (elfeed-ref-id meta-content) table) t)))) - (cl-loop for id hash-keys of table using (hash-value used) - for used-p = (or used (member id '("." ".."))) - when (and (not used-p) stats-p) - sum (let* ((ref (elfeed-ref--create :id id)) - (file (elfeed-ref--file ref))) - (* 1.0 (nth 7 (file-attributes file)))) - unless used-p - do (elfeed-ref-delete (elfeed-ref--create :id id)) - finally (cl-loop for dir in dirs - when (elfeed-directory-empty-p dir) - do (delete-directory dir))))) - ''; + (defun elfeed-db-gc (&optional stats-p) + "Clean up unused content from the content database. + If STATS is true, return the space cleared in bytes." + (elfeed-db-gc-empty-feeds) + (let* ((data (expand-file-name "data" elfeed-db-directory)) + (dirs (directory-files data t "^[0-9a-z]\\{2\\}$")) + (ids (cl-mapcan (lambda (d) (directory-files d nil nil t)) dirs)) + (table (make-hash-table :test 'equal))) + (dolist (id ids) + (setf (gethash id table) nil)) + (with-elfeed-db-visit (entry _) + (let ((content (elfeed-entry-content entry)) + (meta-content (elfeed-meta entry :content))) + (when (elfeed-ref-p content) + (setf (gethash (elfeed-ref-id content) table) t)) + (when (elfeed-ref-p (meta-content)) + (setf (gethash (elfeed-ref-id meta-content) table) t)))) + (cl-loop for id hash-keys of table using (hash-value used) + for used-p = (or used (member id '("." ".."))) + when (and (not used-p) stats-p) + sum (let* ((ref (elfeed-ref--create :id id)) + (file (elfeed-ref--file ref))) + (* 1.0 (nth 7 (file-attributes file)))) + unless used-p + do (elfeed-ref-delete (elfeed-ref--create :id id)) + finally (cl-loop for dir in dirs + when (elfeed-directory-empty-p dir) + do (delete-directory dir))))) + ''; + }; }; - }; -} + } diff --git a/pkgsets/emacs/elpy.nix b/pkgsets/emacs/elpy.nix index fd41d3f..87a981b 100644 --- a/pkgsets/emacs/elpy.nix +++ b/pkgsets/emacs/elpy.nix @@ -1,36 +1,43 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; + mkIf (elem "emacs::elpy" config.machine.pkgs) { + programs.emacs.init.usePackage.elpy = { + enable = true; + after = ["python"]; + command = ["elpy-enable"]; + hook = + [ + '' + (elpy-mode + . (lambda () + (set (make-local-variable 'company-backends) + '((company-dabbrev-code company-yasnippet elpy-company-backend))))) + '' + ] + ++ (optional (elem "emacs::flyspell" config.machine.pkgs) "(elpy-mode . (lambda () (flyspell-prog-mode)))") + ++ (optional (elem "emacs::flycheck" config.machine.pkgs) "(elpy-mode . (lambda () (flycheck-mode)))"); + bindLocal = { + elpy-mode-map = { + "" = "company-indent-or-complete-common"; + }; + }; + init = ''(with-eval-after-load 'python (elpy-enable))''; + config = '' + (setq elpy-project-root-finder-functions '(elpy-project-find-git-root elpy-project-find-python-root elpy-project-find-hg-root elpy-project-find-svn-root)) + (setq elpy-rpc-backend "jedi") + (setq python-shell-interpreter "ipython" + python-shell-interpreter-args "-i --simple-prompt") -mkIf (elem "emacs::elpy" config.machine.pkgs) { - programs.emacs.init.usePackage.elpy = { - enable = true; - after = [ "python" ]; - command = [ "elpy-enable" ]; - hook = [ '' - (elpy-mode - . (lambda () - (set (make-local-variable 'company-backends) - '((company-dabbrev-code company-yasnippet elpy-company-backend))))) - '' ] - ++ (optional (elem "emacs::flyspell" config.machine.pkgs) "(elpy-mode . (lambda () (flyspell-prog-mode)))") - ++ (optional (elem "emacs::flycheck" config.machine.pkgs) "(elpy-mode . (lambda () (flycheck-mode)))"); - bindLocal = { elpy-mode-map = { - "" = "company-indent-or-complete-common"; - };}; - init = ''(with-eval-after-load 'python (elpy-enable))''; - config = '' - (setq elpy-project-root-finder-functions '(elpy-project-find-git-root elpy-project-find-python-root elpy-project-find-hg-root elpy-project-find-svn-root)) - (setq elpy-rpc-backend "jedi") - (setq python-shell-interpreter "ipython" - python-shell-interpreter-args "-i --simple-prompt") - - ${optionalString (elem "emacs::flycheck" config.machine.pkgs) '' - ;; manually set what python-mypy is and configure it to ignore 3rd party imports - (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) - (setq-default flycheck-checker 'python-pylint) - (flycheck-add-next-checker 'python-pylint 'python-flake8 t) - ;; (flycheck-add-next-checker 'python-mypy 'python-flake8 t)''} - ''; - }; -} + ${optionalString (elem "emacs::flycheck" config.machine.pkgs) '' + ;; manually set what python-mypy is and configure it to ignore 3rd party imports + (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) + (setq-default flycheck-checker 'python-pylint) + (flycheck-add-next-checker 'python-pylint 'python-flake8 t) + ;; (flycheck-add-next-checker 'python-mypy 'python-flake8 t)''} + ''; + }; + } diff --git a/pkgsets/emacs/fcitx.nix b/pkgsets/emacs/fcitx.nix index 36b2bad..e6d113e 100644 --- a/pkgsets/emacs/fcitx.nix +++ b/pkgsets/emacs/fcitx.nix @@ -1,16 +1,18 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::fcitx" config.machine.pkgs) { - programs.emacs.init.usePackage = { - fcitx = { - enable = true; - demand = true; - config = '' - ;; (setq fcitx-use-dbus t) - (fcitx-default-setup) - ''; + mkIf (elem "emacs::fcitx" config.machine.pkgs) { + programs.emacs.init.usePackage = { + fcitx = { + enable = true; + demand = true; + config = '' + ;; (setq fcitx-use-dbus t) + (fcitx-default-setup) + ''; + }; }; - }; -} + } diff --git a/pkgsets/emacs/flycheck.nix b/pkgsets/emacs/flycheck.nix index 403749f..e4b581a 100644 --- a/pkgsets/emacs/flycheck.nix +++ b/pkgsets/emacs/flycheck.nix @@ -1,35 +1,37 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; + mkIf (elem "emacs::flycheck" config.machine.pkgs) { + programs.emacs.init.usePackage.flycheck = { + enable = true; + command = ["global-flycheck-mode"]; + defer = 1; + bind = {}; + config = '' -mkIf (elem "emacs::flycheck" config.machine.pkgs) { - programs.emacs.init.usePackage.flycheck = { - enable = true; - command = [ "global-flycheck-mode" ]; - defer = 1; - bind = {}; - config = '' + ''; + }; - ''; - }; + programs.emacs.init.usePackage.flycheck-haskell = { + enable = elem "emacs::haskell" config.machine.pkgs; + }; - programs.emacs.init.usePackage.flycheck-haskell = { - enable = (elem "emacs::haskell" config.machine.pkgs); - }; + programs.emacs.init.usePackage.flycheck-irony = { + enable = elem "emacs::irony" config.machine.pkgs; + }; - programs.emacs.init.usePackage.flycheck-irony = { - enable = (elem "emacs::irony" config.machine.pkgs); - }; + programs.emacs.init.usePackage.flycheck-mypy = { + enable = elem "emacs::elpy" config.machine.pkgs; + }; - programs.emacs.init.usePackage.flycheck-mypy = { - enable = (elem "emacs::elpy" config.machine.pkgs); - }; + programs.emacs.init.usePackage.pylint = { + enable = elem "emacs::elpy" config.machine.pkgs; + }; - programs.emacs.init.usePackage.pylint = { - enable = (elem "emacs::elpy" config.machine.pkgs); - }; - - programs.emacs.init.usePackage.flycheck-rust = { - enable = (elem "emacs::rust" config.machine.pkgs); - }; -} + programs.emacs.init.usePackage.flycheck-rust = { + enable = elem "emacs::rust" config.machine.pkgs; + }; + } diff --git a/pkgsets/emacs/flyspell.nix b/pkgsets/emacs/flyspell.nix index 91ec658..32410da 100644 --- a/pkgsets/emacs/flyspell.nix +++ b/pkgsets/emacs/flyspell.nix @@ -1,31 +1,33 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; + mkIf (elem "emacs::flyspell" config.machine.pkgs) { + programs.emacs.init.usePackage.flyspell = { + enable = true; + package = epkgs: null; + diminish = ["flyspell-mode"]; + command = ["flyspell-mode" "flyspell-prog-mode"]; + hook = []; + bind = { + "C-M-" = "flyspell-switch-dictionary"; + "C-c f" = "ispell-word"; + }; + config = '' + ;; Make flyspell less verbose and disable annoying keybind + (setq flyspell-issue-message-flag nil + flyspell-issue-welcome-flag nil + flyspell-use-meta-tab nil) -mkIf (elem "emacs::flyspell" config.machine.pkgs) { - programs.emacs.init.usePackage.flyspell = { - enable = true; - package = epkgs: null; - diminish = [ "flyspell-mode" ]; - command = [ "flyspell-mode" "flyspell-prog-mode" ]; - hook = []; - bind = { - "C-M-" = "flyspell-switch-dictionary"; - "C-c f" = "ispell-word"; + (defun flyspell-switch-dictionary () + (interactive) + (let* ((dic ispell-current-dictionary) + (change (if (string= dic "deutsch8") "english" "deutsch8"))) + (ispell-change-dictionary change) + (message "Dictionary switched to %s" change) + )) + ''; }; - config = '' - ;; Make flyspell less verbose and disable annoying keybind - (setq flyspell-issue-message-flag nil - flyspell-issue-welcome-flag nil - flyspell-use-meta-tab nil) - - (defun flyspell-switch-dictionary () - (interactive) - (let* ((dic ispell-current-dictionary) - (change (if (string= dic "deutsch8") "english" "deutsch8"))) - (ispell-change-dictionary change) - (message "Dictionary switched to %s" change) - )) - ''; - }; -} + } diff --git a/pkgsets/emacs/latex.nix b/pkgsets/emacs/latex.nix index 756d075..b2122c6 100644 --- a/pkgsets/emacs/latex.nix +++ b/pkgsets/emacs/latex.nix @@ -1,27 +1,30 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::latex" config.machine.pkgs) { + programs.emacs.init.usePackage = { + latex-mode = { + enable = true; + package = epkgs: null; + defer = true; + }; -mkIf (elem "emacs::latex" config.machine.pkgs) { - programs.emacs.init.usePackage = { - latex-mode = { - enable = true; - package = epkgs: null; - defer = true; - }; + tex-site = { + enable = true; + defer = true; + package = epkgs: epkgs.auctex; + hook = []; + mode = [''("\\.tex\\'" . TeX-latex-mode)'']; + }; - tex-site = { - enable = true; - defer = true; - package = epkgs: epkgs.auctex; - hook = []; - mode = [ ''("\\.tex\\'" . TeX-latex-mode)'' ]; + preview = { + enable = true; + defer = true; + package = epkgs: epkgs.auctex; + }; }; - - preview = { - enable = true; - defer = true; - package = epkgs: epkgs.auctex; - }; - }; -} + } diff --git a/pkgsets/emacs/lsp.nix b/pkgsets/emacs/lsp.nix index 284077b..b8ff89d 100644 --- a/pkgsets/emacs/lsp.nix +++ b/pkgsets/emacs/lsp.nix @@ -1,56 +1,60 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::lsp" config.machine.pkgs) { + programs.emacs.init.usePackage = { + lsp-mode = { + enable = true; + command = ["lsp-mode"]; + config = '' + (setq lsp-keymap-prefix "C-c") + (setq lsp-eldoc-render-all nil) -mkIf (elem "emacs::lsp" config.machine.pkgs) { - programs.emacs.init.usePackage = { - lsp-mode = { - enable = true; - command = [ "lsp-mode" ]; - config = '' - (setq lsp-keymap-prefix "C-c") - (setq lsp-eldoc-render-all nil) - - (defvar lsp-language-id-configuration '( - ${optionalString (elem "emacs::rust" config.machine.pkgs) + (defvar lsp-language-id-configuration '( + ${optionalString (elem "emacs::rust" config.machine.pkgs) ''(rust-mode . "rust")''} - )) - ${optionalString (elem "emacs::rust" config.machine.pkgs) '' - (setq lsp-rust-clippy-preference "on") - ''} - ${optionalString (elem "emacs::web-mode" config.machine.pkgs) '' - (setq lsp-clients-deno-enable-unstable 't) - (setq lsp-clients-deno-import-map "./import_map.json") - (setq lsp-clients-deno-config "./deno.json") - ''} - ${optionalString (elem "emacs::php-mode" config.machine.pkgs) '' - (setq lsp-intelephense-php-version "8.2") - (setq lsp-intelephense-server-command `("${pkgs.nodePackages.intelephense}/bin/intelephense" "--stdio")) - ''} - ''; - }; + )) + ${optionalString (elem "emacs::rust" config.machine.pkgs) '' + (setq lsp-rust-clippy-preference "on") + ''} + ${optionalString (elem "emacs::web-mode" config.machine.pkgs) '' + (setq lsp-clients-deno-enable-unstable 't) + (setq lsp-clients-deno-import-map "./import_map.json") + (setq lsp-clients-deno-config "./deno.json") + ''} + ${optionalString (elem "emacs::php-mode" config.machine.pkgs) '' + (setq lsp-intelephense-php-version "8.2") + (setq lsp-intelephense-server-command `("${pkgs.nodePackages.intelephense}/bin/intelephense" "--stdio")) + ''} + ''; + }; - lsp-ui = { - enable = true; - after = [ "lsp-mode" ]; - config = '' - (setq lsp-ui-sideline-enable 't) - (setq lsp-ui-sideline-show-symbol nil) - (setq lsp-ui-sideline-show-hover nil) - (setq lsp-ui-doc-show-with-cursor 't) - (setq lsp-ui-doc-delay 1) - (setq lsp-ui-sideline-show-code-actions 't) - (setq lsp-ui-sideline-update-mode 'point) - (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) - (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references) - ''; - }; + lsp-ui = { + enable = true; + after = ["lsp-mode"]; + config = '' + (setq lsp-ui-sideline-enable 't) + (setq lsp-ui-sideline-show-symbol nil) + (setq lsp-ui-sideline-show-hover nil) + (setq lsp-ui-doc-show-with-cursor 't) + (setq lsp-ui-doc-delay 1) + (setq lsp-ui-sideline-show-code-actions 't) + (setq lsp-ui-sideline-update-mode 'point) + (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) + (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references) + ''; + }; - lsp-ui-flycheck = { - enable = true; - package = epkgs: [ epkgs.lsp-ui ]; - after = [ "lsp-ui" ] - ++ optional (elem "emacs::flycheck" config.machine.pkgs) "flycheck"; + lsp-ui-flycheck = { + enable = true; + package = epkgs: [epkgs.lsp-ui]; + after = + ["lsp-ui"] + ++ optional (elem "emacs::flycheck" config.machine.pkgs) "flycheck"; + }; }; - }; -} + } diff --git a/pkgsets/emacs/magit.nix b/pkgsets/emacs/magit.nix index a63feb3..65b313c 100644 --- a/pkgsets/emacs/magit.nix +++ b/pkgsets/emacs/magit.nix @@ -1,12 +1,14 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::magit" config.machine.pkgs) { - programs.emacs.init.usePackage.magit = { - enable = true; - bind = { - "C-c m" = "magit-status"; + mkIf (elem "emacs::magit" config.machine.pkgs) { + programs.emacs.init.usePackage.magit = { + enable = true; + bind = { + "C-c m" = "magit-status"; + }; }; - }; -} + } diff --git a/pkgsets/emacs/mu4e.nix b/pkgsets/emacs/mu4e.nix index 843564b..3a24ee1 100644 --- a/pkgsets/emacs/mu4e.nix +++ b/pkgsets/emacs/mu4e.nix @@ -1,8 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let defaultEncrypt = pkgs.emacsPackages.trivialBuild rec { pname = "defaultencrypt"; version = "ba07acc8e9fd692534c39c7cdad0a19dc0d897d9"; @@ -14,106 +16,107 @@ let sha256 = "1ln7h1syx7yi7bqvirv90mk4rvwxg4zm1wvfcvhfh64s3hqrbfgl"; }; }; -in mkIf (elem "emacs::mu4e" config.machine.pkgs) { - programs.emacs.init.usePackage.pinentry = { - enable = true; - command = [ "pinentry-start" ]; - hook = [ "(after-init . pinentry-start)" ]; - }; - - programs.emacs.init.usePackage.mu4e = { - enable = true; - package = epkgs: null; - command = [ "mu4e" ]; - diminish = [ "mu4e-mode" ]; - hook = [ - "(mu4e-view-mode . visual-line-mode)" - "(mu4e-compose-mode . flyspell-mode)" - ''(message-send . (lambda () - (unless (yes-or-no-p "Send this message?") - (signal 'quit nil))))'' - ]; - bind = { "\t" = "'company-complete-common"; }; - bindLocal = rec { - mu4e-headers-mode-map = { - "C-+" = "nil"; - "C--" = "nil"; - }; - mu4e-view-mode-map = mu4e-headers-mode-map; +in + mkIf (elem "emacs::mu4e" config.machine.pkgs) { + programs.emacs.init.usePackage.pinentry = { + enable = true; + command = ["pinentry-start"]; + hook = ["(after-init . pinentry-start)"]; }; - init = '' - ;; (add-to-list 'load-path "${defaultEncrypt}/share/emacs/site-lisp") - ;; (require 'jl-encrypt) - ''; - config = '' - (setq mail-user-agent 'mu4e-user-agent) - (setq org-mu4e-link-query-in-headers-mode t) - (setq mu4e-maildir "~/.mail/Mail") - (setq mu4e-get-mail-command "${pkgs.isync}/bin/mbsync -a") - (setq mu4e-context-policy 'pick-first) - (setq mu4e-change-filenames-when-moving t) - (setq starttls-use-gnutls t) - (setq message-send-mail-function 'smtpmail-send-it) - (setq mu4e-update-interval 300) - (setq mu4e-use-fancy-chars t) - (setq mu4e-view-show-addresses t) - (setq mu4e-headers-show-threads t) - (setq mu4e-headers-skip-duplicates t) - (setq mail-user-agent 'mu4e-user-agent) - (defvaralias 'mu4e-compose-signature 'message-signature) - (setq-default mu4e-save-multiple-attachments-without-asking t) - (setq-default mu4e-view-show-addresses t) - (setq-default mu4e-confirm-quit nil) - (setq-default mu4e-hide-index-messages t) - (setq-default mu4e-index-update-in-background t) - (setq mu4e-compose-in-new-frame nil) - ;;rename files when moving - ;;NEEDED FOR MBSYNC - (setq mu4e-change-filenames-when-moving t) + programs.emacs.init.usePackage.mu4e = { + enable = true; + package = epkgs: null; + command = ["mu4e"]; + diminish = ["mu4e-mode"]; + hook = [ + "(mu4e-view-mode . visual-line-mode)" + "(mu4e-compose-mode . flyspell-mode)" + '' (message-send . (lambda () + (unless (yes-or-no-p "Send this message?") + (signal 'quit nil))))'' + ]; + bind = {"\t" = "'company-complete-common";}; + bindLocal = rec { + mu4e-headers-mode-map = { + "C-+" = "nil"; + "C--" = "nil"; + }; + mu4e-view-mode-map = mu4e-headers-mode-map; + }; + init = '' + ;; (add-to-list 'load-path "${defaultEncrypt}/share/emacs/site-lisp") + ;; (require 'jl-encrypt) + ''; + config = '' + (setq mail-user-agent 'mu4e-user-agent) + (setq org-mu4e-link-query-in-headers-mode t) + (setq mu4e-maildir "~/.mail/Mail") + (setq mu4e-get-mail-command "${pkgs.isync}/bin/mbsync -a") + (setq mu4e-context-policy 'pick-first) + (setq mu4e-change-filenames-when-moving t) + (setq starttls-use-gnutls t) + (setq message-send-mail-function 'smtpmail-send-it) + (setq mu4e-update-interval 300) + (setq mu4e-use-fancy-chars t) + (setq mu4e-view-show-addresses t) + (setq mu4e-headers-show-threads t) + (setq mu4e-headers-skip-duplicates t) + (setq mail-user-agent 'mu4e-user-agent) + (defvaralias 'mu4e-compose-signature 'message-signature) + (setq-default mu4e-save-multiple-attachments-without-asking t) + (setq-default mu4e-view-show-addresses t) + (setq-default mu4e-confirm-quit nil) + (setq-default mu4e-hide-index-messages t) + (setq-default mu4e-index-update-in-background t) + (setq mu4e-compose-in-new-frame nil) - (setq mu4e-html2text-command "iconv -c -t utf-8 | ${pkgs.pandoc}/bin/pandoc -f html -t plain") - (setq mu4e-view-show-images t) - (when (fboundp 'imagemagick-register-types) - (imagemagick-register-types)) - (setq message-kill-buffer-on-exit t) + ;;rename files when moving + ;;NEEDED FOR MBSYNC + (setq mu4e-change-filenames-when-moving t) - ;; Encryption Stuff - ;; (setq mml-secure-openpgp-sign-with-sender t) - ;; ;; (setq mm-sign-option ‘guided’) - ;; (setq epa-pinentry-mode 'loopback) - ;; mailAcc config goes here - (load-file "~/.emacs.d/mu4e.el") + (setq mu4e-html2text-command "iconv -c -t utf-8 | ${pkgs.pandoc}/bin/pandoc -f html -t plain") + (setq mu4e-view-show-images t) + (when (fboundp 'imagemagick-register-types) + (imagemagick-register-types)) + (setq message-kill-buffer-on-exit t) - (defun my-browse-url-firefox-privately (url &optional new-window) - "Make firefox open URL in private-browsing window." - (interactive (browse-url-interactive-arg "URL: ")) - (let ((process-environment (browse-url-process-environment))) - (apply 'start-process - (concat "firefox " url) - nil - browse-url-firefox-program - (list "-private-window" url)))) - (setq browse-url-browser-function 'my-browse-url-firefox-privately) - (add-to-list 'mu4e-view-actions - '("ViewInBrowser" . mu4e-action-view-in-browser) t) - ''; - extraConfig = '' - :load-path "${pkgs.mu}/share/emacs/site-lisp/mu4e" - ''; - }; + ;; Encryption Stuff + ;; (setq mml-secure-openpgp-sign-with-sender t) + ;; ;; (setq mm-sign-option ‘guided’) + ;; (setq epa-pinentry-mode 'loopback) + ;; mailAcc config goes here + (load-file "~/.emacs.d/mu4e.el") - programs.emacs.init.usePackage.mu4e-alert = { - enable = true; -# hook = [ "after-init . mu4e-alert-enable-mode-line-display" ]; - }; + (defun my-browse-url-firefox-privately (url &optional new-window) + "Make firefox open URL in private-browsing window." + (interactive (browse-url-interactive-arg "URL: ")) + (let ((process-environment (browse-url-process-environment))) + (apply 'start-process + (concat "firefox " url) + nil + browse-url-firefox-program + (list "-private-window" url)))) + (setq browse-url-browser-function 'my-browse-url-firefox-privately) + (add-to-list 'mu4e-view-actions + '("ViewInBrowser" . mu4e-action-view-in-browser) t) + ''; + extraConfig = '' + :load-path "${pkgs.mu}/share/emacs/site-lisp/mu4e" + ''; + }; -# programs.emacs.init.usePackage.org-mu4e = { -# enable = (elem "emacs::org" config.machine.pkgs); -# }; + programs.emacs.init.usePackage.mu4e-alert = { + enable = true; + # hook = [ "after-init . mu4e-alert-enable-mode-line-display" ]; + }; - environment.systemPackages = with pkgs; [ - mu - isync - ]; -} + # programs.emacs.init.usePackage.org-mu4e = { + # enable = (elem "emacs::org" config.machine.pkgs); + # }; + + environment.systemPackages = with pkgs; [ + mu + isync + ]; + } diff --git a/pkgsets/emacs/nix-mode.nix b/pkgsets/emacs/nix-mode.nix index 0b38cd5..34b9944 100644 --- a/pkgsets/emacs/nix-mode.nix +++ b/pkgsets/emacs/nix-mode.nix @@ -1,11 +1,13 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::nix-mode" config.machine.pkgs) { - programs.emacs.init.usePackage.nix-mode = { - enable = true; - mode = [ ''"\\.nix\\'"'' ]; - config = ''(setq nix-nixfmt-bin "nixfmt -w 150")''; - }; -} + mkIf (elem "emacs::nix-mode" config.machine.pkgs) { + programs.emacs.init.usePackage.nix-mode = { + enable = true; + mode = [''"\\.nix\\'"'']; + config = ''(setq nix-nixfmt-bin "nixfmt -w 150")''; + }; + } diff --git a/pkgsets/emacs/org.nix b/pkgsets/emacs/org.nix index a0dad20..dcf2264 100644 --- a/pkgsets/emacs/org.nix +++ b/pkgsets/emacs/org.nix @@ -1,426 +1,440 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::org" config.machine.pkgs) { + programs.emacs.init.usePackage.org = { + enable = true; + package = epkgs: [epkgs.org]; + mode = [''("\\.org\\'" . org-mode)'']; + command = ["org-mode"]; + hook = + [ + "(org-mode . (lambda () (org-indent-mode)))" + '' + (org-mode + . (lambda () + ;; Automatic line-wrapping in org-mode + ;;(auto-fill-mode 1) -mkIf (elem "emacs::org" config.machine.pkgs) { - programs.emacs.init.usePackage.org = { - enable = true; - package = epkgs: [ epkgs.org ]; - mode = [ ''("\\.org\\'" . org-mode)'' ]; - command = [ "org-mode" ]; - hook = [ "(org-mode . (lambda () (org-indent-mode)))" '' - (org-mode - . (lambda () - ;; Automatic line-wrapping in org-mode - ;;(auto-fill-mode 1) + (setq completion-at-point-functions + '(org-completion-symbols + ora-cap-filesystem)))) + '' + '' + (org-mode + . (lambda () + "Beautify Org Checkbox Symbol" + (push '("[ ]" . "☐" ) prettify-symbols-alist) + (push '("[X]" . "☑" ) prettify-symbols-alist) + (push '("[-]" . "❍" ) prettify-symbols-alist) + (prettify-symbols-mode))) + '' + ] + ++ optional (elem "emacs::flyspell" config.machine.pkgs) "(org-mode . (lambda () (flyspell-mode)))"; + bind = { + "C-c a" = "org-agenda"; + }; + bindLocal = { + org-mode-map = + { + "M-" = "org-metaup"; + "M-" = "org-metadown"; + "M-." = "org-open-at-point"; + "M-," = "org-mark-ring-goto"; + "M-S-" = "org-insert-todo-heading-respect-content"; + "M-" = "org-meta-return"; + "M-p" = "org-previous-visible-heading"; + "M-n" = "org-next-visible-heading"; + } + // (optionalAttrs (elem "emacs::company" config.machine.pkgs) { + "" = "company-pcomplete"; + }); + }; + config = '' + ;; Insead of "..." show "…" when there's hidden folded content - (setq completion-at-point-functions - '(org-completion-symbols - ora-cap-filesystem)))) - '' '' - (org-mode - . (lambda () - "Beautify Org Checkbox Symbol" - (push '("[ ]" . "☐" ) prettify-symbols-alist) - (push '("[X]" . "☑" ) prettify-symbols-alist) - (push '("[-]" . "❍" ) prettify-symbols-alist) - (prettify-symbols-mode))) - '' - ] ++ optional (elem "emacs::flyspell" config.machine.pkgs) "(org-mode . (lambda () (flyspell-mode)))"; - bind = { - "C-c a" = "org-agenda"; + ;; org-prettify + (defface org-checkbox-done-text + '((t (:foreground "#71696A" :strike-through t))) + "Face for the text part of a checked org-mode checkbox.") + + (font-lock-add-keywords + 'org-mode + `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)" + 1 'org-checkbox-done-text prepend)) + 'append) + + ;; Some characters to choose from: …, ⤵, ▼, ↴, ⬎, ⤷, and ⋱ + (setq org-ellipsis " ▼") + ;; get nice looking tables (only for non org-tables; rarely used) + (setq table-cell-horizontal-chars "\u2501") + (setq table-cell-vertical-char ?\u2503) + (setq table-cell-intersection-char ?\u254B) + + (setq org-directory "~/Documents/org/") + + ;; Show headings up to level 2 by default when opening an org files + (setq org-startup-folded 'content) + + ;; Show inline images by default + (setq org-startup-with-inline-images t) + + ;; Add more levels to headlines that get displayed with imenu + (setq org-imenu-depth 5) + + ;; Enter key follows links (= C-c C-o) + (setq org-return-follows-link t) + + ;; Don't remove links after inserting + (setq org-keep-stored-link-after-insertion t) + + (setq org-tag-alist (quote ((:startgroup) + ("WAITING" . ?w) + ("HOLD" . ?h) + ("CANCELLED" . ?c) + ("NOTE" . ?n) + (:endgroup) + ("PERSONAL" . ?P) + ("WORK" . ?W) + ("ATOMX" . ?A) + ("E5" . ?E) + ("HOGASO" . ?H) + ("ORG" . ?o) + ("crypt" . ?C) + ("FLAGGED" . ??)))) + + ;; Allow setting single tags without the menu + (setq org-fast-tag-selection-single-key (quote expert)) + + (setq org-archive-mark-done nil) + (setq org-archive-location "%s_archive::* Archived Tasks") + + ;; C-RET, C-S-RET insert new heading after current task content + (setq org-insert-heading-respect-content nil) + + ;; Show a little bit more when using sparse-trees + (setq org-show-following-heading t) + (setq org-show-hierarchy-above t) + (setq org-show-siblings (quote ((default)))) + + ;; don't show * / = etc + (setq org-hide-emphasis-markers t) + + ;; leave highlights in sparse tree after edit. C-c C-c removes highlights + (setq org-remove-highlights-with-change nil) + + ;; M-RET should not split the lines + (setq org-M-RET-may-split-line '((default . nil))) + + (setq org-special-ctrl-a/e t) + (setq org-special-ctrl-k t) + (setq org-yank-adjusted-subtrees t) + + ;; Show org entities as UTF-8 characters (e.g. \sum as ∑) + (setq org-pretty-entities t) + ;; But Don't print "bar" as subscript in "foo_bar" + (setq org-pretty-entities-include-sub-superscripts nil) + ;; And also don't display ^ or _ as super/subscripts + (setq org-use-sub-superscripts nil) + ;; undone TODO entries will block switching the parent to DONE + (setq org-enforce-todo-dependencies t) + + (setq org-use-fast-todo-selection t) + + (setq org-todo-keywords + (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") + (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")))) + + (setq org-todo-keyword-faces + (quote (("TODO" :foreground "red" :weight bold) + ("NEXT" :foreground "blue" :weight bold) + ("DONE" :foreground "forest green" :weight bold) + ("WAITING" :foreground "orange" :weight bold) + ("HOLD" :foreground "magenta" :weight bold) + ("CANCELLED" :foreground "forest green" :weight bold) + ("MEETING" :foreground "forest green" :weight bold) + ("PHONE" :foreground "forest green" :weight bold)))) + + ;; Auto completion for symbols in org-mode + ;; https://oremacs.com/2017/10/04/completion-at-point/ + (defun org-completion-symbols () + (when (looking-back "[`~=][a-zA-Z]+" nil) + (let (cands) + (save-match-data + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "[`~=]\\([a-zA-Z.\\-_]+\\)[`~=]" nil t) + (cl-pushnew + (match-string-no-properties 0) cands :test 'equal)) + cands)) + (when cands + (list (match-beginning 0) (match-end 0) cands))))) + + (defun ora-cap-filesystem () + (let (path) + (when (setq path (ffap-string-at-point)) + (when (string-match "\\`file:\\(.*\\)\\'" path) + (setq path (match-string 1 path))) + (let ((compl (all-completions path #'read-file-name-internal))) + (when compl + (let* ((str (car compl)) + (offset + (let ((i 0) + (len (length str))) + (while (and (< i len) + (equal (get-text-property i 'face str) + 'completions-common-part)) + (cl-incf i)) + i))) + (list (- (point) offset) (point) compl))))))) + + ''; }; - bindLocal = { org-mode-map = { - "M-" = "org-metaup"; - "M-" = "org-metadown"; - "M-." = "org-open-at-point"; - "M-," = "org-mark-ring-goto"; - "M-S-" = "org-insert-todo-heading-respect-content"; - "M-" = "org-meta-return"; - "M-p" = "org-previous-visible-heading"; - "M-n" = "org-next-visible-heading"; - } // (optionalAttrs (elem "emacs::company" config.machine.pkgs) { - "" = "company-pcomplete"; - }); }; - config = '' - ;; Insead of "..." show "…" when there's hidden folded content - ;; org-prettify - (defface org-checkbox-done-text - '((t (:foreground "#71696A" :strike-through t))) - "Face for the text part of a checked org-mode checkbox.") + programs.emacs.init.usePackage.ob = { + enable = true; + package = epkgs: [epkgs.ob-ipython epkgs.ob-rust epkgs.ob-diagrams]; + defer = true; + init = '' + (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append) + ''; + config = '' + (setq org-confirm-babel-evaluate nil) ; don't prompt me to confirm everytime I want to evaluate a block - (font-lock-add-keywords - 'org-mode - `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)" - 1 'org-checkbox-done-text prepend)) - 'append) + (defun org-babel-restart-session-to-point (&optional arg) + "Restart session up to the src-block in the current point. + Goes to beginning of buffer and executes each code block with + `org-babel-execute-src-block' that has the same language and + session as the current block. ARG has same meaning as in + `org-babel-execute-src-block'." + (interactive "P") + (unless (org-in-src-block-p) + (error "You must be in a src-block to run this command")) + (let* ((current-point (point-marker)) + (info (org-babel-get-src-block-info)) + (lang (nth 0 info)) + (params (nth 2 info)) + (session (cdr (assoc :session params)))) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward org-babel-src-block-regexp nil t) + ;; goto start of block + (goto-char (match-beginning 0)) + (let* ((this-info (org-babel-get-src-block-info)) + (this-lang (nth 0 this-info)) + (this-params (nth 2 this-info)) + (this-session (cdr (assoc :session this-params)))) + (when + (and + (< (point) (marker-position current-point)) + (string= lang this-lang) + (src-block-in-session-p session)) + (org-babel-execute-src-block arg))) + ;; move forward so we can find the next block + (forward-line))))) - ;; Some characters to choose from: …, ⤵, ▼, ↴, ⬎, ⤷, and ⋱ - (setq org-ellipsis " ▼") - ;; get nice looking tables (only for non org-tables; rarely used) - (setq table-cell-horizontal-chars "\u2501") - (setq table-cell-vertical-char ?\u2503) - (setq table-cell-intersection-char ?\u254B) + (defun org-babel-kill-session () + "Kill session for current code block." + (interactive) + (unless (org-in-src-block-p) + (error "You must be in a src-block to run this command")) + (save-window-excursion + (org-babel-switch-to-session) + (kill-buffer))) - (setq org-directory "~/Documents/org/") - - ;; Show headings up to level 2 by default when opening an org files - (setq org-startup-folded 'content) - - ;; Show inline images by default - (setq org-startup-with-inline-images t) - - ;; Add more levels to headlines that get displayed with imenu - (setq org-imenu-depth 5) - - ;; Enter key follows links (= C-c C-o) - (setq org-return-follows-link t) - - ;; Don't remove links after inserting - (setq org-keep-stored-link-after-insertion t) - - (setq org-tag-alist (quote ((:startgroup) - ("WAITING" . ?w) - ("HOLD" . ?h) - ("CANCELLED" . ?c) - ("NOTE" . ?n) - (:endgroup) - ("PERSONAL" . ?P) - ("WORK" . ?W) - ("ATOMX" . ?A) - ("E5" . ?E) - ("HOGASO" . ?H) - ("ORG" . ?o) - ("crypt" . ?C) - ("FLAGGED" . ??)))) - - ;; Allow setting single tags without the menu - (setq org-fast-tag-selection-single-key (quote expert)) - - (setq org-archive-mark-done nil) - (setq org-archive-location "%s_archive::* Archived Tasks") - - ;; C-RET, C-S-RET insert new heading after current task content - (setq org-insert-heading-respect-content nil) - - ;; Show a little bit more when using sparse-trees - (setq org-show-following-heading t) - (setq org-show-hierarchy-above t) - (setq org-show-siblings (quote ((default)))) - - ;; don't show * / = etc - (setq org-hide-emphasis-markers t) - - ;; leave highlights in sparse tree after edit. C-c C-c removes highlights - (setq org-remove-highlights-with-change nil) - - ;; M-RET should not split the lines - (setq org-M-RET-may-split-line '((default . nil))) - - (setq org-special-ctrl-a/e t) - (setq org-special-ctrl-k t) - (setq org-yank-adjusted-subtrees t) - - ;; Show org entities as UTF-8 characters (e.g. \sum as ∑) - (setq org-pretty-entities t) - ;; But Don't print "bar" as subscript in "foo_bar" - (setq org-pretty-entities-include-sub-superscripts nil) - ;; And also don't display ^ or _ as super/subscripts - (setq org-use-sub-superscripts nil) - ;; undone TODO entries will block switching the parent to DONE - (setq org-enforce-todo-dependencies t) - - (setq org-use-fast-todo-selection t) - - (setq org-todo-keywords - (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") - (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")))) - - (setq org-todo-keyword-faces - (quote (("TODO" :foreground "red" :weight bold) - ("NEXT" :foreground "blue" :weight bold) - ("DONE" :foreground "forest green" :weight bold) - ("WAITING" :foreground "orange" :weight bold) - ("HOLD" :foreground "magenta" :weight bold) - ("CANCELLED" :foreground "forest green" :weight bold) - ("MEETING" :foreground "forest green" :weight bold) - ("PHONE" :foreground "forest green" :weight bold)))) - - ;; Auto completion for symbols in org-mode - ;; https://oremacs.com/2017/10/04/completion-at-point/ - (defun org-completion-symbols () - (when (looking-back "[`~=][a-zA-Z]+" nil) - (let (cands) - (save-match-data + (defun org-babel-remove-result-buffer () + "Remove results from every code block in buffer." + (interactive) (save-excursion (goto-char (point-min)) - (while (re-search-forward "[`~=]\\([a-zA-Z.\\-_]+\\)[`~=]" nil t) - (cl-pushnew - (match-string-no-properties 0) cands :test 'equal)) - cands)) - (when cands - (list (match-beginning 0) (match-end 0) cands))))) - -(defun ora-cap-filesystem () - (let (path) - (when (setq path (ffap-string-at-point)) - (when (string-match "\\`file:\\(.*\\)\\'" path) - (setq path (match-string 1 path))) - (let ((compl (all-completions path #'read-file-name-internal))) - (when compl - (let* ((str (car compl)) - (offset - (let ((i 0) - (len (length str))) - (while (and (< i len) - (equal (get-text-property i 'face str) - 'completions-common-part)) - (cl-incf i)) - i))) - (list (- (point) offset) (point) compl))))))) - - ''; - }; - - programs.emacs.init.usePackage.ob = { - enable = true; - package = epkgs: [ epkgs.ob-ipython epkgs.ob-rust epkgs.ob-diagrams ]; - defer = true; - init = '' - (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append) - ''; - config = '' - (setq org-confirm-babel-evaluate nil) ; don't prompt me to confirm everytime I want to evaluate a block - - (defun org-babel-restart-session-to-point (&optional arg) - "Restart session up to the src-block in the current point. - Goes to beginning of buffer and executes each code block with - `org-babel-execute-src-block' that has the same language and - session as the current block. ARG has same meaning as in - `org-babel-execute-src-block'." - (interactive "P") - (unless (org-in-src-block-p) - (error "You must be in a src-block to run this command")) - (let* ((current-point (point-marker)) - (info (org-babel-get-src-block-info)) - (lang (nth 0 info)) - (params (nth 2 info)) - (session (cdr (assoc :session params)))) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward org-babel-src-block-regexp nil t) - ;; goto start of block - (goto-char (match-beginning 0)) - (let* ((this-info (org-babel-get-src-block-info)) - (this-lang (nth 0 this-info)) - (this-params (nth 2 this-info)) - (this-session (cdr (assoc :session this-params)))) - (when - (and - (< (point) (marker-position current-point)) - (string= lang this-lang) - (src-block-in-session-p session)) - (org-babel-execute-src-block arg))) - ;; move forward so we can find the next block - (forward-line))))) - - (defun org-babel-kill-session () - "Kill session for current code block." - (interactive) - (unless (org-in-src-block-p) - (error "You must be in a src-block to run this command")) - (save-window-excursion - (org-babel-switch-to-session) - (kill-buffer))) - - (defun org-babel-remove-result-buffer () - "Remove results from every code block in buffer." - (interactive) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward org-babel-src-block-regexp nil t) - (org-babel-remove-result)))) + (while (re-search-forward org-babel-src-block-regexp nil t) + (org-babel-remove-result)))) - ;; this adds a "new language" in babel that gets exported as js in html - ;; https://www.reddit.com/r/orgmode/comments/5bi6ku/tip_for_exporting_javascript_source_block_to/ - (add-to-list 'org-src-lang-modes '("inline-js" . javascript)) - (defvar org-babel-default-header-args:inline-js - '((:results . "html") - (:exports . "results"))) - (defun org-babel-execute:inline-js (body _params) - (format "" body)) + ;; this adds a "new language" in babel that gets exported as js in html + ;; https://www.reddit.com/r/orgmode/comments/5bi6ku/tip_for_exporting_javascript_source_block_to/ + (add-to-list 'org-src-lang-modes '("inline-js" . javascript)) + (defvar org-babel-default-header-args:inline-js + '((:results . "html") + (:exports . "results"))) + (defun org-babel-execute:inline-js (body _params) + (format "" body)) - ;; Path when plantuml is installed from AUR (package `plantuml') - (setq org-plantuml-jar-path "/opt/plantuml/plantuml.jar") + ;; Path when plantuml is installed from AUR (package `plantuml') + (setq org-plantuml-jar-path "/opt/plantuml/plantuml.jar") - ;; add all languages to org mode - (org-babel-do-load-languages - 'org-babel-load-languages - '((C . t) - ;;(R . t) - (asymptote) - (awk) - (calc . t) - (clojure . t) - (comint) - (css) - (ditaa . t) - (dot . t) - (emacs-lisp . t) - (fortran) - (gnuplot . t) - (haskell) - (io) - (java) - (js . t) - (latex) - (lilypond) - (lisp) - (lua . t) - (matlab) - (maxima) - (mscgen) - (ocaml) - (octave . t) - (org . t) - (perl) - (picolisp) - (plantuml . t) - (python . t) - ;; (ipython . t) - ;; (restclient . t) - (ref) - (ruby) - (sass) - (scala) - (scheme) - (screen) - (shell . t) - (shen) - (snippet) - (sql . t) - (sqlite . t))) - ''; - }; + ;; add all languages to org mode + (org-babel-do-load-languages + 'org-babel-load-languages + '((C . t) + ;;(R . t) + (asymptote) + (awk) + (calc . t) + (clojure . t) + (comint) + (css) + (ditaa . t) + (dot . t) + (emacs-lisp . t) + (fortran) + (gnuplot . t) + (haskell) + (io) + (java) + (js . t) + (latex) + (lilypond) + (lisp) + (lua . t) + (matlab) + (maxima) + (mscgen) + (ocaml) + (octave . t) + (org . t) + (perl) + (picolisp) + (plantuml . t) + (python . t) + ;; (ipython . t) + ;; (restclient . t) + (ref) + (ruby) + (sass) + (scala) + (scheme) + (screen) + (shell . t) + (shen) + (snippet) + (sql . t) + (sqlite . t))) + ''; + }; - programs.emacs.init.usePackage.org-src = { - enable = true; - package = epkgs: null; - defer = true; - init = ''(put 'org-src-preserve-indentation 'safe-local-variable 'booleanp)''; - config = '' - (setq org-src-window-setup 'current-window) + programs.emacs.init.usePackage.org-src = { + enable = true; + package = epkgs: null; + defer = true; + init = ''(put 'org-src-preserve-indentation 'safe-local-variable 'booleanp)''; + config = '' + (setq org-src-window-setup 'current-window) - (setq org-src-fontify-natively t) ; syntax highlighting for source code blocks + (setq org-src-fontify-natively t) ; syntax highlighting for source code blocks - ;; Tab should do indent in code blocks - ;; I think I hate this function (causes scroll on TAB - (setq org-src-tab-acts-natively t) - ;; ?Fix weird scrolling + ;; Tab should do indent in code blocks + ;; I think I hate this function (causes scroll on TAB + (setq org-src-tab-acts-natively t) + ;; ?Fix weird scrolling - ;; Don't remove (or add) any extra whitespace - (setq org-src-preserve-indentation nil) - (setq org-edit-src-content-indentation 0) + ;; Don't remove (or add) any extra whitespace + (setq org-src-preserve-indentation nil) + (setq org-edit-src-content-indentation 0) - ;;; Some helper function to manage org-babel sessions + ;;; Some helper function to manage org-babel sessions - (defun src-block-in-session-p (&optional name) - "Return if src-block is in a session of NAME. - NAME may be nil for unnamed sessions." - (let* ((info (org-babel-get-src-block-info)) - ;;(lang (nth 0 info)) - ;;(body (nth 1 info)) - (params (nth 2 info)) - (session (cdr (assoc :session params)))) + (defun src-block-in-session-p (&optional name) + "Return if src-block is in a session of NAME. + NAME may be nil for unnamed sessions." + (let* ((info (org-babel-get-src-block-info)) + ;;(lang (nth 0 info)) + ;;(body (nth 1 info)) + (params (nth 2 info)) + (session (cdr (assoc :session params)))) - (cond - ;; unnamed session, both name and session are nil - ((and (null session) - (null name)) - t) - ;; Matching name and session - ((and - (stringp name) - (stringp session) - (string= name session)) - t) - ;; no match - (t nil)))) + (cond + ;; unnamed session, both name and session are nil + ((and (null session) + (null name)) + t) + ;; Matching name and session + ((and + (stringp name) + (stringp session) + (string= name session)) + t) + ;; no match + (t nil)))) - ;; dot == graphviz-dot - (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) + ;; dot == graphviz-dot + (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) - ;; Add 'conf-mode' to org-babel - (add-to-list 'org-src-lang-modes '("ini" . conf)) - (add-to-list 'org-src-lang-modes '("conf" . conf)) - ''; - }; + ;; Add 'conf-mode' to org-babel + (add-to-list 'org-src-lang-modes '("ini" . conf)) + (add-to-list 'org-src-lang-modes '("conf" . conf)) + ''; + }; - programs.emacs.init.usePackage.org-tempo = { - enable = true; - package = epkgs: null; - }; + programs.emacs.init.usePackage.org-tempo = { + enable = true; + package = epkgs: null; + }; - programs.emacs.init.usePackage.ox = { - enable = true; - package = epkgs: null; - defer = true; - command = []; - config = '' - ;; Use html5 as org export and use new tags - (setq org-html-doctype "html5") - (setq org-html-html5-fancy t) - ;; Don't add html footer to export - (setq org-html-postamble nil) - ;; Don't export ^ or _ as super/subscripts - (setq org-export-with-sub-superscripts nil) - ''; - }; + programs.emacs.init.usePackage.ox = { + enable = true; + package = epkgs: null; + defer = true; + command = []; + config = '' + ;; Use html5 as org export and use new tags + (setq org-html-doctype "html5") + (setq org-html-html5-fancy t) + ;; Don't add html footer to export + (setq org-html-postamble nil) + ;; Don't export ^ or _ as super/subscripts + (setq org-export-with-sub-superscripts nil) + ''; + }; - programs.emacs.init.usePackage.ox-gfm = { - enable = true; - after = [ "ox" ]; - }; + programs.emacs.init.usePackage.ox-gfm = { + enable = true; + after = ["ox"]; + }; - programs.emacs.init.usePackage.ox-rst = { - enable = true; - after = [ "ox" ]; - }; + programs.emacs.init.usePackage.ox-rst = { + enable = true; + after = ["ox"]; + }; - programs.emacs.init.usePackage.ox-md = { - enable = true; - package = epkgs: null; - after = [ "ox" ]; - }; + programs.emacs.init.usePackage.ox-md = { + enable = true; + package = epkgs: null; + after = ["ox"]; + }; - programs.emacs.init.usePackage.org-bullets = { - enable = true; - hook = [ "(org-mode . org-bullets-mode)" ]; - }; + programs.emacs.init.usePackage.org-bullets = { + enable = true; + hook = ["(org-mode . org-bullets-mode)"]; + }; - programs.emacs.init.usePackage.org-crypt = { - enable = true; - package = epkgs: null; - after = [ "org" ]; - hook = [ "(org-mode . (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))" ]; - command = [ "org-decrypt-entry" "org-encrypt-entry" ]; - bindLocal = { org-mode-map = { - "C-c d" = "org-decrypt-entry"; - "C-c e" = "org-encrypt-entry"; - };}; - config = '' - (setq org-tags-exclude-from-inheritance (quote ("crypt"))) - ;; GPG key to use for encryption - (load-file "~/.emacs.d/org-crypt-key.el") + programs.emacs.init.usePackage.org-crypt = { + enable = true; + package = epkgs: null; + after = ["org"]; + hook = ["(org-mode . (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))"]; + command = ["org-decrypt-entry" "org-encrypt-entry"]; + bindLocal = { + org-mode-map = { + "C-c d" = "org-decrypt-entry"; + "C-c e" = "org-encrypt-entry"; + }; + }; + config = '' + (setq org-tags-exclude-from-inheritance (quote ("crypt"))) + ;; GPG key to use for encryption + (load-file "~/.emacs.d/org-crypt-key.el") - ;; don't ask to disable auto-save - (setq org-crypt-disable-auto-save "encrypt") - ''; - }; + ;; don't ask to disable auto-save + (setq org-crypt-disable-auto-save "encrypt") + ''; + }; - programs.emacs.init.usePackage.org-drill = { - enable = true; - }; -} + programs.emacs.init.usePackage.org-drill = { + enable = true; + }; + } diff --git a/pkgsets/emacs/php-mode.nix b/pkgsets/emacs/php-mode.nix index 8546a9f..43a5718 100644 --- a/pkgsets/emacs/php-mode.nix +++ b/pkgsets/emacs/php-mode.nix @@ -1,13 +1,16 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::php-mode" config.machine.pkgs) { - programs.emacs.init.usePackage = { - php-mode = { - enable = true; - hook = lib.optional (elem "emacs::lsp" config.machine.pkgs) - ''(typescript-mode . (lambda () (lsp)))''; + mkIf (elem "emacs::php-mode" config.machine.pkgs) { + programs.emacs.init.usePackage = { + php-mode = { + enable = true; + hook = + lib.optional (elem "emacs::lsp" config.machine.pkgs) + ''(typescript-mode . (lambda () (lsp)))''; + }; }; - }; -} + } diff --git a/pkgsets/emacs/powerline.nix b/pkgsets/emacs/powerline.nix index 56bdec2..aa5e050 100644 --- a/pkgsets/emacs/powerline.nix +++ b/pkgsets/emacs/powerline.nix @@ -1,16 +1,18 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::powerline" config.machine.pkgs) { - programs.emacs.init.usePackage.powerline = { - enable = true; - config = '' - ;; color palette from https://github.com/kuanyui/moe-theme.el/blob/master/moe-theme.el#L283 - (set-face-attribute 'mode-line nil :background "#afd7ff" :foreground "#005f87") - (set-face-attribute 'mode-line-buffer-id nil :background "#afd7ff" :foreground "#080808") - (set-face-attribute 'minibuffer-prompt nil :foreground "#5fafd7" :background "#3a3a3a") - (powerline-default-theme) - ''; - }; -} + mkIf (elem "emacs::powerline" config.machine.pkgs) { + programs.emacs.init.usePackage.powerline = { + enable = true; + config = '' + ;; color palette from https://github.com/kuanyui/moe-theme.el/blob/master/moe-theme.el#L283 + (set-face-attribute 'mode-line nil :background "#afd7ff" :foreground "#005f87") + (set-face-attribute 'mode-line-buffer-id nil :background "#afd7ff" :foreground "#080808") + (set-face-attribute 'minibuffer-prompt nil :foreground "#5fafd7" :background "#3a3a3a") + (powerline-default-theme) + ''; + }; + } diff --git a/pkgsets/emacs/rust.nix b/pkgsets/emacs/rust.nix index ee62be2..4fffbb9 100644 --- a/pkgsets/emacs/rust.nix +++ b/pkgsets/emacs/rust.nix @@ -1,45 +1,55 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let rustEnv = pkgs.symlinkJoin { name = "rustEnv"; paths = config.machine.pkgsets.rustpkgs.pkgwrap; }; -in mkIf (elem "emacs::rust" config.machine.pkgs) { - programs.emacs.init.usePackage.rust-mode = { - enable = true; - hook = [ ''(rust-mode . (lambda () (cargo-minor-mode)))'' ] - ++ (if (elem "emacs::lsp" config.machine.pkgs) - then [''(rust-mode . (lambda () (lsp)))''] - else [''(rust-mode . (lambda () (racer-mode)))'']); - mode = [ ''("\\.rs\\'" . rust-mode)'' ]; - command = [ "rust-mode" ]; - bindLocal = optionalAttrs (elem "emacs::company" config.machine.pkgs) { rust-mode-map = { - "" = "company-indent-or-complete-common"; - };}; - config = '' - (setq rust-rustfmt-bin "${rustEnv}/bin/rustfmt") - (setq rust-format-on-save t) - ''; - }; +in + mkIf (elem "emacs::rust" config.machine.pkgs) { + programs.emacs.init.usePackage.rust-mode = { + enable = true; + hook = + [''(rust-mode . (lambda () (cargo-minor-mode)))''] + ++ ( + if (elem "emacs::lsp" config.machine.pkgs) + then [''(rust-mode . (lambda () (lsp)))''] + else [''(rust-mode . (lambda () (racer-mode)))''] + ); + mode = [''("\\.rs\\'" . rust-mode)'']; + command = ["rust-mode"]; + bindLocal = optionalAttrs (elem "emacs::company" config.machine.pkgs) { + rust-mode-map = { + "" = "company-indent-or-complete-common"; + }; + }; + config = '' + (setq rust-rustfmt-bin "${rustEnv}/bin/rustfmt") + (setq rust-format-on-save t) + ''; + }; - programs.emacs.init.usePackage.cargo = { - enable = true; - defer = true; - }; + programs.emacs.init.usePackage.cargo = { + enable = true; + defer = true; + }; - programs.emacs.init.usePackage.racer = { - enable = true; - defer = true; - hook = [ - ''(racer-mode . (lambda () (eldoc-mode)))'' - ] ++ optional (elem "emacs::company" config.machine.pkgs) ''(racer-mode . (lambda () (company-mode)))''; + programs.emacs.init.usePackage.racer = { + enable = true; + defer = true; + hook = + [ + ''(racer-mode . (lambda () (eldoc-mode)))'' + ] + ++ optional (elem "emacs::company" config.machine.pkgs) ''(racer-mode . (lambda () (company-mode)))''; - config = '' - (setq racer-rust-src-path "${rustEnv}/lib/rustlib/src/rust/src") - (setq racer-cmd "${rustEnv}/bin/racer") - ''; - }; -} + config = '' + (setq racer-rust-src-path "${rustEnv}/lib/rustlib/src/rust/src") + (setq racer-cmd "${rustEnv}/bin/racer") + ''; + }; + } diff --git a/pkgsets/emacs/solarized-theme.nix b/pkgsets/emacs/solarized-theme.nix index 5ba5249..87bd900 100644 --- a/pkgsets/emacs/solarized-theme.nix +++ b/pkgsets/emacs/solarized-theme.nix @@ -1,10 +1,12 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::solarized-theme" config.machine.pkgs) { - programs.emacs.init.usePackage.solarized-theme = { - enable = true; - config = "(load-theme 'solarized-dark t)"; - }; -} + mkIf (elem "emacs::solarized-theme" config.machine.pkgs) { + programs.emacs.init.usePackage.solarized-theme = { + enable = true; + config = "(load-theme 'solarized-dark t)"; + }; + } diff --git a/pkgsets/emacs/telega.nix b/pkgsets/emacs/telega.nix index 2df8925..7e2c83c 100644 --- a/pkgsets/emacs/telega.nix +++ b/pkgsets/emacs/telega.nix @@ -1,15 +1,17 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::telega" config.machine.pkgs) { - programs.emacs.init.usePackage.telegram = { - enable = true; - defer = true; - package = epkgs: [ epkgs.telega epkgs.visual-fill-column ]; - command = [ "telega" ]; - config = '' - (telega-alert-mode 1) - ''; - }; -} + mkIf (elem "emacs::telega" config.machine.pkgs) { + programs.emacs.init.usePackage.telegram = { + enable = true; + defer = true; + package = epkgs: [epkgs.telega epkgs.visual-fill-column]; + command = ["telega"]; + config = '' + (telega-alert-mode 1) + ''; + }; + } diff --git a/pkgsets/emacs/transmission.nix b/pkgsets/emacs/transmission.nix index a8b7c79..e654242 100644 --- a/pkgsets/emacs/transmission.nix +++ b/pkgsets/emacs/transmission.nix @@ -1,47 +1,50 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "emacs::transmission" config.machine.pkgs) { - programs.emacs.init.usePackage = { - transmission = { - enable = true; - defer = true; - command = [ "transmission" ]; - bindLocal = { - transmission-mode-map = { - "A" = ''(lambda () - (interactive) - (transmission-add (read-string "Magnet URI: ")))''; + mkIf (elem "emacs::transmission" config.machine.pkgs) { + programs.emacs.init.usePackage = { + transmission = { + enable = true; + defer = true; + command = ["transmission"]; + bindLocal = { + transmission-mode-map = { + "A" = '' (lambda () + (interactive) + (transmission-add (read-string "Magnet URI: ")))''; + }; }; - }; - config = '' - ;; Auto refresh for all transmission buffers - (setq transmission-refresh-modes '(transmission-mode - transmission-files-mode - transmission-info-mode - transmission-peers-mode)) + config = '' + ;; Auto refresh for all transmission buffers + (setq transmission-refresh-modes '(transmission-mode + transmission-files-mode + transmission-info-mode + transmission-peers-mode)) - (defun transmission () - "Open a `transmission-mode' buffer." - (interactive) - (let* ((name "*transmission*") - (buffer (or (get-buffer name) - (generate-new-buffer name)))) - (transmission-turtle-poll) - (unless (eq buffer (current-buffer)) - (with-current-buffer buffer - (unless (eq major-mode 'transmission-mode) - (condition-case e - (progn - (transmission-mode) - (revert-buffer) - (goto-char (point-min))) - (error - (kill-buffer buffer) - (signal (car e) (cdr e)))))) - (switch-to-buffer buffer)))) - ''; + (defun transmission () + "Open a `transmission-mode' buffer." + (interactive) + (let* ((name "*transmission*") + (buffer (or (get-buffer name) + (generate-new-buffer name)))) + (transmission-turtle-poll) + (unless (eq buffer (current-buffer)) + (with-current-buffer buffer + (unless (eq major-mode 'transmission-mode) + (condition-case e + (progn + (transmission-mode) + (revert-buffer) + (goto-char (point-min))) + (error + (kill-buffer buffer) + (signal (car e) (cdr e)))))) + (switch-to-buffer buffer)))) + ''; + }; }; - }; -} + } diff --git a/pkgsets/emacs/undo-tree.nix b/pkgsets/emacs/undo-tree.nix index 8fd68d2..564514c 100644 --- a/pkgsets/emacs/undo-tree.nix +++ b/pkgsets/emacs/undo-tree.nix @@ -1,16 +1,18 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "emacs::undo-tree" config.machine.pkgs) { - programs.emacs.init.usePackage.undo-tree = { - enable = true; - hook = [ "(after-init . global-undo-tree-mode)" ]; - config = '' - (setq undo-tree-visualizer-diff 't) - (setq undo-tree-auto-save-history 't) - (setq undo-tree-enable-undo-in-region 't) - (setq undo-tree-history-directory-alist '(("." . "~/.emacs_undo"))) - ''; - }; -} + mkIf (elem "emacs::undo-tree" config.machine.pkgs) { + programs.emacs.init.usePackage.undo-tree = { + enable = true; + hook = ["(after-init . global-undo-tree-mode)"]; + config = '' + (setq undo-tree-visualizer-diff 't) + (setq undo-tree-auto-save-history 't) + (setq undo-tree-enable-undo-in-region 't) + (setq undo-tree-history-directory-alist '(("." . "~/.emacs_undo"))) + ''; + }; + } diff --git a/pkgsets/emacs/web-mode.nix b/pkgsets/emacs/web-mode.nix index 5f3cb61..2e16941 100644 --- a/pkgsets/emacs/web-mode.nix +++ b/pkgsets/emacs/web-mode.nix @@ -1,98 +1,100 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; + mkIf (elem "emacs::web-mode" config.machine.pkgs) { + programs.emacs.init.usePackage = { + web-mode = { + enable = true; + init = "(require 'sgml-mode)"; + hook = [ + "(web-mode . (lambda () (sgml-electric-tag-pair-mode)))" + '' + (web-mode . (lambda () + (when (and (buffer-file-name) + (equal (file-name-extension (buffer-file-name)) "svelte")) + (lsp)))) + '' + ]; + # bind = {}; + mode = [ + ''("\\.html\\'" . web-mode)'' + ''("\\.css\\'" . web-mode)'' + ''("\\.html?\\'" . web-mode)'' + ''("\\.svelte\\'" . web-mode)'' + ''("\\.phtml\\'" . web-mode)'' + ''("\\.tpl\\.php\\'" . web-mode)'' + ''("\\.[agj]sp\\'" . web-mode)'' + ''("\\.as[cp]x\\'" . web-mode)'' + ''("\\.erb\\'" . web-mode)'' + ''("\\.mustache\\'" . web-mode)'' + ''("\\.djhtml\\'" . web-mode)'' + ]; + config = '' + (setq web-mode-markup-indent-offset 2) + (setq web-mode-css-indent-offset 2) + (setq web-mode-code-indent-offset 2) + (setq web-mode-sql-indent-offset 2) + (setq web-mode-script-padding 2) + (setq web-mode-style-padding 2) + (setq web-mode-part-padding 2) + (setq web-mode-block-padding 2) + (setq web-mode-enable-comment-annotation 't) -mkIf (elem "emacs::web-mode" config.machine.pkgs) { - programs.emacs.init.usePackage = { - web-mode = { - enable = true; - init = "(require 'sgml-mode)"; - hook = [ - "(web-mode . (lambda () (sgml-electric-tag-pair-mode)))" - '' - (web-mode . (lambda () - (when (and (buffer-file-name) - (equal (file-name-extension (buffer-file-name)) "svelte")) - (lsp)))) - '' - ]; - # bind = {}; - mode = [ - ''("\\.html\\'" . web-mode)'' - ''("\\.css\\'" . web-mode)'' - ''("\\.html?\\'" . web-mode)'' - ''("\\.svelte\\'" . web-mode)'' - ''("\\.phtml\\'" . web-mode)'' - ''("\\.tpl\\.php\\'" . web-mode)'' - ''("\\.[agj]sp\\'" . web-mode)'' - ''("\\.as[cp]x\\'" . web-mode)'' - ''("\\.erb\\'" . web-mode)'' - ''("\\.mustache\\'" . web-mode)'' - ''("\\.djhtml\\'" . web-mode)'' - ]; - config = '' - (setq web-mode-markup-indent-offset 2) - (setq web-mode-css-indent-offset 2) - (setq web-mode-code-indent-offset 2) - (setq web-mode-sql-indent-offset 2) - (setq web-mode-script-padding 2) - (setq web-mode-style-padding 2) - (setq web-mode-part-padding 2) - (setq web-mode-block-padding 2) - (setq web-mode-enable-comment-annotation 't) + (setq web-mode-enable-current-element-highlight 't) - (setq web-mode-enable-current-element-highlight 't) + (setq web-mode-enable-sql-detection 't) + (setq web-mode-auto-close-style 2) - (setq web-mode-enable-sql-detection 't) - (setq web-mode-auto-close-style 2) - - (setq web-mode-engines-alist - '(("php" . "\\.phtml\\'") - ("blade" . "\\.blade\\.")) - ) - ''; + (setq web-mode-engines-alist + '(("php" . "\\.phtml\\'") + ("blade" . "\\.blade\\.")) + ) + ''; + }; + js2-mode = { + enable = true; + mode = [ + ''("\\.js\\'" . js2-mode)'' + ]; + }; + typescript-mode = { + enable = true; + hook = + ["(typescript-mode . (lambda () (subword-mode)))"] + ++ lib.optional (elem "emacs::lsp" config.machine.pkgs) + ''(typescript-mode . (lambda () (lsp)))''; + mode = [ + ''("\\.ts\\'" . typescript-mode)'' + ''("\\.tsx?\\'" . typescript-tsx-mode)'' + ]; + init = '' + (define-derived-mode typescript-tsx-mode typescript-mode "tsx") + ''; + config = '' + (setq typescript-indent-level 2) + ''; + }; + # https://github.com/NixOS/nixpkgs/pull/150239 + tree-sitter = { + enable = true; + package = epkgs: [epkgs.tree-sitter (epkgs.tree-sitter-langs.withPlugins (p: epkgs.tree-sitter-langs.plugins ++ [p.tree-sitter-markdown p.tree-sitter-tsx]))]; + hook = [ + "(typescript-mode . tree-sitter-hl-mode)" + "(typescript-tsx-mode . tree-sitter-hl-mode)" + ]; + config = '' + (tree-sitter-require 'tsx) + (add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx)) + ''; + }; + impatient-mode = { + enable = true; + }; + simple-httpd = { + enable = true; + }; }; - js2-mode = { - enable = true; - mode = [ - ''("\\.js\\'" . js2-mode)'' - ]; - }; - typescript-mode = { - enable = true; - hook = [ "(typescript-mode . (lambda () (subword-mode)))" ] - ++ lib.optional (elem "emacs::lsp" config.machine.pkgs) - ''(typescript-mode . (lambda () (lsp)))''; - mode = [ - ''("\\.ts\\'" . typescript-mode)'' - ''("\\.tsx?\\'" . typescript-tsx-mode)'' - ]; - init = '' - (define-derived-mode typescript-tsx-mode typescript-mode "tsx") - ''; - config = '' - (setq typescript-indent-level 2) - ''; - }; - # https://github.com/NixOS/nixpkgs/pull/150239 - tree-sitter = { - enable = true; - package = (epkgs: [ epkgs.tree-sitter (epkgs.tree-sitter-langs.withPlugins(p: epkgs.tree-sitter-langs.plugins ++ [ p.tree-sitter-markdown p.tree-sitter-tsx ]))]); - hook = [ - "(typescript-mode . tree-sitter-hl-mode)" - "(typescript-tsx-mode . tree-sitter-hl-mode)" - ]; - config = '' - (tree-sitter-require 'tsx) - (add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx)) - ''; - - }; - impatient-mode = { - enable = true; - }; - simple-httpd = { - enable = true; - }; - }; -} + } diff --git a/pkgsets/emacs/yaml-mode.nix b/pkgsets/emacs/yaml-mode.nix index 4fcac9d..1946615 100644 --- a/pkgsets/emacs/yaml-mode.nix +++ b/pkgsets/emacs/yaml-mode.nix @@ -1,11 +1,14 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "emacs::yaml-mode" config.machine.pkgs) { - programs.emacs.init.usePackage = { - yaml-mode = { - enable = true; + mkIf (elem "emacs::yaml-mode" config.machine.pkgs) { + programs.emacs.init.usePackage = { + yaml-mode = { + enable = true; + }; }; - }; -} + } diff --git a/pkgsets/emacs/yasnippet.nix b/pkgsets/emacs/yasnippet.nix index 5120ff0..d5d03fc 100644 --- a/pkgsets/emacs/yasnippet.nix +++ b/pkgsets/emacs/yasnippet.nix @@ -1,18 +1,21 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; + mkIf (elem "emacs::yasnippet" config.machine.pkgs) { + programs.emacs.init.usePackage = { + yasnippet = { + enable = true; + hook = ["(after-init . yas-global-mode)"]; + # config = '' -mkIf (elem "emacs::yasnippet" config.machine.pkgs) { - programs.emacs.init.usePackage = { - yasnippet = { - enable = true; - hook = [ "(after-init . yas-global-mode)" ]; - # config = '' - - # ''; + # ''; + }; + yasnippet-snippets = { + enable = true; + }; }; - yasnippet-snippets = { - enable = true; - }; - }; -} + } diff --git a/pkgsets/extra.nix b/pkgsets/extra.nix index 620f3be..ffe935a 100644 --- a/pkgsets/extra.nix +++ b/pkgsets/extra.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.extra.pkgs = with pkgs; [ alsaUtils binutils-unwrapped diff --git a/pkgsets/haskell-tools.nix b/pkgsets/haskell-tools.nix index 5483ca5..8d5d1f4 100644 --- a/pkgsets/haskell-tools.nix +++ b/pkgsets/haskell-tools.nix @@ -1,5 +1,7 @@ -{ config, pkgs, ... }: - { - config.machine.pkgsets.haskell-tools.pkgs = with pkgs; [ cabal-install hlint ]; # ghcid + config, + pkgs, + ... +}: { + config.machine.pkgsets.haskell-tools.pkgs = with pkgs; [cabal-install hlint]; # ghcid } diff --git a/pkgsets/haskell.nix b/pkgsets/haskell.nix index bf8b684..a47941b 100644 --- a/pkgsets/haskell.nix +++ b/pkgsets/haskell.nix @@ -1,7 +1,11 @@ -{ config, lib, fn, pkgs, ... }: - { - config.machine.pkgsets.haskell.pkgwrap = (pkgs.haskellPackages.ghcWithPackages (pkgs: (fn.pkgFilter config.machine.pkgsets.haskell.pkgs))); + config, + lib, + fn, + pkgs, + ... +}: { + config.machine.pkgsets.haskell.pkgwrap = pkgs.haskellPackages.ghcWithPackages (pkgs: (fn.pkgFilter config.machine.pkgsets.haskell.pkgs)); config.machine.pkgsets.haskell.pkgs = with pkgs.haskellPackages; [ hindent mtl diff --git a/pkgsets/latex.nix b/pkgsets/latex.nix index 1eab06a..6dd47eb 100644 --- a/pkgsets/latex.nix +++ b/pkgsets/latex.nix @@ -1,8 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; - { + config, + lib, + pkgs, + ... +}: +with lib; { config.machine.pkgsets.latex.pkgs = with pkgs; [ texlive.combined.scheme-full texlab diff --git a/pkgsets/mail_utils.nix b/pkgsets/mail_utils.nix index e7b1dfb..ee68f10 100644 --- a/pkgsets/mail_utils.nix +++ b/pkgsets/mail_utils.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.mail_utils.pkgs = with pkgs; [ fetchmail isync diff --git a/pkgsets/nodejs.nix b/pkgsets/nodejs.nix index 91b4704..b3d15c0 100644 --- a/pkgsets/nodejs.nix +++ b/pkgsets/nodejs.nix @@ -1,25 +1,28 @@ -{ config, pkgs, ... }: - { - config.machine.pkgsets.nodejs.pkgs = (with pkgs; [ nodejs yarn deno esbuild ]) ++ - (with pkgs.nodePackages; [ - autoprefixer - browserify - create-react-app - degit - mermaid-cli - parcel-bundler - prettier - prisma - rollup - serve - svelte-check - svelte-language-server - tailwindcss - ts-node - typescript - typescript-language-server - webpack - webpack-cli - ]); + config, + pkgs, + ... +}: { + config.machine.pkgsets.nodejs.pkgs = + (with pkgs; [nodejs yarn deno esbuild]) + ++ (with pkgs.nodePackages; [ + autoprefixer + browserify + create-react-app + degit + mermaid-cli + parcel-bundler + prettier + prisma + rollup + serve + svelte-check + svelte-language-server + tailwindcss + ts-node + typescript + typescript-language-server + webpack + webpack-cli + ]); } diff --git a/pkgsets/php.nix b/pkgsets/php.nix index e04e462..a6a88f0 100644 --- a/pkgsets/php.nix +++ b/pkgsets/php.nix @@ -1,8 +1,14 @@ -{ config, lib, fn, pkgs, ... }: - { - config.machine.pkgsets.php.pkgwrap = (fn.pkgFilter config.machine.pkgsets.php.pkgs); - config.machine.pkgsets.php.pkgs = (with pkgs.php82Packages; [ - composer - ]) ++ (with pkgs; [ php82 ]); + config, + lib, + fn, + pkgs, + ... +}: { + config.machine.pkgsets.php.pkgwrap = fn.pkgFilter config.machine.pkgsets.php.pkgs; + config.machine.pkgsets.php.pkgs = + (with pkgs.php82Packages; [ + composer + ]) + ++ (with pkgs; [php82]); } diff --git a/pkgsets/python3.nix b/pkgsets/python3.nix index 8fb3776..8c9e5ae 100644 --- a/pkgsets/python3.nix +++ b/pkgsets/python3.nix @@ -1,9 +1,12 @@ -{ config, lib, fn, pkgs, ... }: - -with lib; - { - config.machine.pkgsets.python3.pkgwrap = (pkgs.python310.withPackages (ps: (fn.pkgFilter config.machine.pkgsets.python3.pkgs))); + config, + lib, + fn, + pkgs, + ... +}: +with lib; { + config.machine.pkgsets.python3.pkgwrap = pkgs.python310.withPackages (ps: (fn.pkgFilter config.machine.pkgsets.python3.pkgs)); config.machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [ GitPython bpython @@ -13,7 +16,8 @@ with lib; epc flake8 genanki - matplotlib ipywidgets + matplotlib + ipywidgets python-docx mypy numpy @@ -29,7 +33,8 @@ with lib; pypdf2 # pygame pygame_sdl2 pylama - pylint toml + pylint + toml pyopengl pyproj pytest diff --git a/pkgsets/rustpkgs.nix b/pkgsets/rustpkgs.nix index 85db920..28de6df 100644 --- a/pkgsets/rustpkgs.nix +++ b/pkgsets/rustpkgs.nix @@ -1,14 +1,15 @@ -{ config, ... }: - -let - mozRust = with builtins; (map (p: import ((fetchTarball { - url = "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed4.tar.gz"; - sha256 = "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3"; - }) + p))) [ - (toPath "/lib-overlay.nix") - (toPath "/rust-overlay.nix") - ]; - stablepkgs = import { overlays = mozRust;}; +{config, ...}: let + mozRust = with builtins; + (map (p: + import ((fetchTarball { + url = "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed4.tar.gz"; + sha256 = "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3"; + }) + + p))) [ + (toPath "/lib-overlay.nix") + (toPath "/rust-overlay.nix") + ]; + stablepkgs = import {overlays = mozRust;}; # https://rust-lang.github.io/rustup-components-history nightly = stablepkgs.rustChannelOf { @@ -16,24 +17,28 @@ let channel = "nightly"; }; rustNightly = { - rustc = nightly.rust.override { - extensions = [ - "clippy-preview" - "rls-preview" - "rust-analysis" - "rust-src" - "rustfmt-preview" - ]; } // { src = nightly.rust-src; }; + rustc = + nightly.rust.override { + extensions = [ + "clippy-preview" + "rls-preview" + "rust-analysis" + "rust-src" + "rustfmt-preview" + ]; + } + // {src = nightly.rust-src;}; cargo = nightly.cargo; }; - rustPNightly = stablepkgs.recurseIntoAttrs (stablepkgs.makeRustPlatform { + rustPNightly = stablepkgs.recurseIntoAttrs (stablepkgs.makeRustPlatform { inherit (rustNightly) rustc cargo; }); - in { - config.machine.pkgsets.rustpkgs.pkgs = (with stablepkgs; [ - diesel-cli - carnix - rustracer - ]) ++ (with rustNightly; [ rustc cargo]); + config.machine.pkgsets.rustpkgs.pkgs = + (with stablepkgs; [ + diesel-cli + carnix + rustracer + ]) + ++ (with rustNightly; [rustc cargo]); } diff --git a/pkgsets/server.nix b/pkgsets/server.nix index 0c7c420..694a97b 100644 --- a/pkgsets/server.nix +++ b/pkgsets/server.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { config.machine.pkgsets.server.pkgs = with pkgs; [ audit certbot diff --git a/pkgsets/tracking.nix b/pkgsets/tracking.nix index 31cd928..c525108 100644 --- a/pkgsets/tracking.nix +++ b/pkgsets/tracking.nix @@ -1,8 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; - { + config, + lib, + pkgs, + ... +}: +with lib; { config.machine.pkgsets.tracking.pkgs = with pkgs; [ aw-qt aw-server-rust diff --git a/pkgsets/uniProgs.nix b/pkgsets/uniProgs.nix index b47d92c..455f786 100644 --- a/pkgsets/uniProgs.nix +++ b/pkgsets/uniProgs.nix @@ -1,5 +1,7 @@ -{ config, pkgs, ... }: - { - config.machine.pkgsets.uniProgs.pkgs = with pkgs; [ qucs ]; + config, + pkgs, + ... +}: { + config.machine.pkgsets.uniProgs.pkgs = with pkgs; [qucs]; } diff --git a/pkgsets/xpkgs.nix b/pkgsets/xpkgs.nix index 2e4f07b..b8b8b22 100644 --- a/pkgsets/xpkgs.nix +++ b/pkgsets/xpkgs.nix @@ -1,7 +1,9 @@ -{ config, pkgs, ... }: - -let - cfg = config.machine; +{ + config, + pkgs, + ... +}: let + cfg = config.machine; in { config.machine.pkgsets.xpkgs.pkgs = with pkgs; [ acpilight @@ -13,7 +15,9 @@ in { gnome3.gvfs gvfs oneko - pcmanfm lxmenu-data shared-mime-info + pcmanfm + lxmenu-data + shared-mime-info pavucontrol xclip xorg.xkill diff --git a/services/acme.nix b/services/acme.nix index 34d53a7..25eb2f3 100644 --- a/services/acme.nix +++ b/services/acme.nix @@ -1,14 +1,19 @@ -{ options, config, lib, fn, pkgs, ... }: - +{ + options, + config, + lib, + fn, + pkgs, + ... +}: with builtins; -with lib; - -let +with lib; let cfg = config.machine; -in mkIf (elem "acme" cfg.services) { - security.acme = { - # see https://letsencrypt.org/repository/ - acceptTerms = true; - defaults.email = "${(elemAt cfg.mailAccounts 0).name}@${cfg.domain}"; - }; -} +in + mkIf (elem "acme" cfg.services) { + security.acme = { + # see https://letsencrypt.org/repository/ + acceptTerms = true; + defaults.email = "${(elemAt cfg.mailAccounts 0).name}@${cfg.domain}"; + }; + } diff --git a/services/bind.nix b/services/bind.nix index 2408620..1ac87b1 100644 --- a/services/bind.nix +++ b/services/bind.nix @@ -1,28 +1,36 @@ # This Configuration is meant for local DNS setups only! -{ options, config, lib, fn, pkgs, ... }: - +{ + options, + config, + lib, + fn, + pkgs, + ... +}: with builtins; -with lib; - -let +with lib; let cfg = config.machine; -in mkIf (elem "bind" cfg.services) { - services.bind = { - enable = true; - listenOn = [ "127.0.0.1" ]; - forwarders = [ - # Cloudflare CDN - "1.1.1.1" "1.0.0.1" - #CCC DNS - "204.152.184.76" "159.203.38.175" "207.148.83.241" - ]; - # TODO: add DNSSEC - extraOptions = '' - dnssec-validation auto; +in + mkIf (elem "bind" cfg.services) { + services.bind = { + enable = true; + listenOn = ["127.0.0.1"]; + forwarders = [ + # Cloudflare CDN + "1.1.1.1" + "1.0.0.1" + #CCC DNS + "204.152.184.76" + "159.203.38.175" + "207.148.83.241" + ]; + # TODO: add DNSSEC + extraOptions = '' + dnssec-validation auto; - recursion yes; - allow-recursion { 127.0.0.1; }; - version none; - ''; - }; -} + recursion yes; + allow-recursion { 127.0.0.1; }; + version none; + ''; + }; + } diff --git a/services/containers.nix b/services/containers.nix index 1a108ec..dac6070 100644 --- a/services/containers.nix +++ b/services/containers.nix @@ -1,14 +1,15 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "containers" config.machine.services) { - containers.CDServer = { - privateNetwork = true; - hostAddress = "192.168.100.10"; - localAddress = "192.168.100.11"; - config = - { + mkIf (elem "containers" config.machine.services) { + containers.CDServer = { + privateNetwork = true; + hostAddress = "192.168.100.10"; + localAddress = "192.168.100.11"; + config = { imports = [ ../machines/CDServer/options.nix ./default.nix @@ -16,8 +17,8 @@ mkIf (elem "containers" config.machine.services) { ../pkgs/nixpkgs.nix ../pkgs/pkgsets.nix ]; - services.nixosManual.showManual = false; - services.ntp.enable = false; + services.nixosManual.showManual = false; + services.ntp.enable = false; }; - }; -} + }; + } diff --git a/services/cups.nix b/services/cups.nix index 0f27f66..297e672 100644 --- a/services/cups.nix +++ b/services/cups.nix @@ -1,11 +1,14 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "cups" config.machine.services) { - services.printing = { - enable = true; - startWhenNeeded = true; - drivers = with pkgs; [ gutenprint hplip splix samsung-unified-linux-driver ]; - }; -} + mkIf (elem "cups" config.machine.services) { + services.printing = { + enable = true; + startWhenNeeded = true; + drivers = with pkgs; [gutenprint hplip splix samsung-unified-linux-driver]; + }; + } diff --git a/services/desktop.nix b/services/desktop.nix index 0744f84..59a4188 100644 --- a/services/desktop.nix +++ b/services/desktop.nix @@ -1,28 +1,36 @@ -{ config, lib, fn, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + fn, + pkgs, + ... +}: +with lib; let cfg = config.machine; - desktopFiles = fn.lst { p = (toString ./desktop); b = true; }; -in { - imports = desktopFiles; -} // mkIf (elem "desktop" cfg.services) { - services.gvfs.enable = true; - services.xserver = { - layout = "de"; - libinput = { - enable = true; - touchpad = { - tapping = true; - disableWhileTyping = false; - naturalScrolling = false; - horizontalScrolling = true; + desktopFiles = fn.lst { + p = toString ./desktop; + b = true; + }; +in + { + imports = desktopFiles; + } + // mkIf (elem "desktop" cfg.services) { + services.gvfs.enable = true; + services.xserver = { + layout = "de"; + libinput = { + enable = true; + touchpad = { + tapping = true; + disableWhileTyping = false; + naturalScrolling = false; + horizontalScrolling = true; + }; }; }; - }; - services.udev.extraRules = '' - ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness" - ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chmod 664 /sys/class/backlight/%k/brightness" - ''; -} + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness" + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chmod 664 /sys/class/backlight/%k/brightness" + ''; + } diff --git a/services/desktop/i3.nix b/services/desktop/i3.nix index d311053..0f7cd0a 100644 --- a/services/desktop/i3.nix +++ b/services/desktop/i3.nix @@ -1,21 +1,24 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "desktop::i3" config.machine.services) { - services.xserver = { - enable = true; - windowManager.i3 = { + mkIf (elem "desktop::i3" config.machine.services) { + services.xserver = { enable = true; - configFile = (import ../../config/etc/i3/config.nix { inherit pkgs; }); - extraPackages = with pkgs; [ - dmenu - file - i3lock - i3status - xdg-user-dirs - ]; + windowManager.i3 = { + enable = true; + configFile = import ../../config/etc/i3/config.nix {inherit pkgs;}; + extraPackages = with pkgs; [ + dmenu + file + i3lock + i3status + xdg-user-dirs + ]; + }; }; - }; - machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [ py3status pytz tzlocal ]; -} + machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [py3status pytz tzlocal]; + } diff --git a/services/desktop/sway.nix b/services/desktop/sway.nix index f950925..c349d26 100644 --- a/services/desktop/sway.nix +++ b/services/desktop/sway.nix @@ -1,33 +1,39 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "desktop::sway" config.machine.services) { - programs.sway = { - enable = true; - extraPackages = with pkgs; [ - xwayland - file i3status dmenu - qt5.qtwayland - grim slurp - swaylock - swayidle - light - mako - wl-clipboard - wf-recorder - ]; - extraSessionCommands = '' - export GDK_BACKEND=wayland - export CLUTTER_BACKEND=wayland - export SDL_VIDEODRIVER=wayland - # needs qt5.qtwayland in systemPackages - export QT_QPA_PLATFORM=wayland-egl - export QT_WAYLAND_FORCE_DPI=physical - export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" - # Fix for some Java AWT applications (e.g. Android Studio), - # use this if they aren't displayed properly: - export _JAVA_AWT_WM_NONREPARENTING=1 - ''; - }; -} + mkIf (elem "desktop::sway" config.machine.services) { + programs.sway = { + enable = true; + extraPackages = with pkgs; [ + xwayland + file + i3status + dmenu + qt5.qtwayland + grim + slurp + swaylock + swayidle + light + mako + wl-clipboard + wf-recorder + ]; + extraSessionCommands = '' + export GDK_BACKEND=wayland + export CLUTTER_BACKEND=wayland + export SDL_VIDEODRIVER=wayland + # needs qt5.qtwayland in systemPackages + export QT_QPA_PLATFORM=wayland-egl + export QT_WAYLAND_FORCE_DPI=physical + export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" + # Fix for some Java AWT applications (e.g. Android Studio), + # use this if they aren't displayed properly: + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + }; + } diff --git a/services/docker.nix b/services/docker.nix index ae7d385..f19daa5 100644 --- a/services/docker.nix +++ b/services/docker.nix @@ -1,13 +1,16 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: # Note: add privileged users to docker group for access with lib; - -mkIf ((elem "docker" config.machine.services) && !(elem "podman" config.machine.services)) { - virtualisation.docker= { - enable = true; - # Disable live restore as it tends to delay/block system shutdown - liveRestore = false; - }; - environment.systemPackages = with pkgs; [ docker-compose docker-machine cntr ]; -} + mkIf ((elem "docker" config.machine.services) && !(elem "podman" config.machine.services)) { + virtualisation.docker = { + enable = true; + # Disable live restore as it tends to delay/block system shutdown + liveRestore = false; + }; + environment.systemPackages = with pkgs; [docker-compose docker-machine cntr]; + } diff --git a/services/fail2ban.nix b/services/fail2ban.nix index 7522985..ed6fda6 100644 --- a/services/fail2ban.nix +++ b/services/fail2ban.nix @@ -1,102 +1,104 @@ -{ config, lib, ... }: - -with lib; - -let +{ + config, + lib, + ... +}: +with lib; let cfg = config.machine; active = name: (elem name cfg.services); -in mkIf (elem "fail2ban" cfg.services) { - services.fail2ban = { - enable = true; - jails = { - DEFAULT = '' - bantime = 3600 - blocktype = DROP - logpath = /var/log/auth.log - ''; +in + mkIf (elem "fail2ban" cfg.services) { + services.fail2ban = { + enable = true; + jails = { + DEFAULT = '' + bantime = 3600 + blocktype = DROP + logpath = /var/log/auth.log + ''; - ssh = '' - enabled = ${boolToString (active "openssh")} - filter = sshd - maxretry = 4 - action = iptables[name=SSH, port=ssh, protocol=tcp] - ''; - sshd-ddos = '' - enabled = ${boolToString (active "openssh")} - filter = sshd-ddos - maxretry = 4 - action = iptables[name=ssh, port=ssh, protocol=tcp] - ''; + ssh = '' + enabled = ${boolToString (active "openssh")} + filter = sshd + maxretry = 4 + action = iptables[name=SSH, port=ssh, protocol=tcp] + ''; + sshd-ddos = '' + enabled = ${boolToString (active "openssh")} + filter = sshd-ddos + maxretry = 4 + action = iptables[name=ssh, port=ssh, protocol=tcp] + ''; - postfix = '' - enabled = ${boolToString (active "mailserver")} - filter = postfix - maxretry = 3 - action = iptables[name=postfix, port=smtp, protocol=tcp] - ''; - postfix-sasl = '' - enabled = ${boolToString (active "mailserver")} - filter = postfix-sasl - port = postfix,imap3,imaps,pop3,pop3s - maxretry = 3 - action = iptables[name=postfix, port=smtp, protocol=tcp] - ''; - postfix-ddos = '' - enabled = ${boolToString (active "mailserver")} - filter = postfix-ddos - maxretry = 3 - action = iptables[name=postfix, port=submission, protocol=tcp] - bantime = 7200 - ''; + postfix = '' + enabled = ${boolToString (active "mailserver")} + filter = postfix + maxretry = 3 + action = iptables[name=postfix, port=smtp, protocol=tcp] + ''; + postfix-sasl = '' + enabled = ${boolToString (active "mailserver")} + filter = postfix-sasl + port = postfix,imap3,imaps,pop3,pop3s + maxretry = 3 + action = iptables[name=postfix, port=smtp, protocol=tcp] + ''; + postfix-ddos = '' + enabled = ${boolToString (active "mailserver")} + filter = postfix-ddos + maxretry = 3 + action = iptables[name=postfix, port=submission, protocol=tcp] + bantime = 7200 + ''; - nginx-req-limit = '' - enabled = ${boolToString (active "nginx")} - filter = nginx-req-limit - maxretry = 10 - action = iptables-multiport[name=ReqLimit, port="http,https", protocol=tcp] - findtime = 600 - bantime = 7200 + nginx-req-limit = '' + enabled = ${boolToString (active "nginx")} + filter = nginx-req-limit + maxretry = 10 + action = iptables-multiport[name=ReqLimit, port="http,https", protocol=tcp] + findtime = 600 + bantime = 7200 + ''; + }; + }; + + environment.etc."fail2ban/filter.d/sshd-ddos.conf" = { + enable = active "openssh"; + text = '' + [Definition] + failregex = sshd(?:\[\d+\])?: Did not receive identification string from $ + ignoreregex = ''; }; - }; - environment.etc."fail2ban/filter.d/sshd-ddos.conf" = { - enable = (active "openssh"); - text = '' - [Definition] - failregex = sshd(?:\[\d+\])?: Did not receive identification string from $ - ignoreregex = - ''; - }; + environment.etc."fail2ban/filter.d/postfix-sasl.conf" = { + enable = active "mailserver"; + text = '' + # Fail2Ban filter for postfix authentication failures + [INCLUDES] + before = common.conf + [Definition] + daemon = postfix/smtpd + failregex = ^%(__prefix_line)swarning: [-._\w]+\[\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$ + ''; + }; - environment.etc."fail2ban/filter.d/postfix-sasl.conf" = { - enable = (active "mailserver"); - text = '' - # Fail2Ban filter for postfix authentication failures - [INCLUDES] - before = common.conf - [Definition] - daemon = postfix/smtpd - failregex = ^%(__prefix_line)swarning: [-._\w]+\[\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$ - ''; - }; + environment.etc."fail2ban/filter.d/postfix-ddos.conf" = { + enable = active "mailserver"; + text = '' + [Definition] + failregex = lost connection after EHLO from \S+\[\] + ''; + }; - environment.etc."fail2ban/filter.d/postfix-ddos.conf" = { - enable = (active "mailserver"); - text = '' - [Definition] - failregex = lost connection after EHLO from \S+\[\] - ''; - }; + environment.etc."fail2ban/filter.d/nginx-req-limit.conf" = { + enable = active "nginx"; + text = '' + [Definition] + failregex = limiting requests, excess:.* by zone.*client: + ''; + }; - environment.etc."fail2ban/filter.d/nginx-req-limit.conf" = { - enable = (active "nginx"); - text = '' - [Definition] - failregex = limiting requests, excess:.* by zone.*client: - ''; - }; - - # Limit stack size to reduce memory usage - systemd.services.fail2ban.serviceConfig.LimitSTACK = 256 * 1024; -} + # Limit stack size to reduce memory usage + systemd.services.fail2ban.serviceConfig.LimitSTACK = 256 * 1024; + } diff --git a/services/fprintd.nix b/services/fprintd.nix index c0d59c6..50cf201 100644 --- a/services/fprintd.nix +++ b/services/fprintd.nix @@ -1,18 +1,24 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; + mkIf (elem "fprintd" config.machine.services) { + security.pam.services = let + unlock = [ + "sudo" + "i3lock" + "login" + "lightdm" + ]; + in + listToAttrs (forEach unlock (n: { + name = n; + value = {fprintAuth = true;}; + })); -mkIf (elem "fprintd" config.machine.services) { - security.pam.services = let - unlock = [ - "sudo" - "i3lock" - "login" - "lightdm" - ]; - in listToAttrs (forEach unlock (n: {name = n; value = { fprintAuth = true; }; })); - - services.fprintd = { - enable = true; - }; -} + services.fprintd = { + enable = true; + }; + } diff --git a/services/gitea.nix b/services/gitea.nix index d19e041..4f4da32 100644 --- a/services/gitea.nix +++ b/services/gitea.nix @@ -1,54 +1,56 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "gitea" config.machine.services) { - services = { - gitea = let - cfg = config.machine; - domain = (findFirst (s: s.service == "gitea") cfg cfg.vHosts).domain; - in { - enable = true; - user = "git"; - database = { - type = "mysql"; + mkIf (elem "gitea" config.machine.services) { + services = { + gitea = let + cfg = config.machine; + domain = (findFirst (s: s.service == "gitea") cfg cfg.vHosts).domain; + in { + enable = true; user = "git"; - name = "gitea"; - passwordFile = config.sops.secrets."services/gitea/dbPass".path; - }; - settings = { - repository = { - DISABLE_HTTP_GIT = false; - USE_COMPAT_SSH_URI = true; + database = { + type = "mysql"; + user = "git"; + name = "gitea"; + passwordFile = config.sops.secrets."services/gitea/dbPass".path; }; + settings = { + repository = { + DISABLE_HTTP_GIT = false; + USE_COMPAT_SSH_URI = true; + }; - security = { - INSTALL_LOCK = true; - COOKIE_USERNAME = "gitea_username"; - COOKIE_REMEMBER_NAME = "gitea_userauth"; - }; + security = { + INSTALL_LOCK = true; + COOKIE_USERNAME = "gitea_username"; + COOKIE_REMEMBER_NAME = "gitea_userauth"; + }; - server = { - DOMAIN = domain; - ROOT_URL = "https://${domain}/"; - }; + server = { + DOMAIN = domain; + ROOT_URL = "https://${domain}/"; + }; - service = { - DISABLE_REGISTRATION = (lib.mkForce true); - }; + service = { + DISABLE_REGISTRATION = lib.mkForce true; + }; - session = { - cookieSecure = true; + session = { + cookieSecure = true; + }; }; }; }; - }; - sops.secrets."services/gitea/dbPass" = {}; - users.users.git = { - description = "Gitea Service"; - isNormalUser = true; - home = config.services.gitea.stateDir; - createHome = true; - useDefaultShell = true; - }; -} + sops.secrets."services/gitea/dbPass" = {}; + users.users.git = { + description = "Gitea Service"; + isNormalUser = true; + home = config.services.gitea.stateDir; + createHome = true; + useDefaultShell = true; + }; + } diff --git a/services/hydra.nix b/services/hydra.nix index 4a5fe09..a55d192 100644 --- a/services/hydra.nix +++ b/services/hydra.nix @@ -1,71 +1,71 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: # hydra user needs to be manually crated # sudo -u hydra -s # hydra-create-user $USERNAME --password $PASSWORD --role admin - # https://qfpl.io/posts/nix/starting-simple-hydra/ # also for reference a well written hydra config: # https://github.com/NixOS/nixos-org-configurations/blob/master/delft/hydra.nix - -with lib; - -let +with lib; let cacheDir = "/var/cache/hydra"; -in mkIf (elem "hydra" config.machine.services) { - # also take a look at ../conf/nix.nix - nix.buildMachines = [ - { - hostName = "localhost"; - system = "x86_64-linux"; - supportedFeatures = ["kvm" "nixos-test" "big-parallel" "benchmark"]; - maxJobs = 8; - } - ]; +in + mkIf (elem "hydra" config.machine.services) { + # also take a look at ../conf/nix.nix + nix.buildMachines = [ + { + hostName = "localhost"; + system = "x86_64-linux"; + supportedFeatures = ["kvm" "nixos-test" "big-parallel" "benchmark"]; + maxJobs = 8; + } + ]; - services = let - cfg = config.machine; - domain = (findFirst (s: s.service == "hydra") cfg cfg.vHosts).domain; - in { - hydra = { - enable = true; - hydraURL = domain; # externally visible URL - listenHost = "localhost"; - port = 3001; - minimumDiskFree = 15; - minimumDiskFreeEvaluator = 15; - notificationSender = "hydra@mail.${cfg.domain}"; # e-mail of hydra service - useSubstitutes = true; - debugServer = false; - # Hints from hydra-queue-runner: - # binary_cache_dir is deprecated and ignored. use store_uri=file:// instead - # hydra.conf: binary_cache_secret_key_file is deprecated and ignored. use store_uri=...?secret-key= instead - extraConfig = '' - max_output_size = 4294967296 - store_uri = file://${cacheDir}?secret-key=${config.sops.secrets."services.hydra.secretKey".path}&write-nar-listing=1&ls-compression=br&log-compression=br - # add ?local-nar-cache= to set nar cache location - server_store_uri = https://cache.${cfg.domain} - binary_cache_public_uri https://cache.${cfg.domain} - upload_logs_to_binary_cache = true - ''; - }; + services = let + cfg = config.machine; + domain = (findFirst (s: s.service == "hydra") cfg cfg.vHosts).domain; + in { + hydra = { + enable = true; + hydraURL = domain; # externally visible URL + listenHost = "localhost"; + port = 3001; + minimumDiskFree = 15; + minimumDiskFreeEvaluator = 15; + notificationSender = "hydra@mail.${cfg.domain}"; # e-mail of hydra service + useSubstitutes = true; + debugServer = false; + # Hints from hydra-queue-runner: + # binary_cache_dir is deprecated and ignored. use store_uri=file:// instead + # hydra.conf: binary_cache_secret_key_file is deprecated and ignored. use store_uri=...?secret-key= instead + extraConfig = '' + max_output_size = 4294967296 + store_uri = file://${cacheDir}?secret-key=${config.sops.secrets."services.hydra.secretKey".path}&write-nar-listing=1&ls-compression=br&log-compression=br + # add ?local-nar-cache= to set nar cache location + server_store_uri = https://cache.${cfg.domain} + binary_cache_public_uri https://cache.${cfg.domain} + upload_logs_to_binary_cache = true + ''; + }; - nix-serve = { - enable = true; - bindAddress = "0.0.0.0"; - port = 5000; - secretKeyFile = config.sops.secrets."services.hydra.secretKey".path; - extraParams = '' - # Dont know how to change the store root yet... - # --user hydra-queue-runner - # --group hydra - ''; + nix-serve = { + enable = true; + bindAddress = "0.0.0.0"; + port = 5000; + secretKeyFile = config.sops.secrets."services.hydra.secretKey".path; + extraParams = '' + # Dont know how to change the store root yet... + # --user hydra-queue-runner + # --group hydra + ''; + }; }; - }; - systemd.services.nix-serve.serviceConfig.User = mkForce "hydra"; - systemd.services.nix-serve.environment.NIX_STORE_DIR = cacheDir; - sops.secrets."services/hydra/secretKey" = { - owner = "hydra"; - group = "hydra"; - }; -} + systemd.services.nix-serve.serviceConfig.User = mkForce "hydra"; + systemd.services.nix-serve.environment.NIX_STORE_DIR = cacheDir; + sops.secrets."services/hydra/secretKey" = { + owner = "hydra"; + group = "hydra"; + }; + } diff --git a/services/mailserver.nix b/services/mailserver.nix index 91be653..89d3e7c 100644 --- a/services/mailserver.nix +++ b/services/mailserver.nix @@ -1,56 +1,63 @@ -{ config, lib, fn, mailserver, ... }: - -with lib; - { - imports = [ - mailserver.nixosModules.mailserver - ]; -} // mkIf (elem "mailserver" config.machine.services) { - mailserver = let - cfg = config.machine; - domain = cfg.domain; - fdomain = (findFirst (s: s.service == "mail") cfg cfg.vHosts).domain; - mkFqdnAlias = name: [ "${name}@${domain}" "${name}@${fdomain}" ]; - mkExDomAlias = name: (map (exDom: "${name}@${exDom}") cfg.extraDomains); - mkUser = user: rec { - name = "${user.name}@${domain}"; - value = { - hashedPasswordFile = config.sops.secrets."users/${user.name}/mail".path; - aliases = [ "${user.name}@${fdomain}" ] - ++ (flatten (map mkFqdnAlias user.aliases)) - ++ (flatten (map mkExDomAlias ([ user.name ] ++ user.aliases))); + config, + lib, + fn, + mailserver, + ... +}: +with lib; + { + imports = [ + mailserver.nixosModules.mailserver + ]; + } + // mkIf (elem "mailserver" config.machine.services) { + mailserver = let + cfg = config.machine; + domain = cfg.domain; + fdomain = (findFirst (s: s.service == "mail") cfg cfg.vHosts).domain; + mkFqdnAlias = name: ["${name}@${domain}" "${name}@${fdomain}"]; + mkExDomAlias = name: (map (exDom: "${name}@${exDom}") cfg.extraDomains); + mkUser = user: rec { + name = "${user.name}@${domain}"; + value = { + hashedPasswordFile = config.sops.secrets."users/${user.name}/mail".path; + aliases = + ["${user.name}@${fdomain}"] + ++ (flatten (map mkFqdnAlias user.aliases)) + ++ (flatten (map mkExDomAlias ([user.name] ++ user.aliases))); + }; }; + in rec { + enable = true; + fqdn = fdomain; + domains = [fdomain domain] ++ cfg.extraDomains; + loginAccounts = listToAttrs (map mkUser cfg.mailAccounts); + + # Use Let's Encrypt certificates. Note that this needs to set up a stripped + # down nginx and opens port 80. + certificateScheme = "manual"; + certificateFile = "/var/lib/acme/" + fdomain + "/fullchain.pem"; + keyFile = "/var/lib/acme/" + fdomain + "/key.pem"; + + #dhParamBitLength = 4096; # this doesn't exist??? + + # Enable IMAP and POP3 + enableImap = true; + enablePop3 = false; + enableImapSsl = true; + enablePop3Ssl = false; + + # Enable the ManageSieve protocol + enableManageSieve = true; + + # whether to scan inbound emails for viruses (note that this requires at least + # 1 Gb RAM for the server. Without virus scanning 256 MB RAM should be plenty) + virusScanning = false; }; - in rec { - enable = true; - fqdn = fdomain; - domains = ([ fdomain domain ] ++ cfg.extraDomains); - loginAccounts = listToAttrs (map mkUser cfg.mailAccounts); - - # Use Let's Encrypt certificates. Note that this needs to set up a stripped - # down nginx and opens port 80. - certificateScheme = "manual"; - certificateFile = "/var/lib/acme/" + fdomain + "/fullchain.pem"; - keyFile = "/var/lib/acme/" + fdomain + "/key.pem"; - - #dhParamBitLength = 4096; # this doesn't exist??? - - # Enable IMAP and POP3 - enableImap = true; - enablePop3 = false; - enableImapSsl = true; - enablePop3Ssl = false; - - # Enable the ManageSieve protocol - enableManageSieve = true; - - # whether to scan inbound emails for viruses (note that this requires at least - # 1 Gb RAM for the server. Without virus scanning 256 MB RAM should be plenty) - virusScanning = false; - }; - sops.secrets = (fn.sopsHelper - (user: "users/${user.name}/mail") - config.machine.mailAccounts - {}); -} + sops.secrets = + fn.sopsHelper + (user: "users/${user.name}/mail") + config.machine.mailAccounts + {}; + } diff --git a/services/mariaDB.nix b/services/mariaDB.nix index a1d90aa..362ba1c 100644 --- a/services/mariaDB.nix +++ b/services/mariaDB.nix @@ -1,10 +1,13 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "mariaDB" config.machine.services) { - services.mysql = rec { - enable = true; - package = pkgs.mariadb; - }; -} + mkIf (elem "mariaDB" config.machine.services) { + services.mysql = rec { + enable = true; + package = pkgs.mariadb; + }; + } diff --git a/services/mullvad.nix b/services/mullvad.nix index 3fd2df4..5099737 100644 --- a/services/mullvad.nix +++ b/services/mullvad.nix @@ -1,7 +1,9 @@ -{ config, lib, ... }: - +{ + config, + lib, + ... +}: with lib; - -mkIf (elem "mullvad" config.machine.services) { - services.mullvad-vpn.enable = true; -} + mkIf (elem "mullvad" config.machine.services) { + services.mullvad-vpn.enable = true; + } diff --git a/services/nextcloud.nix b/services/nextcloud.nix index 8c08cd0..38aa47b 100644 --- a/services/nextcloud.nix +++ b/services/nextcloud.nix @@ -1,57 +1,65 @@ -{ config, lib, pkgs, fn, ... }: - +{ + config, + lib, + pkgs, + fn, + ... +}: with lib; - -mkIf (elem "nextcloud" config.machine.services) { - services = let - cfg = config.machine; - domain = (findFirst (s: s.service == "nextcloud") cfg cfg.vHosts).domain; - in { - nextcloud = { - enable = true; - enableBrokenCiphersForSSE = false; - home = "/var/lib/nextcloud"; - hostName = domain; - https = true; - maxUploadSize = "1024M"; - package = pkgs.nextcloud27; - config = { - adminuser = mkDefault (elemAt cfg.administrators 0).name; - adminpassFile = config.sops.secrets."services/nextcloud/adminPass".path; - dbtype = "mysql"; - dbhost = "localhost"; - dbport = "3306"; - dbuser = "nextcloud"; - dbpassFile = config.sops.secrets."services/nextcloud/dbPass".path; - dbname = "nextcloud"; - dbtableprefix = "oc_"; - extraTrustedDomains = cfg.extraDomains; + mkIf (elem "nextcloud" config.machine.services) { + services = let + cfg = config.machine; + domain = (findFirst (s: s.service == "nextcloud") cfg cfg.vHosts).domain; + in { + nextcloud = { + enable = true; + enableBrokenCiphersForSSE = false; + home = "/var/lib/nextcloud"; + hostName = domain; + https = true; + maxUploadSize = "1024M"; + package = pkgs.nextcloud27; + config = { + adminuser = mkDefault (elemAt cfg.administrators 0).name; + adminpassFile = config.sops.secrets."services/nextcloud/adminPass".path; + dbtype = "mysql"; + dbhost = "localhost"; + dbport = "3306"; + dbuser = "nextcloud"; + dbpassFile = config.sops.secrets."services/nextcloud/dbPass".path; + dbname = "nextcloud"; + dbtableprefix = "oc_"; + extraTrustedDomains = cfg.extraDomains; + }; + caching = { + apcu = true; + memcached = true; + redis = false; + }; }; - caching = { - apcu = true; - memcached = true; - redis = false; + # Turn Server used for nextcloud-talk + # This stuff is still untested. + coturn = mkIf (elem "nextcloud-talk" config.machine.services) { + # TLS is not needed as WebRTC is already encrypted. + enable = true; + realm = domain; + listening-port = 3478; + use-auth-secret = true; + extraConfig = '' + fingerprint + total-quota=100 + bps-capacity=0 + stale-nonce + no-multicast-peers + ''; }; }; - # Turn Server used for nextcloud-talk - # This stuff is still untested. - coturn = mkIf (elem "nextcloud-talk" config.machine.services) { - # TLS is not needed as WebRTC is already encrypted. - enable = true; - realm = domain; - listening-port = 3478; - use-auth-secret = true; - extraConfig = '' - fingerprint - total-quota=100 - bps-capacity=0 - stale-nonce - no-multicast-peers - ''; - }; - }; - sops.secrets = (fn.sopsHelper - (name: "services/nextcloud/${name}") - [ "adminPass" "dbPass" ] - { owner = "nextcloud"; group = "nextcloud"; }); -} + sops.secrets = + fn.sopsHelper + (name: "services/nextcloud/${name}") + ["adminPass" "dbPass"] + { + owner = "nextcloud"; + group = "nextcloud"; + }; + } diff --git a/services/nginx.nix b/services/nginx.nix index 79e8767..e781287 100644 --- a/services/nginx.nix +++ b/services/nginx.nix @@ -6,48 +6,54 @@ # - Nextcloud # # - Mail ssl root # ############################################################################################## - -{ options, config, lib, pkgs, ... }: - +{ + options, + config, + lib, + pkgs, + ... +}: with lib; with builtins; + mkIf (elem "nginx" config.machine.services) { + services.nginx = let + vHostConfigs = listToAttrs (map + (name: { + name = replaceStrings [".nix"] [""] name; + value = import (./. + (toPath "/nginx_vHosts/${name}")) {inherit options config lib pkgs;}; + }) + (attrNames (readDir ./nginx_vHosts))); -mkIf (elem "nginx" config.machine.services) { - services.nginx = let - vHostConfigs = listToAttrs (map - (name: { - name = (replaceStrings [ ".nix" ] [ "" ] name); - value = (import (./. + (toPath "/nginx_vHosts/${name}")) { inherit options config lib pkgs; });}) - (attrNames (readDir ./nginx_vHosts))); + mkVHost = vHost: { + name = vHost.domain; + value = + { + enableACME = true; + forceSSL = true; + acmeRoot = "/var/lib/acme/acme-challenge"; + } + // vHostConfigs."${vHost.service}"; + }; - mkVHost = vHost: { - name = vHost.domain; - value = { - enableACME = true; - forceSSL = true; - acmeRoot = "/var/lib/acme/acme-challenge"; - } // vHostConfigs."${vHost.service}"; }; - - vHosts = listToAttrs (map mkVHost config.machine.vHosts); - - in { - enable = true; - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - sslCiphers = "EECDH+aRSA+AESGCM:EDH+aRSA:EECDH+aRSA:+AES256:+AES128:+SHA1:!CAMELLIA:!SEED:!3DES:!DES:!RC4:!eNULL"; - sslProtocols = "TLSv1.3 TLSv1.2"; - commonHttpConfig = '' - map $scheme $hsts_header { - https "max-age=31536000; includeSubdomains; preload"; - } - add_header Strict-Transport-Security $hsts_header; - add_header 'Referrer-Policy' 'origin-when-cross-origin'; - # add_header X-Frame-Options DENY; - add_header X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - ''; - virtualHosts = vHosts; - }; -} + vHosts = listToAttrs (map mkVHost config.machine.vHosts); + in { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + sslCiphers = "EECDH+aRSA+AESGCM:EDH+aRSA:EECDH+aRSA:+AES256:+AES128:+SHA1:!CAMELLIA:!SEED:!3DES:!DES:!RC4:!eNULL"; + sslProtocols = "TLSv1.3 TLSv1.2"; + commonHttpConfig = '' + map $scheme $hsts_header { + https "max-age=31536000; includeSubdomains; preload"; + } + add_header Strict-Transport-Security $hsts_header; + add_header 'Referrer-Policy' 'origin-when-cross-origin'; + # add_header X-Frame-Options DENY; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + ''; + virtualHosts = vHosts; + }; + } diff --git a/services/nginx_vHosts/cache.nix b/services/nginx_vHosts/cache.nix index 265feba..a402a0f 100644 --- a/services/nginx_vHosts/cache.nix +++ b/services/nginx_vHosts/cache.nix @@ -1,17 +1,23 @@ -{ config, lib, ... }: - -with lib; - { - vHost = if config.services.nix-serve.enable then { - extraConfig = '' - location / { - proxy_pass http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}; - proxy_set_header Host $host; - proxy_set_header REMOTE_ADDR $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; + config, + lib, + ... +}: +with lib; + { + vHost = + if config.services.nix-serve.enable + then { + extraConfig = '' + location / { + proxy_pass http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}; + proxy_set_header Host $host; + proxy_set_header REMOTE_ADDR $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + } + ''; } - ''; - } else {}; -}.vHost + else {}; + } + .vHost diff --git a/services/nginx_vHosts/gitea.nix b/services/nginx_vHosts/gitea.nix index 78961da..df67d66 100644 --- a/services/nginx_vHosts/gitea.nix +++ b/services/nginx_vHosts/gitea.nix @@ -1,27 +1,33 @@ -{ config, lib, ... }: - -with lib; - { - vHost = if config.services.gitea.enable then { - root = "${config.services.gitea.stateDir}/public"; - extraConfig = '' - location / { - try_files maintain.html $uri $uri/index.html @node; - } + config, + lib, + ... +}: +with lib; + { + vHost = + if config.services.gitea.enable + then { + root = "${config.services.gitea.stateDir}/public"; + extraConfig = '' + location / { + try_files maintain.html $uri $uri/index.html @node; + } - location @node { - client_max_body_size 0; - proxy_pass http://${config.services.gitea.settings.server.HTTP_ADDR}:${toString config.services.gitea.settings.server.HTTP_PORT}; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-Ssl on; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_max_temp_file_size 0; - proxy_redirect off; - proxy_read_timeout 120; + location @node { + client_max_body_size 0; + proxy_pass http://${config.services.gitea.settings.server.HTTP_ADDR}:${toString config.services.gitea.settings.server.HTTP_PORT}; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Ssl on; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_max_temp_file_size 0; + proxy_redirect off; + proxy_read_timeout 120; + } + ''; } - ''; - } else {}; -}.vHost + else {}; + } + .vHost diff --git a/services/nginx_vHosts/hydra.nix b/services/nginx_vHosts/hydra.nix index 374dd67..4ece547 100644 --- a/services/nginx_vHosts/hydra.nix +++ b/services/nginx_vHosts/hydra.nix @@ -1,17 +1,23 @@ -{ config, lib, ... }: - -with lib; - { - vHost = if config.services.hydra.enable then { - extraConfig = '' - location / { - proxy_pass http://${config.services.hydra.listenHost}:${toString config.services.hydra.port}; - proxy_set_header Host $host; - proxy_set_header REMOTE_ADDR $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; + config, + lib, + ... +}: +with lib; + { + vHost = + if config.services.hydra.enable + then { + extraConfig = '' + location / { + proxy_pass http://${config.services.hydra.listenHost}:${toString config.services.hydra.port}; + proxy_set_header Host $host; + proxy_set_header REMOTE_ADDR $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + } + ''; } - ''; - } else {}; -}.vHost + else {}; + } + .vHost diff --git a/services/nginx_vHosts/mail.nix b/services/nginx_vHosts/mail.nix index b8a7188..d9ddb70 100644 --- a/services/nginx_vHosts/mail.nix +++ b/services/nginx_vHosts/mail.nix @@ -1,11 +1,17 @@ -{ config, lib, ... }: - -with lib; - { - vHost = if config.mailserver.enable then { - serverName = config.mailserver.fqdn; - enableACME = true; - forceSSL = true; - } else {}; -}.vHost + config, + lib, + ... +}: +with lib; + { + vHost = + if config.mailserver.enable + then { + serverName = config.mailserver.fqdn; + enableACME = true; + forceSSL = true; + } + else {}; + } + .vHost diff --git a/services/nginx_vHosts/nextcloud.nix b/services/nginx_vHosts/nextcloud.nix index 0a2c3d1..cfd8971 100644 --- a/services/nginx_vHosts/nextcloud.nix +++ b/services/nginx_vHosts/nextcloud.nix @@ -1,10 +1,18 @@ -{ options, config, lib, pkgs, ... }: - +{ + options, + config, + lib, + pkgs, + ... +}: with lib; - -if (config.services.nextcloud.enable == true) then { - vHost = { - enableACME = config.services.nextcloud.https; - forceSSL = config.services.nextcloud.https; - }; -}.vHost else {} + if (config.services.nextcloud.enable == true) + then + { + vHost = { + enableACME = config.services.nextcloud.https; + forceSSL = config.services.nextcloud.https; + }; + } + .vHost + else {} diff --git a/services/nginx_vHosts/simple.nix b/services/nginx_vHosts/simple.nix index fc4af85..872e39e 100644 --- a/services/nginx_vHosts/simple.nix +++ b/services/nginx_vHosts/simple.nix @@ -1,9 +1,12 @@ -{ config, lib, ... }: - -with lib; - { - vHost = { - root = "/var/www"; - }; -}.vHost + config, + lib, + ... +}: +with lib; + { + vHost = { + root = "/var/www"; + }; + } + .vHost diff --git a/services/openssh.nix b/services/openssh.nix index 5521536..feb3439 100644 --- a/services/openssh.nix +++ b/services/openssh.nix @@ -1,35 +1,43 @@ -{ config, lib, fn, ... }: - +{ + config, + lib, + fn, + ... +}: # For reference: # https://infosec.mozilla.org/guidelines/openssh.html # https://stribika.github.io/2015/01/04/secure-secure-shell.html - with lib; - -mkIf (elem "openssh" config.machine.services) { - services.openssh = { - enable = true; - settings.KexAlgorithms = [ "curve25519-sha256@libssh.org" ]; - sftpFlags = [ "-f AUTHPRIV" "-l INFO" ]; - startWhenNeeded = false; - settings = { - KbdInteractiveAuthentication = false; - PasswordAuthentication = false; - PermitRootLogin = "no"; - }; - extraConfig = let users = concatMapStrings (user: "${user.name} ") config.machine.administrators - + (optionalString config.services.gitea.enable (config.services.gitea.user + " ")); - in '' + mkIf (elem "openssh" config.machine.services) { + services.openssh = { + enable = true; + settings.KexAlgorithms = ["curve25519-sha256@libssh.org"]; + sftpFlags = ["-f AUTHPRIV" "-l INFO"]; + startWhenNeeded = false; + settings = { + KbdInteractiveAuthentication = false; + PasswordAuthentication = false; + PermitRootLogin = "no"; + }; + extraConfig = let + users = + concatMapStrings (user: "${user.name} ") config.machine.administrators + + (optionalString config.services.gitea.enable (config.services.gitea.user + " ")); + in '' UsePAM no AllowUsers ${users} LogLevel VERBOSE - ''; - }; - # Add public keys to /etc/ssh/authorized_keys.d - # This replaces users.users.*.openssh.authorizedKeys.* - sops.secrets = (fn.sopsHelper - (user: "users/${user.name}/publicKey") - config.machine.administrators - (user: { path = "/etc/ssh/authorized_keys.d/${user.name}"; mode = "444"; }) - ); -} + ''; + }; + # Add public keys to /etc/ssh/authorized_keys.d + # This replaces users.users.*.openssh.authorizedKeys.* + sops.secrets = ( + fn.sopsHelper + (user: "users/${user.name}/publicKey") + config.machine.administrators + (user: { + path = "/etc/ssh/authorized_keys.d/${user.name}"; + mode = "444"; + }) + ); + } diff --git a/services/podman.nix b/services/podman.nix index 984e055..4373bed 100644 --- a/services/podman.nix +++ b/services/podman.nix @@ -1,18 +1,22 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - withDocker = (elem "docker" config.machine.services); -in mkIf (elem "podman" config.machine.services) { - virtualisation.podman = { - enable = true; - dockerSocket.enable = withDocker; - dockerCompat = withDocker; - defaultNetwork = { - settings.dns_enabled = true; +{ + config, + lib, + pkgs, + ... +}: +with lib; let + withDocker = elem "docker" config.machine.services; +in + mkIf (elem "podman" config.machine.services) { + virtualisation.podman = { + enable = true; + dockerSocket.enable = withDocker; + dockerCompat = withDocker; + defaultNetwork = { + settings.dns_enabled = true; + }; }; - }; - environment.systemPackages = (with pkgs; [ podman-compose cntr ]) ++ - (optional withDocker pkgs.docker-compose); -} + environment.systemPackages = + (with pkgs; [podman-compose cntr]) + ++ (optional withDocker pkgs.docker-compose); + } diff --git a/services/udev.nix b/services/udev.nix index e813439..b397ff3 100644 --- a/services/udev.nix +++ b/services/udev.nix @@ -1,7 +1,10 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; - -mkIf (elem "udev" config.machine.services) { - hardware.steam-hardware.enable = true; -} + mkIf (elem "udev" config.machine.services) { + hardware.steam-hardware.enable = true; + }