nixos-config/hosts/eddie/configuration.nix

693 lines
16 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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).
{
nix-config,
config,
pkgs,
inputs,
...
}:
{
imports = with nix-config.nixosModules; [
# Include the results of the hardware scan.
./hardware-configuration.nix
./razer-speaker-fix.nix
niri
];
nixpkgs = {
config = {
allowUnfree = true;
};
overlays = builtins.attrValues nix-config.overlays ++ [
inputs.niri.overlays.niri
inputs.emacs-overlay.overlays.default
inputs.audio.overlays.default
inputs.nix-rice.overlays.default
(final: prev: {
wineWowPackages.stagingFull = nix-config.pkgs-stable.wineWowPackages.stagingFull.overrideAttrs (old: {
patches = old.patches ++ [ ../../patches/wine-6006.patch ];
waylandSupport = true;
fontconfigSupport = true;
vulkanSupport = true;
});
})
];
};
nix = {
# registry.nixpkgs.flake = nixpkgs;
# channel.enable = false;
settings = {
experimental-features = [
"nix-command"
"flakes"
];
substituters = [
"https://nix-community.cachix.org"
"https://cache.garnix.io"
];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
# Workaround for https://github.com/NixOS/nix/issues/9574
nix-path = config.nix.nixPath;
};
};
sops = {
age.keyFile = "/home/emenel/.config/sops/age/keys.txt"; # must have no password!
defaultSopsFile = ./secrets.yaml;
secrets = {
filez = {};
};
templates."smb-secrets".content = ''
username=admin
password=${config.sops.placeholder.filez}
# '';
};
environment.etc = {
"nixos/smb-secrets" = {
source = config.sops.templates."smb-secrets".path;
group = "users";
};
};
fileSystems =
let
automount_opts = "x-systemd.automount,noauto,users,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,uid=1000,credentials=/etc/nixos/smb-secrets";
in {
"/mnt/filez/media" = {
device = "//100.70.114.113/Media";
fsType = "smb3";
options = [
"${automount_opts}"
];
};
"/mnt/filez/music-production" = {
device = "//100.70.114.113/Music Production";
fsType = "smb3";
options = [
"${automount_opts}"
];
};
"/mnt/filez/storage" = {
device = "//100.70.114.113/Storage";
fsType = "smb3";
options = [
"${automount_opts}"
];
};
"/mnt/filez/photos" = {
device = "//100.70.114.113/Photo Storage";
fsType = "smb3";
options = [
"${automount_opts}"
];
};
};
# fileSystems."/mnt/beets-import" = {
# device = "//100.103.170.132/media";
# fsType = "smb3";
# options = let
# automount_opts = "x-systemd.automount,noauto,users,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,uid=1000";
# in [
# "${automount_opts}"
# ];
# };
environment.systemPackages = with pkgs; [
wget
libGL
home-manager
curl
git-lfs
tailscale
rsync
gnupg
clinfo
alsa-utils
alsa-oss
psutils
util-linux
libgtop
fontconfig
freetype
egl-wayland
glfw-wayland
openssl
appimage-run
xwayland-satellite
xwayland-run
cifs-utils
];
# Bootloader.
boot = {
loader = {
systemd-boot.enable = true;
systemd-boot.configurationLimit = 8;
efi.canTouchEfiVariables = true;
};
kernelPackages = pkgs.linuxPackages_latest;
initrd.systemd.enable = true;
initrd.kernelModules = [
"nvidia"
"nvidia_modeset"
"nvidia_uvm"
"nvidia_drm"
"snd-virmidi"
];
kernelParams = [
"nvidia_drm.fbdev=1"
"nvidia_drm.modeset=1"
];
};
systemd.services.tailscaled.after = [ "NetworkManager-wait-online.service" ];
systemd.sleep.extraConfig = ''
HibernateDelaySec=2h
'';
documentation = {
dev.enable = true;
man.generateCaches = true;
};
hardware = {
openrazer = {
enable = true;
users = [ "emenel" ];
};
graphics = {
enable = true;
enable32Bit = true;
extraPackages = [
pkgs.rocmPackages.clr.icd
pkgs.amdvlk
];
extraPackages32 = [
pkgs.driversi686Linux.amdvlk
];
};
enableAllFirmware = true;
firmware = [
pkgs.sof-firmware
pkgs.alsa-firmware
];
nvidia = {
open = true;
# Modesetting is required.
modesetting.enable = true;
powerManagement.enable = true;
powerManagement.finegrained = true;
# forceFullCompositionPipeline = true;
package = config.boot.kernelPackages.nvidiaPackages.beta;
prime = {
amdgpuBusId = "PCI:101:0:0";
nvidiaBusId = "PCI:1:0:0";
offload = {
enable = true;
enableOffloadCmd = true;
};
#reverseSync.enable = true;
#sync.enable = true;
};
nvidiaSettings = true;
};
};
musnix = {
enable = true;
alsaSeq.enable = true;
rtcqs.enable = true;
};
services.fstrim.enable = true;
services.logind = {
extraConfig = ''
IdleAction=lock
IdleActionSec=5m
'';
};
services.udev = {
extraRules = ''
DEVPATH=="/devices/virtual/misc/cpu_dma_latency", OWNER="root", GROUP="audio", MODE="0660"
'';
packages = [
pkgs.via
pkgs.vial
(pkgs.writeTextFile {
name = "on-battery";
text = ''
# Rule for when switching to battery
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced"
'';
destination = "/etc/udev/rules.d/60-onbattery.rules";
})
(pkgs.writeTextFile {
name = "on-power";
text = ''
# Rule for when switching to ac
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance"
'';
destination = "/etc/udev/rules.d/61-onpower.rules";
})
(pkgs.writeTextFile {
name = "hibernate-low-battery";
text = ''
# Suspend the system when battery level drops to 5% or lower
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${pkgs.systemd}/bin/systemctl hibernate"
'';
destination = "/etc/udev/rules.d/99-hibernate-low-battery.rules";
})
(pkgs.writeTextFile {
name = "on-battery-power-saver";
text = ''
# Switch to power-saver when battery below 50%
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5][0-9]", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver"
'';
destination = "/etc/udev/rules.d/62-power-save-battery.rules";
})
];
};
security.polkit.enable = true;
security.rtkit.enable = true;
security.pam.services.swaylock = { };
security.pam.services.hyprlock = { };
services.xserver.videoDrivers = [
"nvidia"
"modesetting"
];
networking = {
hostName = "eddie";
domain = "local";
nameservers = [
"1.1.1.1"
"1.0.0.1"
];
networkmanager = {
enable = true;
wifi.powersave = true;
# wifi.backend = "iwd";
};
# wireless = {
# iwd = {
# enable = true;
# package = pkgs.iwd;
# settings = {
# IPv6 = {
# enabled = true;
# };
# Settings = {
# AutoConnect = true;
# };
# };
# };
# };
};
services.resolved = {
enable = true;
extraConfig = ''
LLMNR=no
ReadEtcHosts=no
DNSSEC=no
'';
};
# Set your time zone.
time.timeZone = "America/Toronto";
# Select internationalisation properties.
i18n.defaultLocale = "en_CA.UTF-8";
services.xserver.enable = true;
# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.deviceSection = ''Option "TearFree" "true"''; # For amdgpu.
# services.xserver.enableTearFree = true;
services.gnome.gnome-keyring.enable = true;
services.gnome.gnome-settings-daemon.enable = true;
services.picom = {
enable = true;
vSync = true;
};
programs.labwc.enable = true;
programs.ssh.startAgent = true;
programs.nh = {
enable = true;
clean = {
enable = true;
dates = "daily";
extraArgs = "--keep-since 4d --keep 3";
};
flake = "/home/emenel/source/nixos-config";
package = pkgs.nh;
};
programs.dconf.enable = true;
programs.gpaste.enable = true;
programs.xwayland.enable = true;
services.xserver.xkb = {
layout = "us";
variant = "";
};
services.printing = {
enable = true;
drivers = [
pkgs.epson-escpr
pkgs.epson-escpr2
];
};
services.tailscale.enable = true;
services.envfs.enable = true;
services.gnome.sushi.enable = true;
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = [
pkgs.xdg-desktop-portal-gnome
pkgs.xdg-desktop-portal-gtk
pkgs.xdg-desktop-portal
pkgs.xdg-desktop-portal-wlr
pkgs.gnome-keyring
];
};
# Enable sound with pipewire.
services.pulseaudio.enable = false;
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
wireplumber = {
enable = true;
};
extraConfig = {
pipewire."91-null-sinks" = {
"context.modules" = [
{
name = "libpipewire-module-loopback";
args = {
"node.description" = "Default Playback";
"capture.props" = {
"node.name" = "BixSix_or_fallback_Playback";
"media.class" = "Audio/Sink";
"audio.position" = "[FL FR]";
};
"playback.props" = {
"node.name" = "playback.BixSixWithFallbackPlayback";
"audio.position" = "[AUX14 AUX15]";
"target.object" = "alsa_output.usb-Solid_State_Logic_BiG_SiX-00.pro-output-0";
"stream.dont-remix" = true;
"node.passive" = true;
};
};
}
];
};
pipewire."92-low-latency" = {
context.properties = {
default.clock.rate = 48000;
default.clock.quantum = 32;
default.clock.min-quantum = 32;
default.clock.max-quantum = 32;
};
};
pipewire-pulse."92-low-latency" = {
context.modules = [
{
name = "libpipewire-module-protocol-pulse";
args = {
pulse.min.req = "32/48000";
pulse.default.req = "32/48000";
pulse.max.req = "32/48000";
pulse.min.quantum = "32/48000";
pulse.max.quantum = "32/48000";
};
}
];
stream.properties = {
node.latency = "32/48000";
resample.quality = 1;
};
};
pipewire."10-airplay" = {
"context.modules" = [
{
name = "libpipewire-module-raop-discover";
# increase the buffer size if you get dropouts/glitches
# args = {
# "raop.latency.ms" = 500;
# };
}
];
};
};
};
programs.light.enable = true;
programs.steam = {
enable = true;
protontricks.enable = true;
extraCompatPackages = [ pkgs.proton-ge-bin ];
};
# enable fish and launch it from bash for interactive shells
programs.fish.enable = true;
environment.pathsToLink = [ "/share/fish" ];
programs.bash = {
interactiveShellInit = ''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
};
services.flatpak.enable = true;
services.dbus.implementation = "broker";
#programs.gnupg.enable = true;
programs.git.enable = true;
environment.gnome.excludePackages = with pkgs; [
cheese
geary
gnome-music
gnome-tour
];
services.accounts-daemon.enable = true;
services.gnome.gnome-online-accounts.enable = true;
services.kmonad = {
enable = true;
keyboards = {
sinc = {
device = "/dev/input/by-id/usb-Keebio_Sinc_Rev._4-event-kbd";
config = builtins.readFile ../../homes/emenel/dotfiles/dot_config/kmonad/sinc.kbd;
};
razer = {
extraGroups = [ "openrazer" ];
device = "/dev/input/by-id/usb-Razer_Razer_Blade-if01-event-kbd";
config = builtins.readFile ../../homes/emenel/dotfiles/dot_config/kmonad/razer.kbd;
};
};
};
programs.virt-manager.enable = true;
virtualisation = {
libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
};
};
spiceUSBRedirection.enable = true;
};
services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true;
programs.appimage = {
enable = true;
binfmt = true;
package = pkgs.appimage-run.override {
extraPkgs = pkgs: [ pkgs.libxcrypt.out ];
};
};
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
zlib
zstd
stdenv.cc.cc
curlFull
openssl.out
attr
libssh
libxcrypt.out
bzip2
libxml2
acl
libsodium
util-linux
xz
systemd
fontconfig
freetype
gnutls
util-linux
libGL.dev
psutils
egl-wayland
eglexternalplatform
glfw-wayland
glfw
libGLU.dev
libuv.out
libressl.out
libudev-zero.out
];
fonts = {
enableDefaultPackages = true;
fontDir.enable = true;
fontconfig = {
enable = true;
useEmbeddedBitmaps = true;
};
packages = with pkgs; [
fira-code
font-awesome
fira
cooper-hewitt
ibm-plex
jetbrains-mono
iosevka
spleen
fira-code-symbols
powerline-fonts
noto-fonts-color-emoji
noto-fonts
noto-fonts-cjk-sans
noto-fonts-emoji
nerd-fonts.jetbrains-mono
nerd-fonts.fira-code
nerd-fonts._0xproto
nerd-fonts.symbols-only
];
};
powerManagement = {
enable = true;
};
services.power-profiles-daemon = {
enable = true;
package = pkgs.power-profiles-daemon;
};
# enable the OpenSSH daemon.
services.openssh.enable = true;
services.avahi = {
enable = true;
publish.enable = true;
publish.userServices = true;
openFirewall = true;
nssmdns4 = true;
};
services.samba = {
enable = true;
package = pkgs.sambaFull;
openFirewall = true;
};
services.samba-wsdd = {
enable = true;
openFirewall = true;
};
# add user accounts
users.users.emenel = {
isNormalUser = true;
description = "emenel";
extraGroups = [
"networkmanager"
"network"
"wheel"
"uinput"
"uucp"
"dialout"
"input"
"audio"
"video"
"libvirtd"
"nvidia"
"cups"
"openrazer"
"plugdev"
];
packages = with pkgs; [
git
];
};
#do not change
system.stateVersion = "24.05";
}