Last active
April 23, 2024 09:48
-
-
Save 0x61nas/ce413b0b055b1a2a4add3b21d4ee3807 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is your system's configuration file. | |
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) | |
{ | |
inputs, | |
lib, | |
config, | |
pkgs, | |
... | |
}: { | |
# You can import other NixOS modules here | |
imports = [ | |
# If you want to use modules from other flakes (such as nixos-hardware): | |
# inputs.hardware.nixosModules.common-cpu-amd | |
# inputs.hardware.nixosModules.common-ssd | |
# You can also split up your configuration and import pieces of it here: | |
# ./users.nix | |
# Import your generated (nixos-generate-config) hardware configuration | |
./hardware-configuration.nix | |
]; | |
nixpkgs = { | |
# You can add overlays here | |
overlays = [ | |
# If you want to use overlays exported from other flakes: | |
# neovim-nightly-overlay.overlays.default | |
# Or define it inline, for example: | |
# (final: prev: { | |
# hi = final.hello.overrideAttrs (oldAttrs: { | |
# patches = [ ./change-hello-to-hi.patch ]; | |
# }); | |
# }) | |
]; | |
# Configure your nixpkgs instance | |
config = { | |
allowUnfree = true; | |
}; | |
}; | |
# This will add each flake input as a registry | |
# To make nix3 commands consistent with your flake | |
# nix.registry = (lib.mapAttrs (_: flake: {inherit flake;})) ((lib.filterAttrs (_: lib.isType "flake")) inputs); | |
# This will additionally add your inputs to the system's legacy channels | |
# Making legacy nix commands consistent as well, awesome! | |
# nix.nixPath = ["/etc/nix/path"]; | |
# environment.etc = | |
# lib.mapAttrs' | |
# (name: value: { | |
# name = "nix/path/${name}"; | |
# value.source = value.flake; | |
# }) | |
# config.nix.registry; | |
nix.settings = { | |
# Enable flakes and new 'nix' command | |
experimental-features = "nix-command flakes"; | |
# Deduplicate and optimize nix store | |
auto-optimise-store = true; | |
}; | |
# FIXME: Add the rest of your current configuration | |
networking.hostName = "y540"; | |
boot.loader.systemd-boot.enable = true; | |
networking.networkmanager.enable = true; | |
# she was sudo girl, ama doas boy :( | |
security.doas.enable = true; | |
security.sudo.enable = false; | |
security.doas.extraRules = [{ | |
users = ["anas"]; | |
# Optional, retains environment variables while running commands | |
# e.g. retains your NIX_PATH when applying your config | |
keepEnv = true; | |
persist = true; # Optional, only require password verification a single time | |
}]; | |
# Swap on NixOS is set with the option swapDevices on /etc/nixos/hardware-configuration.nix. | |
swapDevices = [ { | |
device = "/var/lib/swapfile"; | |
size = 16*1024; | |
} ]; | |
# Thunar | |
programs.thunar.enable = true; | |
# Touchpad | |
# The driver has many options (see: https://nixos.org/manual/nixos/stable/options). | |
services.xserver.libinput.enable = true; | |
# Proprietary NVIDIA drivers | |
services.xserver.videoDrivers = [ "nvidia" ]; | |
# Enable OpenGL | |
hardware.opengl = { | |
enable = true; | |
driSupport = true; | |
driSupport32Bit = true; | |
}; | |
# Load nvidia driver for Xorg and Wayland | |
services.xserver.videoDrivers = ["nvidia"]; | |
hardware.nvidia = { | |
# Modesetting is required. | |
modesetting.enable = true; | |
# Nvidia power management. Experimental, and can cause sleep/suspend to fail. | |
# Enable this if you have graphical corruption issues or application crashes after waking | |
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead | |
# of just the bare essentials. | |
powerManagement.enable = false; | |
# Fine-grained power management. Turns off GPU when not in use. | |
# Experimental and only works on modern Nvidia GPUs (Turing or newer). | |
powerManagement.finegrained = false; | |
# Use the NVidia open source kernel module (not to be confused with the | |
# independent third-party "nouveau" open source driver). | |
# Support is limited to the Turing and later architectures. Full list of | |
# supported GPUs is at: | |
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus | |
# Only available from driver 515.43.04+ | |
# Currently alpha-quality/buggy, so false is currently the recommended setting. | |
open = false; | |
# Enable the Nvidia settings menu, | |
# accessible via `nvidia-settings`. | |
nvidiaSettings = true; | |
# Optionally, you may need to select the appropriate driver version for your specific GPU. | |
package = config.boot.kernelPackages.nvidiaPackages.stable; | |
}; | |
# hardware.nvidia.prime = { | |
# # Make sure to use the correct Bus ID values for your system! | |
# intelBusId = "PCI:0:2:0"; | |
# nvidiaBusId = "PCI:14:0:0"; | |
# }; | |
# X11 | |
# services.xserver.enable = true; | |
# services.xserver.xkb.layout = "us"; | |
# services.xserver.xkb.variant = "dvorak-l"; | |
# services.xserver.windowManager.dwm.enable = true; | |
# services.xserver.windowManager.dwm.package = pkgs.dwm.overrideAttrs { | |
# src = pkgs.fetchFromGitHub { | |
# owner = "archy-linux"; | |
# repo = "archy-dwm"; | |
# rev = "aurora"; | |
# }; | |
# }; | |
services.xserver = { | |
layout = "us,ara"; | |
xkbVariant = "dvorak-l,"; | |
xkbOptions = "grp:win_space_toggle caps:swapescape keypad:pointerkeys"; | |
}; | |
programs.hyprland = { | |
# Install the packages from nixpkgs | |
enable = true; | |
xwayland.enable = true; | |
# Optional, hint electron apps to use wayland: | |
environment.sessionVariables.NIXOS_OZONE_WL = "1"; | |
}; | |
# Fonts | |
fonts.packages = with pkgs; [ | |
noto-fonts | |
noto-fonts-cjk | |
noto-fonts-emoji | |
liberation_ttf | |
fira-code | |
fira-code-symbols | |
mplus-outline-fonts.githubRelease | |
dina-font | |
proggyfonts | |
]; | |
# Terminal Emulator | |
programs.foot.enable = true; | |
programs.foot.settings = { | |
main = { | |
term = "xterm-256color"; | |
font = "Fira Code:size=11"; | |
dpi-aware = "yes"; | |
}; | |
mouse = { | |
hide-when-typing = "yes"; | |
}; | |
} | |
# TODO: Configure your system-wide user settings (groups, etc), add more users as needed. | |
users.users = { | |
anas = { | |
# TODO: You can set an initial password for your user. | |
# If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. | |
# Be sure to change it (using passwd) after rebooting! | |
initialPassword = "kill me plz"; | |
isNormalUser = true; | |
openssh.authorizedKeys.keys = [ | |
# TODO: Add your SSH public key(s) here, if you plan on using SSH to connect | |
]; | |
# TODO: Be sure to add any other groups you need (such as networkmanager, audio, docker, etc) | |
extraGroups = ["wheel" "audio" "video" "docker"]; | |
}; | |
}; | |
environment.systemPackages = with pkgs; [ | |
neovim | |
docker | |
git | |
gnumake | |
tmux | |
btop | |
wget | |
neofetch | |
nvtop | |
]; | |
environment.shells = with pkgs; [ zsh ]; | |
environment.variables = { | |
EDITOR = "nvim"; | |
TERMINAL = "foot"; | |
PAGER = "less"; | |
SUDO = "doas"; | |
BROWSER="firefox"; | |
NAME = "Anas Elgarhy"; | |
USERNAME = "0x61nas"; | |
EMAIL = "[email protected]"; | |
# Globals | |
TZ = "Africa/Cairo"; | |
# make less better | |
# X = leave content on-screen | |
# F = quit automatically if less than one screenfull | |
# R = raw terminal characters (fixes git diff) | |
# see http://jugglingbits.wordpress.com/2010/03/24/a-better-less-playing-nice-with-git/ | |
LESS = "-F -X -R"; | |
# Rust stuff | |
CARGO_INCREMENTAL = "1"; | |
RUSTFLAGS = "-C target-cpu=native"; | |
RUST_BACKTRACE = "1"; | |
}; | |
# This setups a SSH server. Very important if you're setting up a headless system. | |
# Feel free to remove if you don't need it. | |
services.openssh = { | |
enable = true; | |
settings = { | |
# Forbid root login through SSH. | |
PermitRootLogin = "no"; | |
# Use keys only. Remove if you want to SSH using password (not recommended) | |
PasswordAuthentication = false; | |
}; | |
}; | |
# TLP | |
services.tlp = { | |
enable = true; | |
settings = { | |
CPU_SCALING_GOVERNOR_ON_AC = "performance"; | |
CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; | |
CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; | |
CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; | |
CPU_MIN_PERF_ON_AC = 0; | |
CPU_MAX_PERF_ON_AC = 100; | |
CPU_MIN_PERF_ON_BAT = 0; | |
CPU_MAX_PERF_ON_BAT = 20; | |
#Optional helps save long term battery health | |
START_CHARGE_THRESH_BAT0 = 40; # 40 and bellow it starts to charge | |
STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging | |
}; | |
}; | |
# Thermald proactively prevents overheating on Intel CPUs and works well with other tools. | |
services.thermald.enable = true; | |
powerManagement.enable = true; | |
# Firewall | |
networking.firewall.enable = true; | |
networking.firewall.allowPing = false; | |
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion | |
system.stateVersion = "23.05"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment