My Prior Exposure to Declarative

I have been hard at work to learn NixOS in order to create declarative configs for my system configurations:

NixOS has been a lot of fun to learn and definitely leaves you with a gratifying feeling each time you resolve an issue. Getting my systems to work with NixOS has been a challenge as I do not run normal setups. So I’ve had the joy of being one of the few to write a complete setup for Raspberry Pi 5.

My first introduction to declarative code was CDK in 2022, I haven’t but much thought into it until looking into NixOS. Working through all the configuration problems has allowed me to take on things like Kubernetes with considerably less onboarding effort after getting more exposure to declarative configuration.

NixOS for Gamers and Developers with End-4 Dots

image

Image of

Nvidia has recently been more of a challenge for gamers due to problems with Wayland. My configuration forces the video card out of low power mode to stop the flicker as well as bypass the vbios for ESXi, those interested in running my flakes without ESXi can do so by removing the highlighted lines below:

esnixi/boot.nix
{ config, lib, pkgs, pkgs-unstable, ... }:
{
  config = {
    nixpkgs.config.allowUnsupportedSystem = true;
    boot = {
      binfmt.emulatedSystems = [ "aarch64-linux" ];
      loader = {
        systemd-boot.enable = true;
        efi.canTouchEfiVariables = true;
      };
      supportedFilesystems = [ "ntfs" "nfs" ];
      plymouth.enable = true;
      kernelPackages = pkgs-unstable.linuxPackages_latest;
      kernelModules = [ "uinput" "nvidia" ];
      extraModprobeConfig = ''
        options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
        options nvidia NVreg_EnablePCIeGen3=1
        options nvidia NVreg_EnableGpuFirmware=0
        options nvidia NVreg_RegistryDwords="PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3"
      '';
      initrd.kernelModules = [
        "nvidia"
        "nvidia_modeset"
        "nvidia_uvm"
        "nvidia_drm"
      ];
    };
    hardware.opengl.enable = true;
    virtualisation.spiceUSBRedirection.enable = true;
  };
}
esnixi/virtualisation.nix
{ ... }:
{
  config = {
    # Enable VMWare Tools.
    virtualisation.vmware.guest.enable = true;
    virtualisation.docker.enable = true;
    # Enable QEMU.
    virtualisation.libvirtd.enable = true;
    programs.virt-manager.enable = true;
  };
}
esnixi/graphics.nix
    # Load nvidia driver for Xorg and Wayland
    services.xserver.videoDrivers = [ "nvidia" ];
    hardware.nvidia = {
      package = config.boot.kernelPackages.nvidiaPackages.stable;
      modesetting.enable = true;
      powerManagement.enable = false;

      open = true;
      nvidiaSettings = true;
    };
  };
}

For RPi5 Kubernetes

Setting up Kubernetes was significantly easier on BareMetal than as Virtual Machines for me. I configured a new VLAN on my local network and provided an endpoint on one of my switches for the Kubernetes network to reside.

I was able to find a stale method for enabling Longhorn for NixOS Kubernetes and patched it for use with helmfile from my NixOS flakes.

Importing WordPress was more of a challenge due to all of its features and I spent a lot of time chasing down a backup solution that both works and imports all of my database. There is none. ]=

The most fun part to figure out was signing certificates with a certificate authority as well as standing up GitHub clusterplex, which is an X86_64/ARM64 solution for a true distributed Plex!

Raspberry Pi 5 with End-4 Dots

I have been working on bringing easier configurations to NixOS for the RPi5 by providing staged config approaches to reach a usable state. Starting with the following config from bootable media

/etc/nixos/configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).

{ config, lib, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = false;
  boot.loader.grub.device = "nodev";
  boot.loader.grub.efiSupport = true;
  boot.kernelPackages = (import (builtins.fetchTarball https://gitlab.com/vriska/nix-rpi5/-/archive/main.tar.gz)).legacyPackages.aarch64-linux.linuxPackages_rpi5;
  boot.kernelParams = [ "8250.nr_uarts=11" "console=ttyAMA10,9600" "console=tty0" ];
  networking.hostName = "nixberry";
  networking.networkmanager.enable = true;
  networking.networkmanager.wifi.backend = "iwd";
  networking.wireless.iwd = {
    enable = true;
    settings.General.EnableNetworkConfiguration = true;
  };

  time.timeZone = "America/Los_Angeles";

  environment.systemPackages = with pkgs; [
    vim
    pciutils
    usbutils
    wpa_supplicant
    btop
    curl
    git
  ];

  services.openssh.enable = true;
  services.openssh.settings.PermitRootLogin = "yes";
  networking.firewall.enable = false;
 
  services.hardware.argonone = {
    enable = true;
  };

  services.xserver = {
    enable = true;
    displayManager.gdm.enable = true;
    desktopManager.enlightenment.enable = true;
  };

  system.stateVersion = "24.05"; # Did you read the comment?

}

I would like to upgrade my flakes from 23.05, however, I am having problems with the wireless kernel modules and do not want to release anything until I resolve those issues!

Leave a Reply

Your email address will not be published. Required fields are marked *