diff --git a/TODO b/TODO index db1e6ce..c5d7775 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +- nix.settings.experimental-features = [ "nix-command" "flakes" ]; - distributed build (https://nix.dev/tutorials/nixos/distributed-builds-setup) - setup script (https://github.com/jakeb-grant/nix-configs/blob/main/setup.sh) - swap diff --git a/flake.nix b/flake.nix index e1c00f1..63ce975 100644 --- a/flake.nix +++ b/flake.nix @@ -10,61 +10,11 @@ }; }; - outputs = { self, nixpkgs, disko, ... }@inputs: { + outputs = { nixpkgs, disko, ... }: { nixosConfigurations = { opti = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = [ - ./hosts/opti - disko.nixosModules.disko - { - disko.devices = { - disk = { - main = { - type = "disk"; - device = - "/dev/disk/by-id/nvme-eui.00000000000000000c82d58020000000"; - content = { - type = "gpt"; - partitions = { - boot = { - size = "500M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - primary = { - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; # Override existing partition - subvolumes = { - "/rootfs" = { mountpoint = "/"; }; - "/home" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/home"; - }; - "/home/wekuz" = { }; - "/nix" = { - mountOptions = [ "compress=zstd" "noatime" ]; - mountpoint = "/nix"; - }; - }; - - mountpoint = "/partition-root"; - }; - }; - }; - }; - }; - }; - }; - } - ]; + modules = [ ./hosts/opti disko.nixosModules.disko ]; }; }; }; diff --git a/hosts/opti/default.nix b/hosts/opti/default.nix index d29cfb6..a8e86f9 100644 --- a/hosts/opti/default.nix +++ b/hosts/opti/default.nix @@ -1,12 +1,22 @@ { config, lib, pkgs, ... }: { - imports = [ ./hardware-configuration.nix ]; + imports = [ ./hardware-configuration.nix ./disko-config.nix ]; nix = { - package = pkgs.nixFlakes; + package = pkgs.nixVersions.stable; + + optimise.automatic = true; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 14d"; + }; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + extraOptions = '' - experimental-features = nix-command flakes + min-free = 512000000 + max-free = 2000000000 ''; }; @@ -17,19 +27,52 @@ nixpkgs.hostPlatform = "x86_64-linux"; + hardware.graphics = { + enable = true; + extraPackages = with pkgs; [ intel-media-driver vaapiIntel ]; + }; + + time.timeZone = "Europe/Tallinn"; + networking = { hostName = "opti"; networkmanager.enable = true; - firewall.enable = false; # TODO: Configure firewall + useDHCP = true; + firewall.allowedTCPPorts = [ 22 ]; }; - services.openssh.enable = true; + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; + settings.PermitRootLogin = "no"; + }; - environment.systemPackages = with pkgs; [ git ]; + virtualisation = { + docker = { + enable = true; + autoPrune = { + enable = true; + dates = "weekly"; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + git + btop + ncdu + tmux + wget + ripgrep + smartmontools + lm_sensors + ]; + + environment.variables.EDITOR = "nvim"; users.users.wekuz = { isNormalUser = true; - extraGroups = [ "wheel" ]; + extraGroups = [ "wheel" "networkmanager" "docker" ]; packages = with pkgs; [ ]; openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBs3aPxyJpVGytuVSO3va2WybKNFMR241o8DCJQbBEWV" diff --git a/hosts/opti/disko-config.nix b/hosts/opti/disko-config.nix index 325edbe..8ddfd7f 100644 --- a/hosts/opti/disko-config.nix +++ b/hosts/opti/disko-config.nix @@ -1,47 +1,50 @@ { - disko.devices = { - disk = { - main = { - type = "disk"; - device = - "/dev/disk/by-id/nvme-eui.00000000000000000c82d58020000000"; - content = { - type = "gpt"; - partitions = { - boot = { - size = "500M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - primary = { - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; # Override existing partition - subvolumes = { - "/rootfs" = { mountpoint = "/"; }; - "/home" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/home"; - }; - "/home/wekuz" = { }; - "/nix" = { - mountOptions = [ "compress=zstd" "noatime" ]; - mountpoint = "/nix"; - }; - }; - - mountpoint = "/partition-root"; - }; - }; - }; - }; - }; + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/disk/by-id/nvme-eui.00000000000000000c82d58020000000"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; }; }; - } + primary = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; # Override existing partition + subvolumes = { + "/rootfs" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/"; + }; + "/home" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/home"; + }; + "/home/wekuz" = { }; + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/nix"; + }; + # TODO: /log + }; + + mountpoint = "/part-root"; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/opti/hardware-configuration.nix b/hosts/opti/hardware-configuration.nix new file mode 100644 index 0000000..8142fc8 --- /dev/null +++ b/hosts/opti/hardware-configuration.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = true; +}