From 3ba26ccfd5a6fce8100fb62bc0e22b2b965bdbe4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 29 May 2022 13:44:45 -0400 Subject: [PATCH] improve comments and general tweaks --- hosts/common.nix | 21 ++++++++++++++++++- modules/editor/neovim/default.nix | 7 +++++-- modules/graphical/i3.nix | 8 ++++---- modules/hardware/audio.nix | 34 +++++++++++++++++++++++-------- modules/hardware/boot.nix | 1 + modules/hardware/keyboard.nix | 7 +++++-- modules/hardware/monitors.nix | 4 ++-- modules/hardware/mouse.nix | 2 +- modules/hardware/sleep.nix | 3 +-- modules/hardware/wifi.nix | 6 ++++-- modules/shell/direnv.nix | 6 +----- modules/shell/fish/default.nix | 6 ++++-- modules/shell/fzf.nix | 1 + modules/shell/git.nix | 4 ++-- 14 files changed, 76 insertions(+), 34 deletions(-) diff --git a/hosts/common.nix b/hosts/common.nix index 7ba995e..2cd1737 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -11,14 +11,33 @@ ../modules/mail/himalaya.nix ]; + options = with lib; { + dotfilesPath = mkOption { + type = types.path; + description = "Path of dotfiles repository."; + default = builtins.toPath "/home/${config.user}/dev/personal/dotfiles"; + }; + }; + config = { + # Enable features in Nix commands nix.extraOptions = "experimental-features = nix-command flakes"; + # Basic common system packages for all devices + environment.systemPackages = with pkgs; [ git vim wget curl ]; + + # Use the system-level nixpkgs instead of Home Manager's home-manager.useGlobalPkgs = true; + + # Install packages to /etc/profiles instead of ~/.nix-profile, useful when + # using multiple profiles home-manager.useUserPackages = true; - environment.systemPackages = with pkgs; [ git vim wget curl ]; + # Set a variable for dotfiles repo, not necessary but convenient + home-manager.users.${config.user} = { + home.sessionVariables = { DOTS = config.dotfilesPath; }; + }; }; diff --git a/modules/editor/neovim/default.nix b/modules/editor/neovim/default.nix index 3ced05b..d8a503a 100644 --- a/modules/editor/neovim/default.nix +++ b/modules/editor/neovim/default.nix @@ -47,8 +47,11 @@ MANPAGER = "nvim +Man!"; }; programs.fish = { - shellAliases = { vim = "nvim"; }; - shellAbbrs = { vll = "vim -c 'Telescope oldfiles'"; }; + shellAbbrs = { + v = lib.mkForce "nvim"; + vl = lib.mkForce "nvim -c 'normal! `0'"; + vll = "nvim -c 'Telescope oldfiles'"; + }; }; }; diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index b2ba2ca..f339137 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -95,13 +95,13 @@ in { # Adjust screen brightness "Shift+F12" = - "exec ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ddcutil --display 2 setvcp 10 + 30"; + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; "Shift+F11" = - "exec ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ddcutil --display 2 setvcp 10 - 30"; + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; "XF86MonBrightnessUp" = - "exec ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ddcutil --display 2 setvcp 10 + 30"; + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; "XF86MonBrightnessDown" = - "exec ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ddcutil --display 2 setvcp 10 - 30"; + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; # Media player controls "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 88c17c4..31b036b 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -32,8 +32,11 @@ in { config = lib.mkIf config.gui.enable { sound.enable = true; + + # Enable PulseAudio hardware.pulseaudio.enable = true; + # These aren't necessary, but helpful for the user environment.systemPackages = with pkgs; [ pamixer # Audio control volnoti # Volume notifications @@ -44,15 +47,28 @@ in { # Graphical volume notifications services.volnoti.enable = true; - # i3 keybinds for changing the volume - xsession.windowManager.i3.config.keybindings = { - "XF86AudioRaiseVolume" = - "exec --no-startup-id ${increaseVolume}/bin/increaseVolume"; - "XF86AudioLowerVolume" = - "exec --no-startup-id ${decreaseVolume}/bin/decreaseVolume"; - "XF86AudioMute" = "exec --no-startup-id ${toggleMute}/bin/toggleMute"; - "XF86AudioMicMute" = - "exec --no-startup-id pamixer --default-source --toggle-mute"; + xsession.windowManager.i3.config = { + + # Make sure that Volnoti actually starts (home-manager doesn't start + # user daemon's automatically) + startup = [{ + command = "systemctl --user restart volnoti"; + always = true; + notification = false; + }]; + + # i3 keybinds for changing the volume + keybindings = { + "XF86AudioRaiseVolume" = + "exec --no-startup-id ${increaseVolume}/bin/increaseVolume"; + "XF86AudioLowerVolume" = + "exec --no-startup-id ${decreaseVolume}/bin/decreaseVolume"; + "XF86AudioMute" = "exec --no-startup-id ${toggleMute}/bin/toggleMute"; + # We can mute the mic by adding "--default-source" + "XF86AudioMicMute" = + "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer --default-source --toggle-mute"; + }; + }; }; diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix index 4e818d8..8d39a17 100644 --- a/modules/hardware/boot.nix +++ b/modules/hardware/boot.nix @@ -1,6 +1,7 @@ { ... }: { # Use the systemd-boot EFI boot loader. + # These came with the system and I don't know if they're required. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; diff --git a/modules/hardware/keyboard.nix b/modules/hardware/keyboard.nix index 6731c29..e5eee1b 100644 --- a/modules/hardware/keyboard.nix +++ b/modules/hardware/keyboard.nix @@ -1,13 +1,16 @@ { ... }: { services.xserver = { + + layout = "us"; + # Keyboard responsiveness autoRepeatDelay = 250; autoRepeatInterval = 40; - # Configure keymap in X11 - layout = "us"; + # Swap escape key with caps lock key xkbOptions = "eurosign:e,caps:swapescape"; + }; } diff --git a/modules/hardware/monitors.nix b/modules/hardware/monitors.nix index 8b797a2..156848b 100644 --- a/modules/hardware/monitors.nix +++ b/modules/hardware/monitors.nix @@ -19,10 +19,10 @@ }; }; - # Detect monitors (brightness) + # Detect monitors (brightness) for ddcutil hardware.i2c.enable = true; - # Grant user access to external monitors + # Grant main user access to external monitors users.users.${config.user}.extraGroups = [ "i2c" ]; services.xserver.displayManager = { diff --git a/modules/hardware/mouse.nix b/modules/hardware/mouse.nix index 861660e..cb3d7f5 100644 --- a/modules/hardware/mouse.nix +++ b/modules/hardware/mouse.nix @@ -2,7 +2,7 @@ config = lib.mkIf config.gui.enable { - # Mouse config + # Mouse customization services.ratbagd.enable = true; environment.systemPackages = with pkgs; [ diff --git a/modules/hardware/sleep.nix b/modules/hardware/sleep.nix index f7b291b..3b7d4bb 100644 --- a/modules/hardware/sleep.nix +++ b/modules/hardware/sleep.nix @@ -2,8 +2,7 @@ # Prevent wake from keyboard powerManagement.powerDownCommands = '' - echo disabled > /sys/bus/usb/devices/1-6/power/wakeup - echo disabled > /sys/bus/usb/devices/1-8/power/wakeup + for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done ''; } diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix index 30b7906..290044e 100644 --- a/modules/hardware/wifi.nix +++ b/modules/hardware/wifi.nix @@ -1,7 +1,9 @@ { ... }: { - networking.wireless.enable = - true; # Enables wireless support via wpa_supplicant. + # Enables wireless support via wpa_supplicant. + networking.wireless.enable = true; + + # Allows the user to control the WiFi settings. networking.wireless.userControlled.enable = true; } diff --git a/modules/shell/direnv.nix b/modules/shell/direnv.nix index b278436..90d06ea 100644 --- a/modules/shell/direnv.nix +++ b/modules/shell/direnv.nix @@ -3,11 +3,7 @@ home-manager.users.${config.user}.programs.direnv = { enable = true; nix-direnv.enable = true; - config = { - whitelist = { - prefix = [ "/home/${config.user}/dev/personal/dotfiles/" ]; - }; - }; + config = { whitelist = { prefix = [ config.dotfilesPath ]; }; }; }; } diff --git a/modules/shell/fish/default.nix b/modules/shell/fish/default.nix index a3a0da0..3d115b8 100644 --- a/modules/shell/fish/default.nix +++ b/modules/shell/fish/default.nix @@ -1,10 +1,12 @@ { config, pkgs, lib, ... }: { users.users.${config.user}.shell = pkgs.fish; - programs.fish.enable = true; # Needed for LightDM to remember username + programs.fish.enable = + true; # Needed for LightDM to remember username (TODO: fix) home-manager.users.${config.user} = { + # Packages used in abbreviations and aliases home.packages = with pkgs; [ curl ]; programs.fish = { @@ -89,7 +91,7 @@ tan = "tmux attach-session -t noah"; tnn = "tmux new-session -s noah"; - # Vim + # Vim (overwritten by Neovim) v = "vim"; vl = "vim -c 'normal! `0'"; diff --git a/modules/shell/fzf.nix b/modules/shell/fzf.nix index f7eb0da..faaa307 100644 --- a/modules/shell/fzf.nix +++ b/modules/shell/fzf.nix @@ -18,6 +18,7 @@ shellAbbrs = { lf = "ls -lh | fzf"; }; }; + # Global fzf configuration home.sessionVariables = let fzfCommand = "fd --type file"; in { FZF_DEFAULT_COMMAND = fzfCommand; diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 727ce66..da56122 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -19,7 +19,7 @@ in { home-manager.users.root.programs.git = { enable = true; - extraConfig.safe.directory = "/home/${config.user}/dev/personal/dotfiles"; + extraConfig.safe.directory = config.dotfilesPath; }; home-manager.users.${config.user} = { @@ -29,7 +29,7 @@ in { userEmail = config.gitEmail; extraConfig = { pager = { branch = "false"; }; - safe = { directory = "/home/${config.user}/dev/personal/dotfiles"; }; + safe = { directory = config.dotfilesPath; }; pull = { ff = "only"; }; init = { defaultBranch = "master"; }; };