diff --git a/.config/nixos/laptop/mecca/bg.jpg b/.config/nixos/laptop/mecca/bg.jpg new file mode 100644 index 0000000..c6a4c31 Binary files /dev/null and b/.config/nixos/laptop/mecca/bg.jpg differ diff --git a/.config/nixos/laptop/mecca/configuration.nix b/.config/nixos/laptop/mecca/configuration.nix new file mode 100644 index 0000000..db5d47a --- /dev/null +++ b/.config/nixos/laptop/mecca/configuration.nix @@ -0,0 +1,184 @@ +{ config, lib, pkgs, inputs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ]; + + # Enable automatic system updates + system.autoUpgrade = { + enable = true; + flake = inputs.self.outPath; + flags = [ + "--update-input" + "nixpkgs" + "-L" # print build logs + ]; + dates = "weekly"; + randomizedDelaySec = "45min"; + }; + # Allow non-free software (RMS will be mad at me :<) + nixpkgs.config.allowUnfree = true; + # Enable nix-command and flakes + nix.settings.experimental-features = [ "nix-command" "flakes"]; + + # SystemD-boot is good enough + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + systemd.tpm2.enable = false; + + networking.hostName = "mecca"; # Change for given system + networking.networkmanager.enable = true; + + # Timezone => AST + time.timeZone = "America/St_Thomas"; + + stylix = { + enable = true; + image = ./bg.jpg; + }; + + # Hyprland looks nice so I'm using it + programs.hyprland = { + enable = true; + withUWSM = true; + xwayland.enable = true; + }; + environment.sessionVariables.NIXOS_OZONE_WL = "1"; + xdg.portal.enable = true; + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + + # using piprewire cuz embrace muh modernity + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + services.libinput.enable = true; # for laptop touchpad + + # Laptop battery optimizations + # NOTE: Comment out if on PC/Not required for your rig + services.tlp = { + enable = true; + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 20; + + START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge + STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging + }; + }; + services.auto-cpufreq.enable = true; + services.auto-cpufreq.settings = { + battery = { + governor = "powersave"; + turbo = "never"; + }; + charger = { + governor = "performance"; + turbo = "auto"; + }; + }; + powerManagement.powertop.enable = true; + + # Kanata setup + # Mostly copied from https://dev.to/shanu-kumawat/how-to-set-up-kanata-on-nixos-a-step-by-step-guide-1jkc + boot.kernelModules = [ "uinput" ]; # Enable uinput kernel module + hardware.uinput.enable = true; # Enable uinput + # Set up udev rules for uinput + services.udev.extraRules = '' + KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput" + ''; + users.groups.uinput = { }; # ensure uinput group exists + # Add Kanata service user to necessary groups + systemd.services.kanata-internalKeyboard.serviceConfig = { + SupplementaryGroups = [ + "input" + "uinput" + ]; + }; + # Kanata configuration + services.kanata = { + enable = true; + keyboards = { + internalKeyboard = { + devices = [ + "/dev/input/by-path/platform-i8042-serio-0-event-kbd" + ]; + extraDefCfg = "concurrent-tap-hold yes"; + config = builtins.readFile ./kanata.kbd; + }; + }; + }; + + # Default user account + users.users.lunita = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + packages = with pkgs; [ + tree + ]; + shell = pkgs.zsh; + }; + # Enabling Emacs server + services.emacs = { + enable = true; + package = pkgs.emacs-gtk; + }; + # Enable zsh + programs.zsh.enable = true; + # Going with FF for now. Might switch over to Zen eventually + programs.firefox.enable = true; + # Enable Tailscale for homeserver stuff + services.tailscale.enable = true; + # Enable syncthing for Obsidian & KeePass DB sync across devices + services.syncthing.enable = true; + + environment.systemPackages = with pkgs; [ + home-manager # For using Nix Home Manager + zsh # Default user shell + jq + stow # For dotfiles deployment. May use home-manager in future + fastfetch # Muh epic r1ce!!! + minecraftia # font + jetbrains-mono # font + terminus_font # font + neovim # Terminal text editor + wget # coreutil for some script compatibility + htop # Resource manager + waybar # Status bar + libnotify # Desktop notifications + swww # Wallpaper manager + brightnessctl # For laptop backlight brightness control + grim # screenshot utility + slurp # select utility + wl-clipboard # xclip alternative + rofi-wayland # Dmenu replacement for Wayland + ghostty # Terminal emulator + mpv # Video player + zathura # PDF/CBZ/EPUB/DJVU reader + tmux # Tride and true terminal multiplexer + obsidian # For epic note taking (really just mediocre journaling) + keepassxc # Secure password manager + syncthing # Self explanatory + tailscale # Same as above + ]; + + # Enable OpenSSH SSH Daemon + services.openssh.enable = true; + + # Copy sysconf in case this file is deleted or corrupted + # NOTE: Doesn't work with flakes enabled. + # system.copySystemConfiguration = true; + + system.stateVersion = "25.05"; +} diff --git a/.config/nixos/laptop/mecca/flake.nix b/.config/nixos/laptop/mecca/flake.nix new file mode 100755 index 0000000..fe37ffd --- /dev/null +++ b/.config/nixos/laptop/mecca/flake.nix @@ -0,0 +1,17 @@ +{ + description = "System flake"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + stylix.url = "github:danth/stylix"; + }; + outputs = { self, nixpkgs, ... }@inputs: { + nixosConfigurations.mecca = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./configuration.nix + inputs.stylix.nixosModules.stylix + ]; + }; + }; +} + diff --git a/.config/nixos/laptop/mecca/hardware-configuration.nix b/.config/nixos/laptop/mecca/hardware-configuration.nix new file mode 100644 index 0000000..222db91 --- /dev/null +++ b/.config/nixos/laptop/mecca/hardware-configuration.nix @@ -0,0 +1,41 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9c7f9128-0371-4b7b-b0fb-86aeabe0491a"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/BE22-C08F"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/8380ab37-d79c-4b25-888b-d457596dcfae"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}