mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 12:40:13 +00:00
move nixos and darwin back into modules dir
This commit is contained in:
84
modules/nixos/hardware/audio.nix
Normal file
84
modules/nixos/hardware/audio.nix
Normal file
@ -0,0 +1,84 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
# These micro-scripts change the volume while also triggering the volume
|
||||
# notification widget
|
||||
|
||||
increaseVolume = pkgs.writeShellScriptBin "increaseVolume" ''
|
||||
${pkgs.pamixer}/bin/pamixer -i 2
|
||||
volume=$(${pkgs.pamixer}/bin/pamixer --get-volume)
|
||||
${pkgs.volnoti}/bin/volnoti-show $volume
|
||||
'';
|
||||
|
||||
decreaseVolume = pkgs.writeShellScriptBin "decreaseVolume" ''
|
||||
${pkgs.pamixer}/bin/pamixer -d 2
|
||||
volume=$(${pkgs.pamixer}/bin/pamixer --get-volume)
|
||||
${pkgs.volnoti}/bin/volnoti-show $volume
|
||||
'';
|
||||
|
||||
toggleMute = pkgs.writeShellScriptBin "toggleMute" ''
|
||||
${pkgs.pamixer}/bin/pamixer --toggle-mute
|
||||
mute=$(${pkgs.pamixer}/bin/pamixer --get-mute)
|
||||
if [ "$mute" == "true" ]; then
|
||||
${pkgs.volnoti}/bin/volnoti-show --mute
|
||||
else
|
||||
volume=$(${pkgs.pamixer}/bin/pamixer --get-volume)
|
||||
${pkgs.volnoti}/bin/volnoti-show $volume
|
||||
fi
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
config = lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) {
|
||||
sound.enable = true;
|
||||
|
||||
# Enable PipeWire
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
pulse.enable = true;
|
||||
};
|
||||
|
||||
# Provides audio source with background noise filtered
|
||||
programs.noisetorch.enable = true;
|
||||
|
||||
# These aren't necessary, but helpful for the user
|
||||
environment.systemPackages = with pkgs; [
|
||||
pamixer # Audio control
|
||||
volnoti # Volume notifications
|
||||
];
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
# Graphical volume notifications
|
||||
services.volnoti.enable = true;
|
||||
|
||||
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 --alpha 0.15 --radius 40 --timeout 0.2";
|
||||
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";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
43
modules/nixos/hardware/boot.nix
Normal file
43
modules/nixos/hardware/boot.nix
Normal file
@ -0,0 +1,43 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
boot.loader = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
|
||||
grub = {
|
||||
enable = true;
|
||||
|
||||
# Not sure what this does, but it involves the UEFI/BIOS
|
||||
efiSupport = true;
|
||||
|
||||
# Check for other OSes and make them available
|
||||
useOSProber = true;
|
||||
|
||||
# Attempt to display GRUB on widescreen monitor
|
||||
gfxmodeEfi = "1920x1080";
|
||||
|
||||
# Install GRUB onto the boot disk
|
||||
# device = config.fileSystems."/boot".device;
|
||||
|
||||
# Don't install GRUB, required for UEFI?
|
||||
device = "nodev";
|
||||
|
||||
# Display menu indefinitely if holding shift key
|
||||
extraConfig = ''
|
||||
if keystatus --shift ; then
|
||||
set timeout=-1
|
||||
else
|
||||
set timeout=0
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
# Always display menu indefinitely; default is 5 seconds
|
||||
# timeout = null;
|
||||
|
||||
# Allows GRUB to interact with the UEFI/BIOS I guess
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
# Allow reading from Windows drives
|
||||
boot.supportedFilesystems =
|
||||
lib.mkIf (config.physical && pkgs.stdenv.isLinux) [ "ntfs" ];
|
||||
|
||||
}
|
20
modules/nixos/hardware/default.nix
Normal file
20
modules/nixos/hardware/default.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{ lib, ... }: {
|
||||
|
||||
imports = [
|
||||
./audio.nix
|
||||
./boot.nix
|
||||
./keyboard.nix
|
||||
./monitors.nix
|
||||
./mouse.nix
|
||||
./networking.nix
|
||||
./server.nix
|
||||
./sleep.nix
|
||||
./wifi.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
physical = lib.mkEnableOption "Whether this machine is a physical device.";
|
||||
server = lib.mkEnableOption "Whether this machine is a server.";
|
||||
};
|
||||
|
||||
}
|
16
modules/nixos/hardware/keyboard.nix
Normal file
16
modules/nixos/hardware/keyboard.nix
Normal file
@ -0,0 +1,16 @@
|
||||
{ ... }: {
|
||||
|
||||
services.xserver = {
|
||||
|
||||
layout = "us";
|
||||
|
||||
# Keyboard responsiveness
|
||||
autoRepeatDelay = 250;
|
||||
autoRepeatInterval = 40;
|
||||
|
||||
# Swap escape key with caps lock key
|
||||
xkbOptions = "eurosign:e,caps:swapescape";
|
||||
|
||||
};
|
||||
|
||||
}
|
51
modules/nixos/hardware/monitors.nix
Normal file
51
modules/nixos/hardware/monitors.nix
Normal file
@ -0,0 +1,51 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config =
|
||||
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
|
||||
|
||||
environment.systemPackages = with pkgs;
|
||||
[
|
||||
ddcutil # Monitor brightness control
|
||||
];
|
||||
|
||||
# Reduce blue light at night
|
||||
services.redshift = {
|
||||
enable = true;
|
||||
brightness = {
|
||||
day = "1.0";
|
||||
night = "1.0";
|
||||
};
|
||||
};
|
||||
|
||||
# Detect monitors (brightness) for ddcutil
|
||||
hardware.i2c.enable = true;
|
||||
|
||||
# Grant main user access to external monitors
|
||||
users.users.${config.user}.extraGroups = [ "i2c" ];
|
||||
|
||||
services.xserver.displayManager = {
|
||||
|
||||
# Put the login screen on the left monitor
|
||||
lightdm.greeters.gtk.extraConfig = ''
|
||||
active-monitor=0
|
||||
'';
|
||||
|
||||
# Set up screen position and rotation
|
||||
setupCommands = ''
|
||||
${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-1 \
|
||||
--mode 1920x1200 \
|
||||
--pos 1920x0 \
|
||||
--rotate left \
|
||||
--output HDMI-A-0 \
|
||||
--primary \
|
||||
--mode 1920x1080 \
|
||||
--pos 0x560 \
|
||||
--rotate normal \
|
||||
--output DVI-0 --off \
|
||||
--output DVI-1 --off \
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
22
modules/nixos/hardware/mouse.nix
Normal file
22
modules/nixos/hardware/mouse.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config =
|
||||
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
|
||||
|
||||
# Mouse customization
|
||||
services.ratbagd.enable = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
libratbag # Mouse adjustments
|
||||
piper # Mouse adjustments GUI
|
||||
];
|
||||
|
||||
services.xserver.libinput.mouse = {
|
||||
# Disable mouse acceleration
|
||||
accelProfile = "flat";
|
||||
accelSpeed = "1.15";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
14
modules/nixos/hardware/networking.nix
Normal file
14
modules/nixos/hardware/networking.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
|
||||
|
||||
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
|
||||
# Per-interface useDHCP will be mandatory in the future, so this generated config
|
||||
# replicates the default behaviour.
|
||||
networking.useDHCP = false;
|
||||
networking.interfaces.enp5s0.useDHCP = true;
|
||||
networking.interfaces.wlp4s0.useDHCP = true;
|
||||
|
||||
};
|
||||
|
||||
}
|
11
modules/nixos/hardware/server.nix
Normal file
11
modules/nixos/hardware/server.nix
Normal file
@ -0,0 +1,11 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (pkgs.stdenv.isLinux && config.server) {
|
||||
|
||||
# Servers need a bootloader or they won't start
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
};
|
||||
|
||||
}
|
12
modules/nixos/hardware/sleep.nix
Normal file
12
modules/nixos/hardware/sleep.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
|
||||
|
||||
# Prevent wake from keyboard
|
||||
powerManagement.powerDownCommands = ''
|
||||
for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
}
|
13
modules/nixos/hardware/wifi.nix
Normal file
13
modules/nixos/hardware/wifi.nix
Normal file
@ -0,0 +1,13 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
|
||||
|
||||
# Enables wireless support via wpa_supplicant.
|
||||
networking.wireless.enable = true;
|
||||
|
||||
# Allows the user to control the WiFi settings.
|
||||
networking.wireless.userControlled.enable = true;
|
||||
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user