diff --git a/configuration.nix b/configuration.nix index 1dc5c6d..2eb9785 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,195 +1,26 @@ -# 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'). - +# NixOS Configuration +# Main entry point - imports modular configuration files { config, pkgs, lib, ... }: { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - # boot.loader.systemd-boot.enable = true; #Disabled for GRUB - boot.loader.efi.canTouchEfiVariables = true; - - # Grub - boot.loader.grub.enable = true; - boot.loader.grub.device = "nodev"; - boot.loader.grub.efiSupport = true; - # boot.loader.grub.useOSProber = true; - # boot.loader.grub.extraConfig = "GRUB_DISABLE_OS_PROBER=false"; - boot.loader.grub.extraEntries = '' - menuentry "Arch Linux (zen)" { - search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d - linux /@/boot/vmlinuz-linux-zen root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw - initrd /@/boot/initramfs-linux-zen.img - } - - menuentry "Arch Linux (default)" { - search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d - linux /@/boot/vmlinuz-linux root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw - initrd /@/boot/initramfs-linux.img - } - - menuentry "Arch Linux (lts)" { - search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d - linux /@/boot/vmlinuz-linux-lts root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw - initrd /@/boot/initramfs-linux-lts.img - } - ''; - - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "Europe/Tallinn"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_IN"; - LC_IDENTIFICATION = "en_IN"; - LC_MEASUREMENT = "en_IN"; - LC_MONETARY = "en_IN"; - LC_NAME = "en_IN"; - LC_NUMERIC = "en_IN"; - LC_PAPER = "en_IN"; - LC_TELEPHONE = "en_IN"; - LC_TIME = "en_IN"; - }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver.xkb = { - layout = "us"; - variant = ""; - }; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - services.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with 'passwd'. - users.users.asxpi = { - isNormalUser = true; - description = "Sergei P"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - # Internet - thunderbird - telegram-desktop - firefox-devedition - # Code - zed-editor - ]; - }; - - # Set GPG_TTY for all users - environment.shellInit = '' - export GPG_TTY=$(tty) - ''; - - # Install firefox. - # programs.firefox.enable = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - os-prober - nano - git - btrfs-progs - curl - wget - htop - fastfetch - nodejs_20 - gnupg + imports = [ + ./hardware-configuration.nix + ./modules/boot.nix + ./modules/networking.nix + ./modules/locale.nix + ./modules/desktop.nix + ./modules/users.nix + ./modules/packages.nix + ./modules/shell.nix + ./modules/programs.nix + ./modules/wireguard.nix ]; - # Create a wrapper script for nixos-rebuild - environment.shellAliases = { - nrs = ''export GPG_TTY=$(tty) && sudo nixos-rebuild switch && cd /etc/nixos && git add -A && git commit -S -m "Update: $(date +%Y-%m-%d_%H:%M)" || true && git push origin main''; - }; - - environment.etc."gitconfig".text = '' - [user] - name = Sergei Poljanski - email = me@asxp.io - signingkey = 4F8851660FA4121B - [commit] - gpgsign = true - [init] - defaultBranch = main - [safe] - directory = /etc/nixos - ''; - - # Enable flakes - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryPackage = pkgs.pinentry-curses; - }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It's perfectly fine and recommended to leave # this value at the release version of the first install of this system. # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "25.11"; # Did you read the comment? - + system.stateVersion = "25.11"; } diff --git a/flake.nix b/flake.nix index 22f27dd..7ff535d 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ }; outputs = { self, nixpkgs, claude-code-nix, ... }@inputs: { - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + nixosConfigurations.meow = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ diff --git a/modules/boot.nix b/modules/boot.nix new file mode 100644 index 0000000..1adccd6 --- /dev/null +++ b/modules/boot.nix @@ -0,0 +1,35 @@ +# Bootloader and GRUB configuration +{ config, pkgs, lib, ... }: + +{ + # boot.loader.systemd-boot.enable = true; # Disabled for GRUB + boot.loader.efi.canTouchEfiVariables = true; + + # GRUB bootloader + boot.loader.grub = { + enable = true; + device = "nodev"; + efiSupport = true; + # useOSProber = true; + # extraConfig = "GRUB_DISABLE_OS_PROBER=false"; + extraEntries = '' + menuentry "Arch Linux (zen)" { + search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d + linux /@/boot/vmlinuz-linux-zen root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw + initrd /@/boot/initramfs-linux-zen.img + } + + menuentry "Arch Linux (default)" { + search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d + linux /@/boot/vmlinuz-linux root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw + initrd /@/boot/initramfs-linux.img + } + + menuentry "Arch Linux (lts)" { + search --set=root --fs-uuid 15ae8384-3dfc-4915-9201-66ecfc5f230d + linux /@/boot/vmlinuz-linux-lts root=UUID=15ae8384-3dfc-4915-9201-66ecfc5f230d rootflags=subvol=@ rw + initrd /@/boot/initramfs-linux-lts.img + } + ''; + }; +} diff --git a/modules/desktop.nix b/modules/desktop.nix new file mode 100644 index 0000000..3ca093f --- /dev/null +++ b/modules/desktop.nix @@ -0,0 +1,36 @@ +# Desktop environment, display, and audio configuration +{ config, pkgs, lib, ... }: + +{ + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.displayManager.gdm.enable = true; + services.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us,ru"; + variant = ""; + options = "grp:alt_shift_toggle"; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + # jack.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; +} diff --git a/modules/locale.nix b/modules/locale.nix new file mode 100644 index 0000000..26bd528 --- /dev/null +++ b/modules/locale.nix @@ -0,0 +1,22 @@ +# Timezone and locale configuration +{ config, pkgs, lib, ... }: + +{ + # Set your time zone. + time.timeZone = "Europe/Tallinn"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_IN"; + LC_IDENTIFICATION = "en_IN"; + LC_MEASUREMENT = "en_IN"; + LC_MONETARY = "en_IN"; + LC_NAME = "en_IN"; + LC_NUMERIC = "en_IN"; + LC_PAPER = "en_IN"; + LC_TELEPHONE = "en_IN"; + LC_TIME = "en_IN"; + }; +} diff --git a/modules/networking.nix b/modules/networking.nix new file mode 100644 index 0000000..96db55a --- /dev/null +++ b/modules/networking.nix @@ -0,0 +1,37 @@ +# Networking and WWAN modem configuration +{ config, pkgs, lib, ... }: + +{ + networking.hostName = "meow"; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Fibocom EM120R-GL WWAN Modem Support + # FCC unlock for Quectel EM120R-GL + networking.modemmanager.fccUnlockScripts = [ + { + id = "1eac:1001"; + path = "${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/1eac:1001"; + } + ]; + + # udev rules for WWAN devices + services.udev.extraRules = '' + KERNEL=="wwan*mbim*", MODE="0660", GROUP="dialout" + KERNEL=="wwan*qcdm*", MODE="0660", GROUP="dialout" + KERNEL=="wwan*at*", MODE="0660", GROUP="dialout" + KERNEL=="cdc-wdm*", MODE="0660", GROUP="dialout" + ''; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; +} diff --git a/modules/packages.nix b/modules/packages.nix new file mode 100644 index 0000000..3bc0a1f --- /dev/null +++ b/modules/packages.nix @@ -0,0 +1,62 @@ +# System packages configuration +{ config, pkgs, lib, ... }: + +{ + # Allow unfree packages + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "castlabs-electron" + "tidal-hifi" + "discord-ptb" + ]; + + # List packages installed in system profile. + environment.systemPackages = with pkgs; [ + # Core utilities + nano + git + curl + wget + htop + fastfetch + ncdu + file + tree + unzip + zip + rsync + + # Modern CLI replacements + ripgrep # rg - faster grep + fd # faster find + bat # better cat with syntax highlighting + eza # better ls (exa replacement) + duf # better df + jq # JSON processor + + # Hardware & system info + pciutils # lspci + usbutils # lsusb + lsof # list open files + iotop # disk I/O monitor + + # Networking tools + net-tools # netstat, ifconfig (legacy) + iproute2 # ss, ip (modern) + dnsutils # dig, nslookup + traceroute + nmap # network scanner + + # Filesystem + os-prober + btrfs-progs + + # Development + nodejs_20 + gnupg + + # WWAN modem tools + libmbim + libqmi + modemmanager + ]; +} diff --git a/modules/programs.nix b/modules/programs.nix new file mode 100644 index 0000000..f4d4283 --- /dev/null +++ b/modules/programs.nix @@ -0,0 +1,31 @@ +# Programs and services configuration +{ config, pkgs, lib, ... }: + +{ + # GPG agent + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryPackage = pkgs.pinentry-curses; + }; + + # Git configuration + environment.etc."gitconfig".text = '' + [user] + name = Sergei Poljanski + email = me@asxp.io + signingkey = 4F8851660FA4121B + [commit] + gpgsign = true + [init] + defaultBranch = main + [safe] + directory = /etc/nixos + ''; + + # Enable flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; +} diff --git a/modules/shell.nix b/modules/shell.nix new file mode 100644 index 0000000..a950056 --- /dev/null +++ b/modules/shell.nix @@ -0,0 +1,82 @@ +# Zsh and shell configuration +{ config, pkgs, lib, ... }: + +{ + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + + # History settings + histSize = 10000; + histFile = "$HOME/.zsh_history"; + + # Shell aliases + shellAliases = { + ls = "ls --color=auto"; + grep = "grep --color=auto"; + claude = "$HOME/.claude/local/claude"; + }; + + # Prompt configuration + promptInit = '' + # Blue colored prompt: [HH:MM:SS] [user@host path] $ + PROMPT='%B%F{#0055ff}[%b%f%D{%H:%M:%S}%B%F{#0055ff}]%b%f %B%F{#0055ff}[%b%f%n@%m %B%F{#0055ff}%~]%b%f %B%F{#0055ff}$%b%f ' + ''; + + interactiveShellInit = '' + # History options + setopt SHARE_HISTORY + setopt HIST_IGNORE_DUPS + setopt HIST_IGNORE_ALL_DUPS + bindkey -e + + # Enhanced completion settings + zstyle ':completion:*' menu select + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' + zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}" + zstyle ':completion:*' rehash true + + # Key bindings for navigation + bindkey "^[[H" beginning-of-line # Home + bindkey "^[[F" end-of-line # End + bindkey "^[[3~" delete-char # Delete + bindkey "^[[1;5C" forward-word # Ctrl+Right + bindkey "^[[1;5D" backward-word # Ctrl+Left + bindkey '^R' history-incremental-search-backward + + # Autosuggestions color + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + + # Environment variables + export GOPATH=$HOME/.go + export PATH=$PATH:$GOPATH/bin + export PATH=$HOME/.local/bin:$PATH + export PATH=$HOME/.opencode/bin:$PATH + + # Google Cloud SDK (if exists) + if [ -f "$HOME/Code/gke/google-cloud-sdk/path.zsh.inc" ]; then + source "$HOME/Code/gke/google-cloud-sdk/path.zsh.inc" + fi + if [ -f "$HOME/Code/gke/google-cloud-sdk/completion.zsh.inc" ]; then + source "$HOME/Code/gke/google-cloud-sdk/completion.zsh.inc" + fi + + # NVM (if you need it - consider using nixpkgs nodejs instead) + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" + ''; + }; + + # Set GPG_TTY for all users + environment.shellInit = '' + export GPG_TTY=$(tty) + ''; + + # Shell aliases (available in all shells) + environment.shellAliases = { + nrs = ''export GPG_TTY=$(tty) && sudo nixos-rebuild switch && cd /etc/nixos && git add -A && git commit -S -m "Update: $(date +%Y-%m-%d_%H:%M)" || true && git push origin main''; + }; +} diff --git a/modules/users.nix b/modules/users.nix new file mode 100644 index 0000000..422acfa --- /dev/null +++ b/modules/users.nix @@ -0,0 +1,24 @@ +# User accounts configuration +{ config, pkgs, lib, ... }: + +{ + # Define a user account. Don't forget to set a password with 'passwd'. + users.users.asxpi = { + isNormalUser = true; + description = "Sergei P"; + extraGroups = [ "networkmanager" "wheel" "dialout" ]; + shell = pkgs.zsh; + packages = with pkgs; [ + # Internet + thunderbird + telegram-desktop + firefox-devedition + # Music + tidal-hifi + # Discord + discord-ptb + # Code + zed-editor + ]; + }; +} diff --git a/modules/wireguard.nix b/modules/wireguard.nix new file mode 100644 index 0000000..0786975 --- /dev/null +++ b/modules/wireguard.nix @@ -0,0 +1,16 @@ +# WireGuard VPN configuration +{ config, pkgs, lib, ... }: + +{ + environment.systemPackages = with pkgs; [ + wireguard-tools + ]; + + # WireGuard interface + networking.wg-quick.interfaces = { + wg0 = { + configFile = "/etc/wireguard/wg0.conf"; # TODO: Secret Manager. TODO: Add SSH, GPG as well to secret manager + autostart = true; + }; + }; +}