diff --git a/Makefile b/Makefile index f9bcd9d3..bf15a8b2 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ channels: $(NIXOS_PREFIX)/configuration.nix: @sudo nixos-generate-config --root "$(PREFIX)" - @echo "(import /etc/dotfiles \"$$(hostname)\")" | sudo tee "$(NIXOS_PREFIX)/configuration.nix" + @echo "import /etc/dotfiles \"$$(hostname)\"" | sudo tee "$(NIXOS_PREFIX)/configuration.nix" # Convenience aliases diff --git a/hosts/personal.nix b/hosts/personal.nix index 203f2471..9713d787 100644 --- a/hosts/personal.nix +++ b/hosts/personal.nix @@ -1,11 +1,14 @@ # hosts/personal.nix --- settings common to my personal systems -{ pkgs, ... }: +{ config, pkgs, ... }: { - imports = [ ./. ]; + imports = [ + ./. + + ]; + # Support for more filesystems environment.systemPackages = with pkgs; [ - # Support for more filesystems exfat ntfs3g hfsprogs @@ -26,27 +29,4 @@ "192.168.1.11" = [ "shiro" ]; "192.168.1.12" = [ "midori" ]; }; - - - ### A tidy $HOME is a tidy mind. - # Obey XDG conventions; - my.home.xdg.enable = true; - environment.variables = { - # These are the defaults, but some applications are buggy when these lack - # explicit values. - XDG_CONFIG_HOME = "$HOME/.config"; - XDG_CACHE_HOME = "$HOME/.cache"; - XDG_DATA_HOME = "$HOME/.local/share"; - XDG_BIN_HOME = "$HOME/.local/bin"; - }; - # Conform more programs to XDG conventions. The rest are handled by their - # respective modules. - my.env = { - __GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv"; - CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv"; - HISTFILE = "$XDG_DATA_HOME/bash/history"; - INPUTRC = "$XDG_CACHE_HOME/readline/inputrc"; - LESSHISTFILE = "$XDG_CACHE_HOME/lesshst"; - WGETRC = "$XDG_CACHE_HOME/wgetrc"; - }; } diff --git a/modules/desktop/apps/st.nix b/modules/desktop/apps/st.nix new file mode 100644 index 00000000..3196551f --- /dev/null +++ b/modules/desktop/apps/st.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: + +{ + services.xserver.desktopManager.xterm.enable = false; + + my.packages = with pkgs; [ + libqalculate # calculator cli w/ currency & unit conversion + + xst # st + nice-to-have extensions + (makeDesktopItem { + name = "xst"; + desktopName = "Suckless Terminal"; + genericName = "Default terminal"; + icon = "utilities-terminal"; + exec = "${xst}/bin/xst"; + categories = "Development;System;Utility"; + }) + + (writeScriptBin "st-scratch" '' + #!${stdenv.shell} + SCRID=st-scratch + focused=$(xdotool getactivewindow) + scratch=$(xdotool search --onlyvisible --classname $SCRID) + if [[ -n $scratch ]]; then + if [[ $focused == $scratch ]]; then + xdotool windowkill $scratch + else + xdotool windowactivate $scratch + fi + else + xst -t $SCRID -n $SCRID -c $SCRID \ + -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ + -g 100x26 \ + -e $SHELL + fi + '') + (writeScriptBin "st-calc" '' + #!${stdenv.shell} + SCRID=st-calc + scratch=$(xdotool search --onlyvisible --classname $SCRID) + [ -n "$scratch" ] && xdotool windowkill $scratch + xst -t $SCRID -n $SCRID -c $SCRID \ + -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ + -g 80x12 \ + -e $SHELL -c qalc + '') + (makeDesktopItem { + name = "st-calc"; + desktopName = "Calculator"; + icon = "calc"; + exec = "st-calc"; + categories = "Development"; + }) + ]; +} diff --git a/modules/desktop/bspwm.nix b/modules/desktop/bspwm.nix index 30f50b01..7c3bae1c 100644 --- a/modules/desktop/bspwm.nix +++ b/modules/desktop/bspwm.nix @@ -2,14 +2,16 @@ { imports = [ + ./. # common settings # My launcher ./apps/rofi.nix - # I often need a thumbnail browser to show off, peruse or organize photos, # design work, or digital art. ./apps/thunar.nix - + # ./apps/redshift.nix + # + ./apps/st.nix ]; environment.systemPackages = with pkgs; [ @@ -26,7 +28,6 @@ services = { xserver = { enable = true; - desktopManager.xterm.enable = false; windowManager.bspwm.enable = true; displayManager.lightdm = { enable = true; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 9adb5e36..2a448d07 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -1,6 +1,42 @@ { config, lib, pkgs, ... }: { + my = { + packages = with pkgs; [ + calibre # managing my ebooks + evince # pdf reader + feh # image viewer + mpv # video player + xclip + xdotool + ]; + }; + + ## Sound + sound.enable = true; + hardware.pulseaudio.enable = true; + + ## Fonts + fonts = { + enableFontDir = true; + enableGhostscriptFonts = true; + fonts = with pkgs; [ + ubuntu_font_family + dejavu_fonts + fira-code + fira-code-symbols + symbola + noto-fonts + noto-fonts-cjk + font-awesome-ttf + siji + ]; + fontconfig.defaultFonts = { + sansSerif = ["Ubuntu"]; + monospace = ["Fira Code"]; + }; + }; + services.compton = { backend = "glx"; vSync = true; @@ -22,108 +58,4 @@ "_GTK_FRAME_EXTENTS@:c" ]; }; - - my = { - env.XAUTHORITY = "/tmp/Xauthority"; - init = "[ -e ~/.Xauthority ] && mv -f ~/.Xauthority \"$XAUTHORITY\""; - - packages = with pkgs; [ - libqalculate - xclip - xdotool - mpv # video player - feh # image viewer - - # Useful apps - calibre # managing my ebooks - evince # pdf reader - - xst # st + nice-to-have extensions - (makeDesktopItem { - name = "xst"; - desktopName = "Suckless Terminal"; - genericName = "Default terminal"; - icon = "utilities-terminal"; - exec = "${xst}/bin/xst"; - categories = "Development;System;Utility"; - }) - - (writeScriptBin "st-scratch" '' - #!${stdenv.shell} - SCRID=st-scratch - focused=$(xdotool getactivewindow) - scratch=$(xdotool search --onlyvisible --classname $SCRID) - if [[ -n $scratch ]]; then - if [[ $focused == $scratch ]]; then - xdotool windowkill $scratch - else - xdotool windowactivate $scratch - fi - else - xst -t $SCRID -n $SCRID -c $SCRID \ - -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ - -g 100x26 \ - -e $SHELL - fi - '') - (writeScriptBin "st-calc" '' - #!${stdenv.shell} - SCRID=st-calc - scratch=$(xdotool search --onlyvisible --classname $SCRID) - [ -n "$scratch" ] && xdotool windowkill $scratch - xst -t $SCRID -n $SCRID -c $SCRID \ - -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ - -g 80x12 \ - -e $SHELL -c qalc - '') - (makeDesktopItem { - name = "st-calc"; - desktopName = "Calculator"; - icon = "calc"; - exec = "st-calc"; - categories = "Development"; - }) - ]; - }; - - fonts.enableFontDir = true; - fonts.enableGhostscriptFonts = true; - fonts.fonts = with pkgs; [ - ubuntu_font_family - dejavu_fonts - fira-code - fira-code-symbols - symbola - noto-fonts - noto-fonts-cjk - font-awesome-ttf - siji - ]; - fonts.fontconfig.defaultFonts = { - sansSerif = ["Ubuntu"]; - monospace = ["Fira Code"]; - }; - - system.activationScripts.clearHome = '' - pushd /home/${config.my.username} - rm -rf .compose-cache .nv .pki .dbus .fehbg - [ -s .xsession-errors ] || rm -f .xsession-errors* - popd - ''; - - sound.enable = true; - hardware.pulseaudio.enable = true; - # Prevents ~/.esd_auth files by disabling the esound protocol module for - # pulseaudio, which I likely don't need. Is there a better way? - hardware.pulseaudio.configFile = - let paConfigFile = - with pkgs; runCommand "disablePulseaudioEsoundModule" - { buildInputs = [ pulseaudio ]; } '' - mkdir "$out" - cp ${pulseaudio}/etc/pulse/default.pa "$out/default.pa" - sed -i -e 's|load-module module-esound-protocol-unix|# ...|' "$out/default.pa" - ''; - in lib.mkIf config.hardware.pulseaudio.enable - "${paConfigFile}/default.pa"; - } diff --git a/modules/xdg.nix b/modules/xdg.nix new file mode 100644 index 00000000..971bd5b0 --- /dev/null +++ b/modules/xdg.nix @@ -0,0 +1,49 @@ +# modules/xdg.nix -- a tidy $HOME is a tidy mind + +{ config, lib, pkgs, ... }: +{ + # Obey XDG conventions; + my.home.xdg.enable = true; + environment.variables = { + # These are the defaults, but some applications are buggy when these lack + # explicit values. + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_DATA_HOME = "$HOME/.local/share"; + XDG_BIN_HOME = "$HOME/.local/bin"; + }; + + # Conform more programs to XDG conventions. The rest are handled by their + # respective modules. + my.env = { + __GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv"; + CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv"; + HISTFILE = "$XDG_DATA_HOME/bash/history"; + INPUTRC = "$XDG_CACHE_HOME/readline/inputrc"; + LESSHISTFILE = "$XDG_CACHE_HOME/lesshst"; + WGETRC = "$XDG_CACHE_HOME/wgetrc"; + XAUTHORITY = "/tmp/Xauthority"; + }; + my.init = "[ -e ~/.Xauthority ] && mv -f ~/.Xauthority \"$XAUTHORITY\""; + + # Prevents ~/.esd_auth files by disabling the esound protocol module for + # pulseaudio, which I likely don't need. Is there a better way? + hardware.pulseaudio.configFile = + let paConfigFile = + with pkgs; runCommand "disablePulseaudioEsoundModule" + { buildInputs = [ pulseaudio ]; } '' + mkdir "$out" + cp ${pulseaudio}/etc/pulse/default.pa "$out/default.pa" + sed -i -e 's|load-module module-esound-protocol-unix|# ...|' "$out/default.pa" + ''; + in lib.mkIf config.hardware.pulseaudio.enable + "${paConfigFile}/default.pa"; + + # Clean up leftovers, as much as we can + system.activationScripts.clearHome = '' + pushd /home/${config.my.username} + rm -rf .compose-cache .nv .pki .dbus .fehbg + [ -s .xsession-errors ] || rm -f .xsession-errors* + popd + ''; +}