From 4182e1e771be30ff74306ae046df96f27b3df7b4 Mon Sep 17 00:00:00 2001 From: Kabbone Date: Sat, 28 Oct 2023 11:39:27 +0200 Subject: [PATCH] hosts: nasbak: add initial --- hosts/default.nix | 6 +- hosts/nasbackup/default.nix | 66 +++++++ hosts/nasbackup/hardware-configuration.nix | 206 +++++++++++++++++++++ hosts/nasbackup/home.nix | 39 ++++ modules/services/nasbak/default.nix | 18 ++ 5 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 hosts/nasbackup/default.nix create mode 100644 hosts/nasbackup/hardware-configuration.nix create mode 100644 hosts/nasbackup/home.nix create mode 100644 modules/services/nasbak/default.nix diff --git a/hosts/default.nix b/hosts/default.nix index f8b8bcc..330ed86 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -159,14 +159,14 @@ in ]; }; - nas = lib.nixosSystem { # Desktop profile + nasbackup = lib.nixosSystem { # Desktop profile inherit system; #user = "dmz-user"; specialArgs = { inherit inputs user location nixos-hardware nur agenix; }; modules = [ agenix.nixosModules.default nur.nixosModules.nur - ./nas + ./nasbackup ./configuration_desktop.nix ../modules/hardware/remoteClient.nix nixos-hardware.nixosModules.common-cpu-intel @@ -180,7 +180,7 @@ in home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { inherit user; }; home-manager.users.${user} = { - imports = [(import ./home_server.nix)] ++ [(import ./nas/home.nix)]; + imports = [(import ./home_server.nix)] ++ [(import ./nasbackup/home.nix)]; }; } ]; diff --git a/hosts/nasbackup/default.nix b/hosts/nasbackup/default.nix new file mode 100644 index 0000000..b840184 --- /dev/null +++ b/hosts/nasbackup/default.nix @@ -0,0 +1,66 @@ +# +# Specific system configuration settings for desktop +# +# flake.nix +# ├─ ./hosts +# │ └─ ./laptop +# │ ├─ default.nix * +# │ └─ hardware-configuration.nix +# └─ ./modules +# ├─ ./desktop +# │ └─ ./hyprland +# │ └─ hyprland.nix +# ├─ ./modules +# │ └─ ./programs +# │ └─ waybar.nix +# └─ ./hardware +# └─ default.nix +# + +{ config, pkgs, user, ... }: + +{ + imports = # For now, if applying to other system, swap files + [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix + (import ../../modules/desktop/virtualisation) ++ # Docker + (import ../../modules/services/nasbackup) ++ # Server Services + (import ../../modules/hardware); # Hardware devices + + boot = { # Boot options + kernelPackages = pkgs.linuxPackages_latest; + + loader = { # EFI Boot + systemd-boot.enable = true; + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + timeout = 1; # Grub auto select time + }; + }; + + programs = { # No xbacklight, this is the alterantive + zsh.enable = true; + ssh.startAgent = false; + gnupg.agent = { + enable = false; + enableSSHSupport = true; + pinentryFlavor = "curses"; + }; + }; + + services = { + #auto-cpufreq.enable = true; + avahi = { # Needed to find wireless printer + enable = true; + nssmdns = true; + publish = { # Needed for detecting the scanner + enable = true; + addresses = true; + userServices = true; + }; + }; + + }; + +} diff --git a/hosts/nasbackup/hardware-configuration.nix b/hosts/nasbackup/hardware-configuration.nix new file mode 100644 index 0000000..4ce0e58 --- /dev/null +++ b/hosts/nasbackup/hardware-configuration.nix @@ -0,0 +1,206 @@ +# +# Hardware settings for Teclast F5 10" Laptop +# NixOS @ sda2 +# +# flake.nix +# └─ ./hosts +# └─ ./laptop +# └─ hardware-configuration.nix * +# +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "vfio_pci" "vfio" "vfio_iommu_type1" ]; +# boot.initrd.secrets = { +# "/root/NASKeyfile" = +# /root/NASKeyfile; +# }; +# boot.initrd.luks.devices = { +# NAS-RAID1 = { +# device = "/dev/disk/by-uuid/57e6446d-faca-4b67-9063-e8d9afb80088"; +# keyFile = "/root/NASKeyfile"; +# }; +# NAS-RAID2 = { +# device = "/dev/disk/by-uuid/b9edc489-ac37-4b28-981d-442722df7ae2"; +# keyFile = "/root/NASKeyfile"; +# }; +# }; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + boot.tmp.useTmpfs = false; + boot.tmp.cleanOnBoot = true; + zramSwap.enable = true; + + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" +# "/mnt/Pluto" + ]; + }; + + services.btrbk = { + instances = { + hf = { + onCalendar = "hourly"; + settings = { + incremental = "yes"; + snapshot_create = "ondemand"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + volume = { + "/mnt/snapshots/root" = { + snapshot_create = "always"; + subvolume = { + "@" = {}; + "@home" = {}; + }; + }; + }; + }; + }; +# lf = { +# onCalendar = "daily"; +# settings = { +# incremental = "yes"; +# snapshot_create = "ondemand"; +# snapshot_dir = "@snapshots"; +# timestamp_format = "long"; +# +# snapshot_preserve = "2m 2w 5d"; +# snapshot_preserve_min = "latest"; +# +# volume = { +# "/mnt/snapshots/Pluto" = { +# snapshot_create = "always"; +# subvolume = { +# "@" = {}; +# "@/Backups" = {}; +# "@/Games" = {}; +# "@/IT" = {}; +# "@/Media" = {}; +# "@/Pictures" = {}; +# "@/Rest" = {}; +# }; +# }; +# }; +# }; +# }; +# }; +# }; + + fileSystems."/" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@,discard=async" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; + }; + + fileSystems."/srv" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@srv,discard=async" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; + }; + + fileSystems."/swap" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@swap,discard=async" ]; + }; + +# fileSystems."/mnt/snapshots/root" = +# { device = "/dev/disk/by-label/NIXROOT"; +# fsType = "btrfs"; +# options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvolid=5,discard=async" ]; +# }; +# +# fileSystems."/mnt/snapshots/Pluto" = +# { device = "/dev/disk/by-label/NAS-RAID"; +# fsType = "btrfs"; +# options = [ "compress=zstd,space_cache=v2,noatime,subvolid=5" ]; +# }; +# +# fileSystems."/mnt/Pluto" = +# { device = "/dev/disk/by-label/NAS-RAID"; +# fsType = "btrfs"; +# options = [ "compress=zstd,space_cache=v2,noatime,subvol=@" ]; +# }; +# + fileSystems."/boot" = + { device = "/dev/disk/by-label/NIXBOOT"; + fsType = "vfat"; + }; + + swapDevices = [ { device = "/swap/swapfile"; } ]; + + networking = { + hostName = "nasbak"; + domain = "home.opel-online.de"; + networkmanager = { + enable = false; + }; + timeServers = [ + "192.168.2.1" + ]; + interfaces = { + enp6s18 = { + useDHCP = true; # For versatility sake, manually edit IP on nm-applet. +# ipv4.addresses = [ { +# address = "45.142.114.153"; +# prefixLength = 24; +# } ]; +# ipv6.addresses = [ { +# address = "2a00:ccc1:101:19D::2"; +# prefixLength = 64; +# } ]; +# }; + }; + }; +# defaultGateway = "45.142.114.1"; + defaultGateway6 = { + address = "fe80::1"; + interface = "enp6s18"; + }; +# nameservers = [ "9.9.9.9" "2620:fe::fe" ]; + #firewall = { + # enable = false; + # #allowedUDPPorts = [ 53 67 ]; + # #allowedTCPPorts = [ 53 80 443 9443 ]; + #}; + }; + + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + powerManagement = { + cpuFreqGovernor = lib.mkDefault "powersave"; + powertop.enable = true; +# powerUpCommands = '' +# ${pkgs.hdparm}/sbin/hdparm -S 150 /dev/disk/by-uuid/57e6446d-faca-4b67-9063-e8d9afb80088 +# ${pkgs.hdparm}/sbin/hdparm -S 150 /dev/disk/by-uuid/b9edc489-ac37-4b28-981d-442722df7ae2 +# ''; + }; + +} diff --git a/hosts/nasbackup/home.nix b/hosts/nasbackup/home.nix new file mode 100644 index 0000000..03d34bb --- /dev/null +++ b/hosts/nasbackup/home.nix @@ -0,0 +1,39 @@ +# +# Home-manager configuration for laptop +# +# flake.nix +# ├─ ./hosts +# │ └─ ./laptop +# │ └─ home.nix * +# └─ ./modules +# └─ ./desktop +# └─ ./hyprland +# └─ hyprland.nix +# + +{ pkgs, ... }: + +{ + imports = + [ + ../../modules/home.nix # Window Manager + ]; + + home = { # Specific packages for laptop + packages = with pkgs; [ + # Applications + + # Display + #light # xorg.xbacklight not supported. Other option is just use xrandr. + + # Power Management + #auto-cpufreq # Power management + #tlp # Power management + ]; + }; + + programs = { + alacritty.settings.font.size = 11; + }; + +} diff --git a/modules/services/nasbak/default.nix b/modules/services/nasbak/default.nix new file mode 100644 index 0000000..1c98c3a --- /dev/null +++ b/modules/services/nasbak/default.nix @@ -0,0 +1,18 @@ +# +# Services +# +# flake.nix +# ├─ ./hosts +# │ └─ home.nix +# └─ ./modules +# └─ ./services +# └─ default.nix * +# └─ ... +# + +[ +# ./nfs.nix +] + +# picom, polybar and sxhkd are pulled from desktop module +# redshift temporarely disables