diff --git a/.config/linux/nix/AmdGpu.nix b/.config/linux/nix/AmdGpu.nix new file mode 100644 index 0000000..50a42bf --- /dev/null +++ b/.config/linux/nix/AmdGpu.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + boot.initrd.kernelModules = [ "amdgpu" ]; + services.xserver.videoDrivers = [ "amdgpu" ]; + hardware.opengl.extraPackages = with pkgs; [ + amdvlk + ]; +} diff --git a/.config/linux/nix/Common.nix b/.config/linux/nix/Common.nix new file mode 100644 index 0000000..67232d9 --- /dev/null +++ b/.config/linux/nix/Common.nix @@ -0,0 +1,64 @@ +# Help: man configuration.nix or https://nixos.org/nixos/options.html + +{ config, pkgs, ... }: + +{ + # System packages. + environment.systemPackages = with pkgs; [ + android-tools + appimage-run + binwalk + btop + ddrescue + git + jdk11 + jdk19 + lm_sensors + lshw + gnumake + lsof + ncdu + neovim + nmap + parallel + pv + ripgrep + scanmem + smartmontools + steam-run + sqlite + testdisk + tmux + virt-manager + wget + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Network. + networking.networkmanager.enable = true; + + # Firewall. + networking.firewall.enable = false; + + # Locale. + time.timeZone = "Europe/Moscow"; + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "ru_RU.UTF-8"; + LC_IDENTIFICATION = "ru_RU.UTF-8"; + LC_MEASUREMENT = "ru_RU.UTF-8"; + LC_MONETARY = "ru_RU.UTF-8"; + LC_NAME = "ru_RU.UTF-8"; + LC_NUMERIC = "ru_RU.UTF-8"; + LC_PAPER = "ru_RU.UTF-8"; + LC_TELEPHONE = "ru_RU.UTF-8"; + LC_TIME = "ru_RU.UTF-8"; + }; + + # Nix. + nixpkgs.config.allowUnfree = true; + nix.settings.auto-optimise-store = true; +} diff --git a/.config/linux/nix/Docker.nix b/.config/linux/nix/Docker.nix new file mode 100644 index 0000000..9070f88 --- /dev/null +++ b/.config/linux/nix/Docker.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + virtualisation.docker.enable = true; +} diff --git a/.config/linux/nix/DockerRootless.nix b/.config/linux/nix/DockerRootless.nix new file mode 100644 index 0000000..c8a7803 --- /dev/null +++ b/.config/linux/nix/DockerRootless.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + virtualisation.docker.enable = true; + virtualisation.docker.rootless = { + enable = true; + setSocketVariable = true; + }; +} diff --git a/.config/linux/nix/Flatpak.nix b/.config/linux/nix/Flatpak.nix new file mode 100644 index 0000000..6b82127 --- /dev/null +++ b/.config/linux/nix/Flatpak.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + services.flatpak.enable = true; +} diff --git a/.config/linux/nix/Gnome.nix b/.config/linux/nix/Gnome.nix new file mode 100644 index 0000000..59e11ce --- /dev/null +++ b/.config/linux/nix/Gnome.nix @@ -0,0 +1,23 @@ +{ ... }: + +{ + # GUI. + services.xserver.enable = true; + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; + + # Sound. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; +} diff --git a/.config/linux/nix/PowersaveAmd.nix b/.config/linux/nix/PowersaveAmd.nix new file mode 100644 index 0000000..31fb01a --- /dev/null +++ b/.config/linux/nix/PowersaveAmd.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: + +{ + systemd.services.powersave = { + enable = true; + description = "AMD Disable Boost"; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "yes"; + ExecStart = "${pkgs.bash}/bin/bash -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'"; + ExecStop = "${pkgs.bash}/bin/bash -c 'echo 1 > /sys/devices/system/cpu/cpufreq/boost'"; + }; + wantedBy = [ "multi-user.target" ]; + }; +} diff --git a/.config/linux/nix/PowersaveIntel.nix b/.config/linux/nix/PowersaveIntel.nix new file mode 100644 index 0000000..5c90ff2 --- /dev/null +++ b/.config/linux/nix/PowersaveIntel.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: + +{ + systemd.services.powersave = { + enable = true; + description = "Intel Disable Boost"; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "yes"; + ExecStart = "${pkgs.bash}/bin/bash -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'"; + ExecStop = "${pkgs.bash}/bin/bash -c 'echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo'"; + }; + wantedBy = [ "multi-user.target" ]; + }; +} diff --git a/.config/linux/nix/Print.nix b/.config/linux/nix/Print.nix new file mode 100644 index 0000000..85c4e76 --- /dev/null +++ b/.config/linux/nix/Print.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + services.printing = { + enable = true; + clientConf = '' + DigestOptions DenyMD5 + ServerName 192.168.1.2 + ''; + }; +} diff --git a/.config/linux/nix/Sshd.nix b/.config/linux/nix/Sshd.nix new file mode 100644 index 0000000..a3c5698 --- /dev/null +++ b/.config/linux/nix/Sshd.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + services.openssh.enable = true; +} diff --git a/.config/linux/nix/Voronind.nix b/.config/linux/nix/Voronind.nix new file mode 100644 index 0000000..11551a7 --- /dev/null +++ b/.config/linux/nix/Voronind.nix @@ -0,0 +1,12 @@ +{ ... }: + +{ + users.users.voronind = { + isNormalUser = true; + description = "Dmitry Voronin"; + extraGroups = [ "networkmanager" ]; + packages = with pkgs; [ + gnome.gnome-tweaks + ]; + }; +} diff --git a/.config/linux/nix/desktop/configuration.nix b/.config/linux/nix/desktop/configuration.nix index 3e6d9fb..198dc8e 100644 --- a/.config/linux/nix/desktop/configuration.nix +++ b/.config/linux/nix/desktop/configuration.nix @@ -1,134 +1,20 @@ { config, pkgs, ... }: -# Help: man configuration.nix or https://nixos.org/nixos/options.html { imports = [ ./hardware-configuration.nix + ../Common.nix + ../PowersaveAmd.nix + ../Print.nix + ../Gnome.nix + ../Voronind.nix + ../Flatpak.nix + ../DockerRootless.nix ]; - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.initrd.kernelModules = [ "amdgpu" ]; - # Network. - networking.networkmanager.enable = true; networking.hostName = "desktop"; - # Locale. - time.timeZone = "Europe/Moscow"; - i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "ru_RU.UTF-8"; - LC_IDENTIFICATION = "ru_RU.UTF-8"; - LC_MEASUREMENT = "ru_RU.UTF-8"; - LC_MONETARY = "ru_RU.UTF-8"; - LC_NAME = "ru_RU.UTF-8"; - LC_NUMERIC = "ru_RU.UTF-8"; - LC_PAPER = "ru_RU.UTF-8"; - LC_TELEPHONE = "ru_RU.UTF-8"; - LC_TIME = "ru_RU.UTF-8"; - }; - - # GUI. - services.xserver.enable = true; - services.xserver.videoDrivers = [ "amdgpu" ]; - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; - hardware.opengl.extraPackages = with pkgs; [ - amdvlk - ]; - - # Printing. - services.printing = { - enable = true; - clientConf = '' - DigestOptions DenyMD5 - ServerName 192.168.1.2 - ''; - }; - - # Sound. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - }; - - # User. - users.users.voronind = { - isNormalUser = true; - description = "Dmitry Voronin"; - extraGroups = [ "networkmanager" ]; - packages = with pkgs; [ - gnome.gnome-tweaks - ]; - }; - - # Flatpak. - services.flatpak.enable = true; - - # System packages. - environment.systemPackages = with pkgs; [ - android-tools - appimage-run - binwalk - btop - ddrescue - git - jdk11 - jdk19 - lm_sensors - lshw - gnumake - lsof - ncdu - neovim - nmap - parallel - pv - ripgrep - scanmem - smartmontools - steam-run - sqlite - testdisk - tmux - virt-manager - wget - ]; - - # Docker. - virtualisation.docker.enable = true; - # users.extraGroups.docker.members = [ "voronind" ]; - virtualisation.docker.rootless = { - enable = true; - setSocketVariable = true; - }; - - # Systemd. - systemd.services.powersave = { - enable = true; - description = "AMD Disable Boost"; - unitConfig = { - Type = "simple"; - }; - serviceConfig = { - RemainAfterExit = "yes"; - ExecStart = "${pkgs.bash}/bin/bash -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'"; - ExecStop = "${pkgs.bash}/bin/bash -c 'echo 1 > /sys/devices/system/cpu/cpufreq/boost'"; - }; - wantedBy = [ "multi-user.target" ]; - }; - # Filesystems. fileSystems."/storage/hot" = { device = "/dev/storage/hot"; @@ -148,16 +34,6 @@ options = [ "noauto" "nofail" ]; }; - # Openssh server. - services.openssh.enable = false; - - # Firewall. - networking.firewall.enable = false; - - # Nix. - nixpkgs.config.allowUnfree = true; - nix.settings.auto-optimise-store = true; - # Do not touch ever. system.stateVersion = "23.11"; }