diff --git a/common.nix b/common.nix index 48e228f..9c64bde 100644 --- a/common.nix +++ b/common.nix @@ -1,32 +1,16 @@ { config, lib, pkgs, ... }: { time.timeZone = "Asia/Chita"; - system.stateVersion = "26.05"; + system.stateVersion = "26.11"; imports = [ ./mods/pxeboot.nix ]; i18n.defaultLocale = "ru_RU.UTF-8"; swapDevices = [ { device = "/var/swapfile"; } ]; users.users.root.hashedPasswordFile = "/secrets/user/root-pw"; nix.settings.experimental-features = [ "nix-command" "flakes" ]; - console = { - font = "cyr-sun16"; - keyMap = "ruwin_alt_sh-UTF-8"; - }; - environment.systemPackages = with pkgs; [ - jq _7zz sbctl - openssl grub2_efi - ]; - fileSystems = let - noatime.options = [ "noatime" ]; - in { - "/" = noatime; - "/boot" = noatime; - }; - services = { - logind.settings.Login.HandleLidSwitch = "ignore"; - openssh = { - enable = true; - settings.PasswordAuthentication = false; - }; + environment.systemPackages = with pkgs; [ jq _7zz sbctl openssl ]; + fileSystems = { + "/".options = [ "noatime" ]; + "/boot".options = [ "noatime" ]; }; systemd.tmpfiles.rules = [ "d /root/backup" @@ -45,16 +29,26 @@ panicOnChecksumMismatch = true; }; }; - networking = { - firewall = { - allowedTCPPorts = [ 53 80 2049 ]; - allowedUDPPorts = [ 53 67 69 547 ]; - }; - nat = { + services = { + logind.settings.Login.HandleLidSwitch = "ignore"; + openssh = { enable = true; - enableIPv6 = true; - internalInterfaces = [ "enp1s0" ]; + settings.PasswordAuthentication = false; }; + dnsmasq = { + enable = true; + settings = { + enable-ra = true; + no-resolv = true; + cache-size = 4096; + bogus-priv = true; + domain-needed = true; + server = [ "1.1.1.2" "2606:4700:4700::1112" + "1.0.0.2" "2606:4700:4700::1002" ]; + }; + }; + }; + networking = { wg-quick.interfaces.awg0 = { type = "amneziawg"; peers = [ { @@ -66,35 +60,19 @@ enable = true; ensureProfiles = { environmentFiles = [ "/secrets/wifi.env" ]; - profiles = { - ethernet = { - ipv6 = { - method = "manual"; - addresses = "fc02::1/64"; - }; - ipv4 = { - method = "manual"; - addresses = "10.2.0.1/16"; - }; - connection = { - id = "ethernet"; - type = "802-3-ethernet"; - }; + profiles.wifi = { + wifi-security.key-mgmt = "sae"; + ipv6 = { + method = "manual"; + gateway = "fc01::1"; }; - wifi = { - wifi-security.key-mgmt = "sae"; - ipv6 = { - method = "manual"; - gateway = "fc01::1"; - }; - ipv4 = { - method = "manual"; - gateway = "10.1.0.1"; - }; - connection = { - id = "wifi"; - type = "802-11-wireless"; - }; + ipv4 = { + method = "manual"; + gateway = "10.1.0.1"; + }; + connection = { + id = "wifi"; + type = "802-11-wireless"; }; }; }; diff --git a/desktop/configuration.nix b/desktop/configuration.nix index 5865f22..420047e 100644 --- a/desktop/configuration.nix +++ b/desktop/configuration.nix @@ -1,18 +1,11 @@ { config, lib, pkgs, ... }: { imports = [ ../common.nix ./hardware.nix ]; - users.users = { - data = { - uid = 1256; - isNormalUser = true; - hashedPasswordFile = "/secrets/user/data-pw"; - }; - bogale = { - uid = 1551; - isNormalUser = true; - extraGroups = [ "wheel" ]; - hashedPasswordFile = "/secrets/user/bogale-pw"; - }; + users.users.bogale = { + uid = 1551; + isNormalUser = true; + extraGroups = [ "wheel" ]; + hashedPasswordFile = "/secrets/user/bogale-pw"; }; networking = { hostName = "nixos-desktop"; @@ -27,4 +20,9 @@ wifi-security.psk = "$BOGALE_5_PSK"; }; }; + programs.niri.enable = true; + services.pipewire = { + enable = true; + pulse.enable = true; + }; } diff --git a/desktop/hardware.nix b/desktop/hardware.nix new file mode 100644 index 0000000..7af382a --- /dev/null +++ b/desktop/hardware.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, modulesPath, ... }: +{ + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + boot = { + kernelModules = [ "kvm-amd" ]; + initrd = { + luks.devices.root.device = "/dev/disk/by-uuid/70ac6613-2e6c-4817-a0ce-43a97efb8bab"; + availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_usb_sdmmc" ]; + }; + }; + fileSystems = { + "/" = { + fsType = "ext4"; + device = "/dev/mapper/root"; + }; + "/boot" = { + fsType = "vfat"; + device = "/dev/disk/by-uuid/2610-A769"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + }; +} diff --git a/flake.nix b/flake.nix index f376312..4ee6436 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,6 @@ useUserPackages = true; extraSpecialArgs = { inherit inputs; }; users = { - data = ./home/data.nix; root = ./home/root.nix; bogale = ./home/bogale.nix; }; diff --git a/home/bogale.nix b/home/bogale.nix index 70ec97a..7831ffb 100644 --- a/home/bogale.nix +++ b/home/bogale.nix @@ -1,8 +1,110 @@ { config, pkgs, ... }: { imports = [ ./common.nix ]; + programs.alacritty.enable = true; + gtk = { + enable = true; + colorScheme = "dark"; + }; home = { username = "bogale"; homeDirectory = "/home/bogale"; + packages = with pkgs; [ bibata-cursors brave-origin ]; + #pointerCursor = { + #enable = true; + #gtk.enable = true; + #x11.enable = true; + #name = "Vanilla-DMZ"; + #package = pkgs.vanilla-dmz; + #}; + }; + wayland.windowManager.niri = { + enable = true; + settings = { + gestures.hot-corners.off = {}; + binds."Mod+T".spawn = "alacritty"; + hotkey-overlay.skip-at-startup = {}; + screenshot-path = "~/Multimedia/Screenshots/%Y-%m-%d_%H-%M-%S.png"; + cursor = { + xcursor-size = 24; + xcursor-theme = "Bibata-Modern-Amber"; + }; + layout = { + center-focused-column = "always"; + default-column-width.proportion = 0.8; + }; + window-rule = { + open-floating = false; + clip-to-geometry = true; + geometry-corner-radius = 20; + }; + input = { + touchpad = { + dwt = {}; + tap = {}; + natural-scroll = {}; + }; + keyboard = { + numlock = {}; + xkb = { + layout = "us,ru"; + options = "grp:alt_shift_toggle"; + }; + }; + }; + binds = { + "Print".screenshot = {}; + "Mod+Q".close-window = {}; + "Mod+F".maximize-column = {}; + "Mod+O".toggle-overview = {}; + "Mod+H".focus-column-left = {}; + "Mod+L".focus-column-right = {}; + "Alt+Print".screenshot-window = {}; + "Ctrl+Print".screenshot-screen = {}; + "Mod+Shift+H".move-column-left = {}; + "Mod+Shift+F".fullscreen-window = {}; + "Mod+Shift+L".move-column-right = {}; + "Mod+Shift+P".power-off-monitors = {}; + "Mod+K".focus-window-or-workspace-up = {}; + "Mod+J".focus-window-or-workspace-down = {}; + "Mod+Shift+K".move-window-up-or-to-workspace-up = {}; + "Mod+Shift+J".move-window-down-or-to-workspace-down = {}; + }; + }; }; } +/* + spawn-at-startup "noctalia" + spawn-at-startup "gammastep" "-b" "0.8:0.5" "-l" "52:113.5" "-P" "-t" "6000:3000" + environment.QT_QPA_PLATFORMTHEME "qt6ct" + } + + binds { + Mod+D { spawn-sh "noctalia msg panel-toggle launcher"; } + Mod+E { spawn-sh "noctalia msg panel-toggle session"; } + Mod+S { spawn-sh "noctalia msg panel-toggle control-center"; } + Mod+Shift+S { spawn-sh "noctalia msg settings-open"; } + + XF86AudioRaiseVolume { spawn-sh "noctalia msg volume-up"; } + XF86AudioLowerVolume { spawn-sh "noctalia msg volume-down"; } + XF86AudioMute { spawn-sh "noctalia msg volume-mute"; } + Shift+XF86AudioRaiseVolume { spawn-sh "noctalia msg mic-volume-up"; } + Shift+XF86AudioLowerVolume { spawn-sh "noctalia msg mic-volume-down"; } + Shift+XF86AudioMute { spawn-sh "noctalia msg mic-mute"; } + XF86MonBrightnessUp { spawn-sh "noctalia msg brightness-up"; } + XF86MonBrightnessDown { spawn-sh "noctalia msg brightness-down"; } + + + + Mod+Ctrl+H { focus-monitor-left; } + Mod+Ctrl+J { focus-monitor-down; } + Mod+Ctrl+K { focus-monitor-up; } + Mod+Ctrl+L { focus-monitor-right; } + + Mod+Ctrl+Shift+H { move-column-to-monitor-left; } + Mod+Ctrl+Shift+J { move-column-to-monitor-down; } + Mod+Ctrl+Shift+K { move-column-to-monitor-up; } + Mod+Ctrl+Shift+L { move-column-to-monitor-right; } + + } +*/ diff --git a/home/common.nix b/home/common.nix index f4b2813..36d3ede 100644 --- a/home/common.nix +++ b/home/common.nix @@ -1,20 +1,23 @@ { config, pkgs, ... }: { - home.stateVersion = "26.05"; services.ssh-agent.enable = true; - home.packages = with pkgs; [ ncdu yt-dlp ]; + home = { + stateVersion = "26.11"; + packages = with pkgs; [ ncdu yt-dlp ]; + }; programs = { home-manager.enable = true; - bash = { - enable = true; - shellAliases.la = "ls -lAtr"; - historyControl = [ "ignoreboth" ]; - }; ssh = { enable = true; enableDefaultConfig = false; settings."*".SetEnv.TERM = "xterm-256color"; }; + bash = { + enable = true; + shellAliases.la = "ls -lAtr"; + historyControl = [ "ignoreboth" ]; + sessionVariables.PROMPT_COMMAND = "history -a"; + }; git = { enable = true; settings = { diff --git a/home/data.nix b/home/data.nix deleted file mode 100644 index 2c64968..0000000 --- a/home/data.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ config, pkgs, ... }: -{ - imports = [ ./common.nix ]; - home = { - username = "data"; - homeDirectory = "/home/data"; - }; -} diff --git a/install.sh b/install.sh index c105463..f826f8d 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ gdisk $DISK mkfs.fat -F 32 $ESPPART cryptsetup luksFormat $ROOTPART cryptsetup open $ROOTPART root -mkfs.ext4 $ROOTPART +mkfs.ext4 /dev/mapper/root mount /dev/mapper/root /mnt mount $ESPPART --mkdir -o umask=077 /mnt/boot mkdir /mnt/var @@ -11,5 +11,5 @@ swapon /mnt/var/swapfile nixos-generate-config --root /mnt --kernel latest --flake #copy backup nixos-install --no-root-passwd --no-channel-copy --flake "/mnt/etc/nixos#nixos" -sbctl enroll-keys --yes-this-might-brick-my-machine +sbctl enroll-keys --yolo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+2+7 $ROOTPART diff --git a/mods/pxeboot.nix b/mods/pxeboot.nix index 308f140..a506f55 100644 --- a/mods/pxeboot.nix +++ b/mods/pxeboot.nix @@ -1,5 +1,6 @@ { config, lib, pkgs, ... }: { + environment.systemPackages = [ pkgs.grub2_efi ]; virtualisation.oci-containers.containers.fedora-dracut = { pull = "newer"; autoStart = false; @@ -13,6 +14,14 @@ ]; }; services = { + dnsmasq.settings = { + enable-tftp = true; + interface = "enp1s0"; + tftp-root = "/srv/tftp"; + dhcp-boot = "grubx64.efi"; + dhcp-range = [ "10.2.0.2,10.2.255.254,12h" + "fc02::2,fc02::ffff:ffff:ffff:ffff,12h" ]; + }; nfs.server = { enable = true; exports = let @@ -22,22 +31,29 @@ "/srv/nfs/fedora/root" = clients; }; }; - dnsmasq = { + }; + networking = { + firewall = { + allowedTCPPorts = [ 53 2049 ]; + allowedUDPPorts = [ 53 67 69 547 ]; + }; + nat = { enable = true; - settings = { - enable-ra = true; - no-resolv = true; - cache-size = 4096; - bogus-priv = true; - enable-tftp = true; - interface = "enp1s0"; - domain-needed = true; - tftp-root = "/srv/tftp"; - dhcp-boot = "grubx64.efi"; - server = [ "1.1.1.2" "2606:4700:4700::1112" - "1.0.0.2" "2606:4700:4700::1002" ]; - dhcp-range = [ "10.2.0.2,10.2.255.254,12h" - "fc02::2,fc02::ffff:ffff:ffff:ffff,12h" ]; + enableIPv6 = true; + internalInterfaces = [ "enp1s0" ]; + }; + networkmanager.ensureProfiles.profiles.ethernet = { + ipv6 = { + method = "manual"; + addresses = "fc02::1/64"; + }; + ipv4 = { + method = "manual"; + addresses = "10.2.0.1/16"; + }; + connection = { + id = "ethernet"; + type = "802-3-ethernet"; }; }; }; @@ -45,7 +61,9 @@ tmpfiles.rules = [ "d /srv/tftp" ]; services.pxeboot = { before = [ "nfs-server.service" ]; + after = [ "wg-quick-awg0.service" ]; requiredBy = [ "nfs-server.service" ]; + requires = [ "wg-quick-awg0.service" ]; path = with pkgs; [ xz curl e2fsprogs grub2_efi util-linux ]; serviceConfig = { Type = "oneshot"; @@ -77,6 +95,18 @@ url = "https://download.fedoraproject.org/pub/fedora/linux/releases/" + "44/Workstation/x86_64/iso/Fedora-Workstation-Live-44-1.7.x86_64.iso"; }; + entryScript = pkgs.writeShellScript "entry.sh" '' + set -e + dnf install -y nfs-utils dracut-network + cd /data/workdir + for target in $(ls .. | grep -v workdir); do + mkdir $target + modsDir=../$target/usr/lib/modules/* + cp $modsDir/vmlinuz $target + dracut -Nm "network-manager nfs" --zstd -k $modsDir \ + --kver $(basename $modsDir) $target/initramfs + done + ''; grubCfg = pkgs.writeText "grub.cfg" '' function load { set p=$cmdpath/boot/$1 @@ -90,18 +120,6 @@ load fedora selinux=0 } ''; - entryScript = pkgs.writeShellScript "entry.sh" '' - set -e - dnf install -y nfs-utils dracut-network - cd /data/workdir - for target in $(ls .. | grep -v workdir); do - mkdir $target - modsDir=../$target/usr/lib/modules/* - cp $modsDir/vmlinuz $target - dracut -Nm "network-manager nfs" --zstd -k $modsDir \ - --kver $(basename $modsDir) $target/initramfs - done - ''; in '' for distro in arch fedora; do case $distro in diff --git a/server/configuration.nix b/server/configuration.nix index bc2308c..c109ae8 100644 --- a/server/configuration.nix +++ b/server/configuration.nix @@ -49,7 +49,7 @@ hostName = "nixos-server"; firewall = { allowedUDPPorts = [ 443 ]; - allowedTCPPorts = [ 25 443 465 993 ]; + allowedTCPPorts = [ 25 80 443 465 993 ]; }; wg-quick.interfaces.awg0 = { configFile = "/secrets/awg/1.conf";