From 2879732b42dc67c3dc284b0b1caffaea93150dc7 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 3 Jun 2018 14:35:49 -0700 Subject: [PATCH 01/11] [Emacs] Only use exec-path-from-shell in MacOS --- dotfiles/emacs.d/README.org | 1 + 1 file changed, 1 insertion(+) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 0049c23b..f7c6518f 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -218,6 +218,7 @@ These definitions silence the byte-compiler. Sets environment variables by starting a shell. #+BEGIN_SRC emacs-lisp (use-package exec-path-from-shell + :disabled (not (equal system-type 'darwin)) :config (progn ;; For debugging From 53a0fb9689347e260f2df7737c439bb138a7a03e Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 4 Jun 2018 13:30:58 -0700 Subject: [PATCH 02/11] [Linux] Restore xmonad shell script --- dotfiles/lib/bin/xmonad | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 dotfiles/lib/bin/xmonad diff --git a/dotfiles/lib/bin/xmonad b/dotfiles/lib/bin/xmonad new file mode 100755 index 00000000..47e6a2c5 --- /dev/null +++ b/dotfiles/lib/bin/xmonad @@ -0,0 +1,10 @@ +#!/usr/bin/env zsh +# -*- mode:sh + +if command_exists "imalison-taffybar"; then + imalison-xmonad "$@" +else + # Move .lib/bin to the end of PATH so that this script is not called again + add_to_path "$HOME/.lib/bin" --after + xmonad "$@" +fi From f5525df0bccc3e3b0b0b4e017ea90b917c236a3d Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 4 Jun 2018 13:31:34 -0700 Subject: [PATCH 03/11] [Termite] Make scrollback unlimted --- dotfiles/config/termite/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotfiles/config/termite/config b/dotfiles/config/termite/config index 6f5c2929..dfe4dda1 100644 --- a/dotfiles/config/termite/config +++ b/dotfiles/config/termite/config @@ -1,5 +1,6 @@ [options] dynamic_title = true +scrollback_lines = -1 [colors] # Base16 Default Dark @@ -49,3 +50,4 @@ color18 = #282828 color19 = #383838 color20 = #b8b8b8 color21 = #e8e8e8 + From 4538ff4c6beb8a18c6491d75979f0a0e701ce9ca Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 4 Jun 2018 13:47:37 -0700 Subject: [PATCH 04/11] [Linux] Use pulsemixer for volume control --- dotfiles/config/xmonad/xmonad.hs | 19 +++++++++++-------- dotfiles/lib/bin/set_volume.sh | 5 +++-- dotfiles/lib/setup_functions.sh | 5 ++++- dotfiles/lib/shellenv/linux.sh | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dotfiles/config/xmonad/xmonad.hs b/dotfiles/config/xmonad/xmonad.hs index f41efd79..95468e81 100644 --- a/dotfiles/config/xmonad/xmonad.hs +++ b/dotfiles/config/xmonad/xmonad.hs @@ -461,7 +461,6 @@ myReplaceWindow = -- Workspace Names for EWMH - setWorkspaceNames :: X () setWorkspaceNames = withWindowSet $ \s -> withDisplay $ \dpy -> do sort' <- getSortByIndex @@ -865,6 +864,10 @@ goToNextScreenX = windows goToNextScreen -- Key bindings +volumeUp = spawn "set_volume.sh --unmute --change-volume +5" +volumeDown = spawn "set_volume.sh --unmute --change-volume -5" +mute = spawn "set_volume.sh --toggle-mute" + shiftToEmptyOnScreen direction = followingWindow (windowToScreen direction True) >> shiftToEmptyAndView @@ -907,7 +910,7 @@ addKeys conf@XConfig { modMask = modm } = , ((modalt, xK_Return), deactivateFullAnd restoreAllMinimized) , ((modm .|. controlMask, xK_t), setReplaceTarget >> spawn "chromix-too open chrome://newtab") - , ((mod .|. controlMask, xK_c), chromeReplaceKill) + , ((modm .|. controlMask, xK_c), chromeReplaceKill) , ((hyper, xK_g), gatherThisClass) -- Directional navigation @@ -1005,12 +1008,12 @@ addKeys conf@XConfig { modMask = modm } = , ((0, xF86XK_AudioPrev), spawn "playerctl previous") -- Volume control - , ((0, xF86XK_AudioRaiseVolume), spawn "set_volume.sh up") - , ((0, xF86XK_AudioLowerVolume), spawn "set_volume.sh down") - , ((0, xF86XK_AudioMute), spawn "set_volume.sh mute") - , ((modm, xK_i), spawn "set_volume.sh up") - , ((modm, xK_k), spawn "set_volume.sh down") - , ((modm, xK_u), spawn "set_volume.sh mute") + , ((0, xF86XK_AudioRaiseVolume), volumeUp) + , ((0, xF86XK_AudioLowerVolume), volumeDown) + , ((0, xF86XK_AudioMute), mute) + , ((modm, xK_i), volumeUp) + , ((modm, xK_k), volumeDown) + , ((modm, xK_u), mute) , ((hyper .|. shiftMask, xK_q), spawn "toggle_mute_current_window.sh") , ((hctrl, xK_q), spawn "toggle_mute_current_window.sh only") diff --git a/dotfiles/lib/bin/set_volume.sh b/dotfiles/lib/bin/set_volume.sh index b2771cc6..f89dedd3 100755 --- a/dotfiles/lib/bin/set_volume.sh +++ b/dotfiles/lib/bin/set_volume.sh @@ -10,7 +10,8 @@ function switch_sink_applications() } current_default=$(pahelper.sh list | grep '*' | all_after_char ":" | xargs) -environment_variable_exists USE_ONLY_ONE_PASINK && pahelper.sh "$current_default" +environment_variable_exists USE_ONLY_O_PASINK && pahelper.sh "$current_default" -pulseaudio-ctl "$@" +# XXX: this does not prevent volumes higher than 100 +pulsemixer "$@" pashowvolume diff --git a/dotfiles/lib/setup_functions.sh b/dotfiles/lib/setup_functions.sh index e98a4d67..4c9a753f 100644 --- a/dotfiles/lib/setup_functions.sh +++ b/dotfiles/lib/setup_functions.sh @@ -60,7 +60,6 @@ function get_linux_distro { return 1 } - function is_osx() { if command_exists uname; then case `uname` in @@ -82,3 +81,7 @@ function source_directory_files { source "$filename" done } + +function min { + [ $1 -le $2 ] && echo "$1" || echo "$2" +} diff --git a/dotfiles/lib/shellenv/linux.sh b/dotfiles/lib/shellenv/linux.sh index 95c74d59..3fc459e6 100644 --- a/dotfiles/lib/shellenv/linux.sh +++ b/dotfiles/lib/shellenv/linux.sh @@ -13,7 +13,7 @@ pasink() { pavolume () { pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'"$(pasink)"'>"} - /^\s+volume: / && indefault {print $5; exit}' + /^\s+volume: / && indefault {print $5; exit}' | grep -Eo "[0-9]*" } paismuted () { @@ -24,7 +24,7 @@ pashowvolume () { if paismuted; then volnoti-show -m else - volnoti-show "$(pavolume)" + volnoti-show "$(min $(pavolume) 100)" fi } From 6d351ccf4c53f1a49bbb67a267ace02ebf2c7c79 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 16:05:36 -0700 Subject: [PATCH 05/11] [Emacs] Demand server startup --- dotfiles/emacs.d/README.org | 1 + 1 file changed, 1 insertion(+) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index b8c43549..191bf95b 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -1418,6 +1418,7 @@ Paradox is a package.el extension. I have no use for it now that I use straight. ** server #+BEGIN_SRC emacs-lisp (use-package server + :demand t :config (progn (defvar imalison:default-server-file From b01be33386707d6b0cdceb5b43b4c68abc52d887 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:29:37 -0700 Subject: [PATCH 06/11] [Emacs] Only enable lsp-haskell when hie binary exists --- dotfiles/config/xmonad/build | 31 +++++++++++++++++++++++++++++-- dotfiles/config/xmonad/stack.yaml | 9 +++++++++ dotfiles/emacs.d/README.org | 3 ++- dotfiles/lib/bin/xmonad | 10 ---------- 4 files changed, 40 insertions(+), 13 deletions(-) delete mode 100755 dotfiles/lib/bin/xmonad diff --git a/dotfiles/config/xmonad/build b/dotfiles/config/xmonad/build index a1ecc97b..5b93498c 100755 --- a/dotfiles/config/xmonad/build +++ b/dotfiles/config/xmonad/build @@ -1,9 +1,36 @@ #!/usr/bin/env bash +function min { + [ $1 -le $2 ] && echo "$1" || echo "$2" +} + +function get_exe_dir { + # XXX: This exists because calling in to stack is kind of slow with nix + # integration enabled, even when just using it to get a path. + if [ -e ./.cached-stack-install-path ]; then + cat .cached-stack-install-path + else + stack path --local-install-root + fi +} + +function do_rebuild { + +} + SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" EXE_NAME=imalison-xmonad +EXE_LOCATION=$(get_exe_dir)/bin/$EXE_NAME output_file=$1; shift -stack install -cp -uf $(stack path --local-install-root)/bin/$EXE_NAME $output_file +if [ -e ./.cached-stack-install-path ]; then + last_built=$(stat -c '%Y' $EXE_LOCATION) + xmonad_modified=$(stat -c '%Y' ./xmonad.hs) + + [ $last_built -lt $xmonad_modified ] && stack install +else + stack install +fi + +cp -uf $EXE_LOCATION $output_file diff --git a/dotfiles/config/xmonad/stack.yaml b/dotfiles/config/xmonad/stack.yaml index 045170ce..8e09048c 100644 --- a/dotfiles/config/xmonad/stack.yaml +++ b/dotfiles/config/xmonad/stack.yaml @@ -9,3 +9,12 @@ packages: extra-deps: - X11-xft-0.3.1 resolver: lts-11.7 +nix: + packages: + - pkgconfig + - x11 + - xorg.libX11 + - xorg.libXext + - xorg.libXinerama + - xorg.libXrandr + - xorg.libXrender diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 191bf95b..23a2a700 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -2774,7 +2774,8 @@ The following is taken from [[https://github.com/syl20bnr/spacemacs/blob/a650877 #+BEGIN_SRC emacs-lisp (use-package lsp-haskell :config - (add-hook 'haskell-mode-hook 'lsp-haskell-enable)) + (when (executable-find "hie") + (add-hook 'haskell-mode-hook 'lsp-haskell-enable))) #+END_SRC **** intero Intero seems to be causing hangs, so it has been disabled diff --git a/dotfiles/lib/bin/xmonad b/dotfiles/lib/bin/xmonad deleted file mode 100755 index 47e6a2c5..00000000 --- a/dotfiles/lib/bin/xmonad +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zsh -# -*- mode:sh - -if command_exists "imalison-taffybar"; then - imalison-xmonad "$@" -else - # Move .lib/bin to the end of PATH so that this script is not called again - add_to_path "$HOME/.lib/bin" --after - xmonad "$@" -fi From 1db8fe3088be1c9bae0be049aad88ead5be758b0 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:29:58 -0700 Subject: [PATCH 07/11] [Emacs] Use prebuilt auctex --- dotfiles/emacs.d/README.org | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 23a2a700..c83a941a 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -3608,7 +3608,9 @@ alphanumeric characters only." *** TeX #+BEGIN_SRC emacs-lisp (use-package tex - :straight auctex + :straight (auctex :host github :repo "raxod502/auctex" + :branch "fork/1" + :files (:defaults (:exclude "doc/*.texi"))) :commands TeX-mode :preface (progn From 7f622596b356c4271486d27d6dc61f707ad13c30 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:31:29 -0700 Subject: [PATCH 08/11] [Linux] Load XDG_DATA_DIRS in xprofile --- dotfiles/xprofile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotfiles/xprofile b/dotfiles/xprofile index 34526974..ea51963e 100644 --- a/dotfiles/xprofile +++ b/dotfiles/xprofile @@ -1,9 +1,11 @@ # -*- mode: sh; -*- - # If there are issues with path, check /etc/profile for hard overrides of PATH. . "$HOME/.lib/login.sh" # XXX: prevents https://github.com/xmonad/xmonad/issues/86 from affecting startup rm -f ~/.xmonad/xmonad.state load_xkb_map.sh + +run_if_exists systemctl --user import-environment XDG_DATA_DIRS +run_if_exists systemctl --user start wm.target From 6fd51c74d866848107038b5612e304b2316d48d1 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:33:16 -0700 Subject: [PATCH 09/11] [taffybar] Add nix packages section to stack.yaml --- dotfiles/config/taffybar/stack.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dotfiles/config/taffybar/stack.yaml b/dotfiles/config/taffybar/stack.yaml index ee3aa68c..d0355036 100644 --- a/dotfiles/config/taffybar/stack.yaml +++ b/dotfiles/config/taffybar/stack.yaml @@ -46,3 +46,23 @@ extra-deps: - time-units-1.0.0 - xml-helpers-1.0.0 resolver: lts-11.7 +nix: + packages: + - cairo + - gcc + - gnome2.pango + - gobjectIntrospection + - gtk3 + - hicolor-icon-theme + - libdbusmenu-glib + - libdbusmenu-gtk3 + - libxml2 + - numix-icon-theme-circle + - pkgconfig + - x11 + - xorg.libX11 + - xorg.libXext + - xorg.libXinerama + - xorg.libXrandr + - xorg.libXrender + - zlib From 075b1a98c432d890218a65967f4426b4cefcff81 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:55:07 -0700 Subject: [PATCH 10/11] [NixOS] Add nixOS machine configuration and base configuration --- nixos/configuration.nix | 201 +++++++++++++++++++++++++++++++ nixos/machines/imalison-home.nix | 60 +++++++++ 2 files changed, 261 insertions(+) create mode 100644 nixos/configuration.nix create mode 100644 nixos/machines/imalison-home.nix diff --git a/nixos/configuration.nix b/nixos/configuration.nix new file mode 100644 index 00000000..c3a96cdb --- /dev/null +++ b/nixos/configuration.nix @@ -0,0 +1,201 @@ +{ config, pkgs, ... }: +let + my-python-packages = python-packages: with python-packages; [ + appdirs + requests + virtualenv + ipython + ipdb + virtualenvwrapper + pip + ]; + python-with-my-packages = pkgs.python3.withPackages my-python-packages; +in +{ + boot.loader.systemd-boot.enable = true; + nixpkgs.config.allowUnfree = true; + security.sudo.wheelNeedsPassword = false; + networking.networkmanager.enable = true; + + i18n = { + consoleKeyMap = "us"; + defaultLocale = "en_US.UTF-8"; + }; + + # Set your time zone. + # TODO: this should be set dynamically + time.timeZone = "America/Los_Angeles"; + + fonts = { + fonts = with pkgs; [ + fira-mono + dejavu_fonts + noto-fonts-emoji + emojione + twemoji-color-font + source-code-pro + roboto + source-sans-pro + source-serif-pro + ]; + fontconfig = { + defaultFonts = { + monospace = [ "Source Code Pro" ]; + sansSerif = [ "Roboto" ]; + serif = [ "Source Serif Pro" ]; + }; + ultimate = { + enable = false; + }; + }; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + + # Applications + google-chrome + firefox + hexchat + kodi + vlc + xfce.thunar + spotify + termite + rxvt_unicode + emacs + + # Appearance + numix-icon-theme-circle + gnome3.adwaita-icon-theme + hicolor-icon-theme + + # Desktop + autorandr + clipit + compton + feh + sddm-kcm + networkmanagerapplet + pinentry + pommed_light + rofi + rofi-pass + volnoti + xclip + xdotool + xorg.xkbcomp + xsettingsd + + # Audio + pulsemixer + pavucontrol + playerctl + + # Haskell + cabal-install + cabal2nix + ghc + stack2nix + stack + + # Tools + binutils + gcc + gitFull + gnumake + gnupg + htop + ncdu + pass + python-with-my-packages + rcm + silver-searcher + stow + tmux + wget + zsh + + # Miscellaneous + librsvg + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + + environment.loginShellInit = ". ~/.lib/nix_login.sh"; + + services.xserver = { + exportConfiguration = true; + enable = true; + layout = "us"; + videoDrivers = [ "nvidia" ]; + desktopManager = { + gnome3.enable = true; + default = "none"; + }; + windowManager = { + default = "xmonad"; + i3.enable = true; + session = [{ + name = "xmonad"; + start = '' + /usr/bin/env imalison-xmonad & + waitPID=$! + ''; + }]; + }; + displayManager = { + # lightdm = { + # enable = true; + # extraSeatDefaults='' + # greeter-hide-users=false + # ''; + # }; + sddm = { + enable = true; + }; + }; + + }; + + hardware.opengl.driSupport32Bit = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.extraUsers.imalison = { + name = "imalison"; + group = "users"; + isNormalUser = true; + extraGroups = [ + "wheel" "disk" "audio" "video" + "networkmanager" "systemd-journal" + ]; + createHome = true; + uid = 1000; + home = "/home/imalison"; + shell = pkgs.zsh; + }; + + system.stateVersion = "18.03"; # Did you read the comment? +} diff --git a/nixos/machines/imalison-home.nix b/nixos/machines/imalison-home.nix new file mode 100644 index 00000000..53fd22b5 --- /dev/null +++ b/nixos/machines/imalison-home.nix @@ -0,0 +1,60 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + + ../configuration.nix + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/110e3bf8-19b7-4a39-8e2a-b4c3c0d59d0e"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/B2DA-CD21"; + fsType = "vfat"; + }; + + fileSystems."/arch-linux-root" = { + device = "/dev/disk/by-uuid/9095e51e-33f9-440d-a272-46e129800f81"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/a6933b22-c7f4-4c57-b330-1450f313922e"; } + { device = "/dev/disk/by-uuid/dbd49a76-4b3e-4b5c-9a88-68a9e61f6210"; } + ]; + + nix.maxJobs = lib.mkDefault 4; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + + boot.initrd.luks.devices = [ + { + name = "root"; + device = "/dev/sda3"; + preLVM = true; + } + ]; + + boot.loader.grub.device = "/dev/sda"; + + networking.hostName = "imalison-home"; + boot.loader.efi.canTouchEfiVariables = true; + + services.xserver.screenSection = '' + DefaultDepth 24 + Option "RegistryDwords" "PerfLevelSrc=0x3322; PowerMizerDefaultAC=0x1" + Option "TripleBuffer" "True" + Option "Stereo" "0" + Option "nvidiaXineramaInfoOrder" "DFP-0" + Option "metamodes" "DVI-D-0: nvidia-auto-select +0+2160 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}, HDMI-0: nvidia-auto-select +640+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}, HDMI-1: nvidia-auto-select +2560+2160 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}" + Option "SLI" "Off" + Option "MultiGPU" "Off" + Option "BaseMosaic" "off" + ''; +} From ff06de1939ca18b87b58339ebd2fe8c8d46a02a3 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 22:34:08 -0700 Subject: [PATCH 11/11] [rofi] Use Souce Code Pro for element font --- dotfiles/config/rofi/sidestyle.rasi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/config/rofi/sidestyle.rasi b/dotfiles/config/rofi/sidestyle.rasi index 8d688079..e4091fee 100644 --- a/dotfiles/config/rofi/sidestyle.rasi +++ b/dotfiles/config/rofi/sidestyle.rasi @@ -91,7 +91,7 @@ } #element { - font: "Open Sans 13"; + font: "Source Code Pro 13"; padding: 12px 1.5em 12px 14px; }