From 7bc6e0c47031a575a93cb682cc2d0305dcaecc47 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 19 Jan 2025 14:25:45 -0500 Subject: [PATCH 01/15] Add a config for neelix. --- nix/configuration/configuration.nix | 1 - nix/configuration/flake.nix | 36 ++++- nix/configuration/hosts/neelix/default.nix | 30 ++++ .../hosts/neelix/disk-config.nix | 140 ++++++++++++++++++ .../hosts/neelix/hardware-configuration.nix | 32 ++++ .../hosts/neelix/optimized_build.nix | 68 +++++++++ .../hosts/neelix/power_management.nix | 46 ++++++ .../hosts/neelix/screen_brightness.nix | 14 ++ nix/configuration/hosts/neelix/wifi.nix | 16 ++ nix/configuration/hosts/odo/disk-config.nix | 3 + 10 files changed, 384 insertions(+), 2 deletions(-) create mode 100644 nix/configuration/hosts/neelix/default.nix create mode 100644 nix/configuration/hosts/neelix/disk-config.nix create mode 100644 nix/configuration/hosts/neelix/hardware-configuration.nix create mode 100644 nix/configuration/hosts/neelix/optimized_build.nix create mode 100644 nix/configuration/hosts/neelix/power_management.nix create mode 100644 nix/configuration/hosts/neelix/screen_brightness.nix create mode 100644 nix/configuration/hosts/neelix/wifi.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 3b1f6da..894d47b 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -11,7 +11,6 @@ ./roles/reset ./util/unfree_polyfill ./roles/iso - ./hosts/odo "${ builtins.fetchTarball { url = "https://github.com/nix-community/disko/archive/refs/tags/v1.9.0.tar.gz"; diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index 91b59fe..c0f25ee 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -81,7 +81,39 @@ }; systems = { odo = { - main = nixpkgs.lib.nixosSystem (base_x86_64_linux // { }); + main = nixpkgs.lib.nixosSystem ( + base_x86_64_linux + // { + modules = base_x86_64_linux.modules ++ [ + ./hosts/odo + ]; + } + ); + iso = nixpkgs.lib.nixosSystem ( + base_x86_64_linux + // { + modules = base_x86_64_linux.modules ++ [ + (nixpkgs + "/nixos/modules/installer/cd-dvd/iso-image.nix") + # TODO: Figure out how to do image based appliances + # (nixpkgs + "/nixos/modules/profiles/image-based-appliance.nix") + { + isoImage.makeEfiBootable = true; + isoImage.makeUsbBootable = true; + me.buildingIso = true; + } + ]; + } + ); + }; + neelix = { + main = nixpkgs.lib.nixosSystem ( + base_x86_64_linux + // { + modules = base_x86_64_linux.modules ++ [ + ./hosts/neelix + ]; + } + ); iso = nixpkgs.lib.nixosSystem ( base_x86_64_linux // { @@ -103,5 +135,7 @@ { nixosConfigurations.odo = systems.odo.main; iso.odo = systems.odo.iso.config.system.build.isoImage; + nixosConfigurations.neelix = systems.neelix.main; + iso.neelix = systems.neelix.iso.config.system.build.isoImage; }; } diff --git a/nix/configuration/hosts/neelix/default.nix b/nix/configuration/hosts/neelix/default.nix new file mode 100644 index 0000000..bdcd7dd --- /dev/null +++ b/nix/configuration/hosts/neelix/default.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: +{ + imports = [ + ./hardware-configuration.nix + ./disk-config.nix + ./optimized_build.nix + ./power_management.nix + ./screen_brightness.nix + ./wifi.nix + ]; + + # Generate with `head -c4 /dev/urandom | od -A none -t x4` + networking.hostId = "fbd233d8"; + + networking.hostName = "neelix"; # Define your hostname. + + time.timeZone = "America/New_York"; + i18n.defaultLocale = "en_US.UTF-8"; + + me.secureBoot.enable = false; + + # Early KMS + boot.initrd.kernelModules = [ "i915" ]; + + # Mount tmpfs at /tmp + boot.tmp.useTmpfs = true; + + me.graphical = true; + me.graphicsCardType = "intel"; +} diff --git a/nix/configuration/hosts/neelix/disk-config.nix b/nix/configuration/hosts/neelix/disk-config.nix new file mode 100644 index 0000000..f9204aa --- /dev/null +++ b/nix/configuration/hosts/neelix/disk-config.nix @@ -0,0 +1,140 @@ +# Manual Step: +# Check if drive supports 4kn: nvme id-ns -H /dev/nvme0n1 +# Format the drive to 4kn: nvme format --lbaf=1 /dev/nvme0n1 +{ + config, + lib, + pkgs, + ... +}: + +lib.mkIf (!config.me.buildingIso) { + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "umask=0077" + "noatime" + "discard" + ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + # mode = "mirror"; + # Workaround: cannot import 'zroot': I/O error in disko tests + options.cachefile = "none"; + options = { + ashift = "12"; + compatibility = "openzfs-2.2-freebsd"; + autotrim = "on"; + }; + rootFsOptions = { + acltype = "posixacl"; + atime = "off"; + relatime = "off"; + xattr = "sa"; + mountpoint = "none"; + compression = "lz4"; + canmount = "off"; + utf8only = "on"; + dnodesize = "auto"; + normalization = "formD"; + }; + + datasets = { + "linux/nix" = { + type = "zfs_fs"; + options.mountpoint = "none"; + }; + "linux/nix/root" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/linux/nix/root@blank$' || zfs snapshot zroot/linux/nix/root@blank"; + }; + "linux/nix/nix" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/nix"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/linux/nix/nix@blank$' || zfs snapshot zroot/linux/nix/nix@blank"; + options = { + recordsize = "1MiB"; + compression = "lz4"; + }; + }; + "linux/nix/home" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/home"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/linux/nix/home@blank$' || zfs snapshot zroot/linux/nix/home@blank"; + }; + "linux/nix/persist" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/persist"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/linux/nix/persist@blank$' || zfs snapshot zroot/linux/nix/persist@blank"; + }; + "linux/nix/state" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/state"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/linux/nix/state@blank$' || zfs snapshot zroot/linux/nix/state@blank"; + }; + }; + }; + }; + }; + + # Make sure all persistent volumes are marked as neededForBoot + # + # Also mounts /home so it is mounted before the user home directories are created. + fileSystems."/persist".neededForBoot = true; + fileSystems."/state".neededForBoot = true; + fileSystems."/home".neededForBoot = true; + + fileSystems."/".options = [ + "noatime" + "norelatime" + ]; + fileSystems."/nix".options = [ + "noatime" + "norelatime" + ]; + fileSystems."/persist".options = [ + "noatime" + "norelatime" + ]; + fileSystems."/state".options = [ + "noatime" + "norelatime" + ]; + fileSystems."/home".options = [ + "noatime" + "norelatime" + ]; +} diff --git a/nix/configuration/hosts/neelix/hardware-configuration.nix b/nix/configuration/hosts/neelix/hardware-configuration.nix new file mode 100644 index 0000000..b583e6a --- /dev/null +++ b/nix/configuration/hosts/neelix/hardware-configuration.nix @@ -0,0 +1,32 @@ +# 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 + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nix/configuration/hosts/neelix/optimized_build.nix b/nix/configuration/hosts/neelix/optimized_build.nix new file mode 100644 index 0000000..4f678a4 --- /dev/null +++ b/nix/configuration/hosts/neelix/optimized_build.nix @@ -0,0 +1,68 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + imports = [ ]; + + nix.settings.system-features = lib.mkForce [ + "gccarch-alderlake" + "gccarch-x86-64-v3" + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + + # nixpkgs.hostPlatform = { + # gcc.arch = "alderlake"; + # gcc.tune = "alderlake"; + # system = "x86_64-linux"; + # }; + + nixpkgs.overlays = [ + ( + self: super: + let + optimizeWithFlags = + pkg: flags: + pkg.overrideAttrs (old: { + NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags; + }); + addConfig = + additionalConfig: pkg: + pkg.override (oldconfig: { + structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig; + }); + in + { + linux_alderlake = + addConfig + { + # Full preemption + PREEMPT = lib.mkOverride 60 lib.kernel.yes; + PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no; + + # Google's BBRv3 TCP congestion Control + TCP_CONG_BBR = lib.kernel.yes; + DEFAULT_BBR = lib.kernel.yes; + + # Preemptive Full Tickless Kernel at 300Hz + HZ = lib.kernel.freeform "300"; + HZ_300 = lib.kernel.yes; + HZ_1000 = lib.kernel.no; + } + ( + optimizeWithFlags super.linux_6_12 [ + "-march=alderlake" + "-mtune=alderlake" + ] + ); + } + ) + ]; + + boot.kernelPackages = lib.mkIf (!config.me.buildingIso) (pkgs.linuxPackagesFor pkgs.linux_alderlake); +} diff --git a/nix/configuration/hosts/neelix/power_management.nix b/nix/configuration/hosts/neelix/power_management.nix new file mode 100644 index 0000000..99bdbe2 --- /dev/null +++ b/nix/configuration/hosts/neelix/power_management.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + environment.systemPackages = with pkgs; [ + powertop + ]; + + # pcie_aspm=force pcie_aspm.policy=powersupersave :: Enable PCIe active state power management for power reduction. + # nowatchdog :: Disable watchdog for power savings (related to disable_sp5100_watchdog above). + boot.kernelParams = [ + "pcie_aspm=force" + # "pcie_aspm.policy=powersupersave" + "nowatchdog" + ]; + + # systemd.tmpfiles.rules = [ + # "w- /sys/firmware/acpi/platform_profile - - - - low-power" + # "w- /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy2/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy3/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy4/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy5/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy6/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy7/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy8/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy9/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy10/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy11/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy12/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy13/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy14/energy_performance_preference - - - - power" + # "w- /sys/devices/system/cpu/cpufreq/policy15/energy_performance_preference - - - - power" + # ]; + + boot.extraModprobeConfig = '' + options snd_hda_intel power_save=1 + ''; +} diff --git a/nix/configuration/hosts/neelix/screen_brightness.nix b/nix/configuration/hosts/neelix/screen_brightness.nix new file mode 100644 index 0000000..8314d0e --- /dev/null +++ b/nix/configuration/hosts/neelix/screen_brightness.nix @@ -0,0 +1,14 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + # systemd.tmpfiles.rules = [ + # "w- /sys/class/backlight/amdgpu_bl1/brightness - - - - 85" + # ]; +} diff --git a/nix/configuration/hosts/neelix/wifi.nix b/nix/configuration/hosts/neelix/wifi.nix new file mode 100644 index 0000000..a1c136d --- /dev/null +++ b/nix/configuration/hosts/neelix/wifi.nix @@ -0,0 +1,16 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + # config = { + # environment.loginShellInit = lib.mkIf (!config.me.buildingIso) '' + # doas iw dev wlan0 set power_save off + # ''; + # }; +} diff --git a/nix/configuration/hosts/odo/disk-config.nix b/nix/configuration/hosts/odo/disk-config.nix index 07048d4..dc31c68 100644 --- a/nix/configuration/hosts/odo/disk-config.nix +++ b/nix/configuration/hosts/odo/disk-config.nix @@ -1,3 +1,6 @@ +# Manual Step: +# Check if drive supports 4kn: nvme id-ns -H /dev/nvme0n1 +# Format the drive to 4kn: nvme format --lbaf=1 /dev/nvme0n1 { config, lib, From f2adb9328b49d4cf809f3eb3dd0345ad8041abb5 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 19 Jan 2025 15:23:38 -0500 Subject: [PATCH 02/15] Build zfs into the ISO image. --- nix/configuration/flake.nix | 4 +- .../hosts/neelix/optimized_build.nix | 124 +++++++++-------- .../hosts/odo/optimized_build.nix | 130 ++++++++++-------- 3 files changed, 139 insertions(+), 119 deletions(-) diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index c0f25ee..2b84092 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -93,6 +93,7 @@ base_x86_64_linux // { modules = base_x86_64_linux.modules ++ [ + ./hosts/odo (nixpkgs + "/nixos/modules/installer/cd-dvd/iso-image.nix") # TODO: Figure out how to do image based appliances # (nixpkgs + "/nixos/modules/profiles/image-based-appliance.nix") @@ -118,9 +119,8 @@ base_x86_64_linux // { modules = base_x86_64_linux.modules ++ [ + ./hosts/neelix (nixpkgs + "/nixos/modules/installer/cd-dvd/iso-image.nix") - # TODO: Figure out how to do image based appliances - # (nixpkgs + "/nixos/modules/profiles/image-based-appliance.nix") { isoImage.makeEfiBootable = true; isoImage.makeUsbBootable = true; diff --git a/nix/configuration/hosts/neelix/optimized_build.nix b/nix/configuration/hosts/neelix/optimized_build.nix index 4f678a4..a6ae54f 100644 --- a/nix/configuration/hosts/neelix/optimized_build.nix +++ b/nix/configuration/hosts/neelix/optimized_build.nix @@ -7,62 +7,72 @@ { imports = [ ]; - nix.settings.system-features = lib.mkForce [ - "gccarch-alderlake" - "gccarch-x86-64-v3" - "benchmark" - "big-parallel" - "kvm" - "nixos-test" + config = lib.mkMerge [ + { } + (lib.mkIf (!config.me.buildingIso) { + nix.settings.system-features = lib.mkForce [ + "gccarch-alderlake" + "gccarch-x86-64-v3" + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + + # nixpkgs.hostPlatform = { + # gcc.arch = "alderlake"; + # gcc.tune = "alderlake"; + # system = "x86_64-linux"; + + # }; + + nixpkgs.overlays = [ + ( + self: super: + let + optimizeWithFlags = + pkg: flags: + pkg.overrideAttrs (old: { + NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags; + }); + addConfig = + additionalConfig: pkg: + pkg.override (oldconfig: { + structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig; + }); + in + { + linux_alderlake = + addConfig + { + # Full preemption + PREEMPT = lib.mkOverride 60 lib.kernel.yes; + PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no; + + # Google's BBRv3 TCP congestion Control + TCP_CONG_BBR = lib.kernel.yes; + DEFAULT_BBR = lib.kernel.yes; + + # Preemptive Full Tickless Kernel at 300Hz + HZ = lib.kernel.freeform "300"; + HZ_300 = lib.kernel.yes; + HZ_1000 = lib.kernel.no; + } + ( + optimizeWithFlags super.linux_6_12 [ + "-march=alderlake" + "-mtune=alderlake" + ] + ); + } + ) + ]; + + boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_alderlake; + }) + (lib.mkIf (config.me.buildingIso) { + boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_12; + boot.supportedFilesystems = [ "zfs" ]; + }) ]; - - # nixpkgs.hostPlatform = { - # gcc.arch = "alderlake"; - # gcc.tune = "alderlake"; - # system = "x86_64-linux"; - # }; - - nixpkgs.overlays = [ - ( - self: super: - let - optimizeWithFlags = - pkg: flags: - pkg.overrideAttrs (old: { - NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags; - }); - addConfig = - additionalConfig: pkg: - pkg.override (oldconfig: { - structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig; - }); - in - { - linux_alderlake = - addConfig - { - # Full preemption - PREEMPT = lib.mkOverride 60 lib.kernel.yes; - PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no; - - # Google's BBRv3 TCP congestion Control - TCP_CONG_BBR = lib.kernel.yes; - DEFAULT_BBR = lib.kernel.yes; - - # Preemptive Full Tickless Kernel at 300Hz - HZ = lib.kernel.freeform "300"; - HZ_300 = lib.kernel.yes; - HZ_1000 = lib.kernel.no; - } - ( - optimizeWithFlags super.linux_6_12 [ - "-march=alderlake" - "-mtune=alderlake" - ] - ); - } - ) - ]; - - boot.kernelPackages = lib.mkIf (!config.me.buildingIso) (pkgs.linuxPackagesFor pkgs.linux_alderlake); } diff --git a/nix/configuration/hosts/odo/optimized_build.nix b/nix/configuration/hosts/odo/optimized_build.nix index 43d09b8..7e6fbc0 100644 --- a/nix/configuration/hosts/odo/optimized_build.nix +++ b/nix/configuration/hosts/odo/optimized_build.nix @@ -7,65 +7,75 @@ { imports = [ ]; - nix.settings.system-features = lib.mkForce [ - "gccarch-znver4" - "gccarch-skylake" - # "gccarch-alderlake" missing WAITPKG - "gccarch-x86-64-v3" - "gccarch-x86-64-v4" - "benchmark" - "big-parallel" - "kvm" - "nixos-test" + config = lib.mkMerge [ + { } + (lib.mkIf (!config.me.buildingIso) { + nix.settings.system-features = lib.mkForce [ + "gccarch-znver4" + "gccarch-skylake" + # "gccarch-alderlake" missing WAITPKG + "gccarch-x86-64-v3" + "gccarch-x86-64-v4" + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + + # nixpkgs.hostPlatform = { + # gcc.arch = "znver4"; + # gcc.tune = "znver4"; + # system = "x86_64-linux"; + + # }; + + nixpkgs.overlays = [ + ( + self: super: + let + optimizeWithFlags = + pkg: flags: + pkg.overrideAttrs (old: { + NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags; + }); + addConfig = + additionalConfig: pkg: + pkg.override (oldconfig: { + structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig; + }); + in + { + linux_znver4 = + addConfig + { + # Full preemption + PREEMPT = lib.mkOverride 60 lib.kernel.yes; + PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no; + + # Google's BBRv3 TCP congestion Control + TCP_CONG_BBR = lib.kernel.yes; + DEFAULT_BBR = lib.kernel.yes; + + # Preemptive Full Tickless Kernel at 300Hz + HZ = lib.kernel.freeform "300"; + HZ_300 = lib.kernel.yes; + HZ_1000 = lib.kernel.no; + } + ( + optimizeWithFlags super.linux_6_12 [ + "-march=znver4" + "-mtune=znver4" + ] + ); + } + ) + ]; + + boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_znver4; + }) + (lib.mkIf (config.me.buildingIso) { + boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_12; + boot.supportedFilesystems.zfs = true; + }) ]; - - # nixpkgs.hostPlatform = { - # gcc.arch = "znver4"; - # gcc.tune = "znver4"; - # system = "x86_64-linux"; - # }; - - nixpkgs.overlays = [ - ( - self: super: - let - optimizeWithFlags = - pkg: flags: - pkg.overrideAttrs (old: { - NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags; - }); - addConfig = - additionalConfig: pkg: - pkg.override (oldconfig: { - structuredExtraConfig = pkg.structuredExtraConfig // additionalConfig; - }); - in - { - linux_znver4 = - addConfig - { - # Full preemption - PREEMPT = lib.mkOverride 60 lib.kernel.yes; - PREEMPT_VOLUNTARY = lib.mkOverride 60 lib.kernel.no; - - # Google's BBRv3 TCP congestion Control - TCP_CONG_BBR = lib.kernel.yes; - DEFAULT_BBR = lib.kernel.yes; - - # Preemptive Full Tickless Kernel at 300Hz - HZ = lib.kernel.freeform "300"; - HZ_300 = lib.kernel.yes; - HZ_1000 = lib.kernel.no; - } - ( - optimizeWithFlags super.linux_6_12 [ - "-march=znver4" - "-mtune=znver4" - ] - ); - } - ) - ]; - - boot.kernelPackages = lib.mkIf (!config.me.buildingIso) (pkgs.linuxPackagesFor pkgs.linux_znver4); } From 95d06dfe0eefe4f343dcecd451dfd841fa47e2d8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 19 Jan 2025 21:29:24 -0500 Subject: [PATCH 03/15] Enable memtest86 when building the ISO. --- nix/configuration/configuration.nix | 1 + nix/configuration/roles/memtest86/default.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 nix/configuration/roles/memtest86/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 894d47b..0b591ca 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -54,6 +54,7 @@ ./roles/wasm ./roles/vnc_client ./roles/chromecast + ./roles/memtest86 ]; nix.settings.experimental-features = [ diff --git a/nix/configuration/roles/memtest86/default.nix b/nix/configuration/roles/memtest86/default.nix new file mode 100644 index 0000000..f552ba2 --- /dev/null +++ b/nix/configuration/roles/memtest86/default.nix @@ -0,0 +1,17 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + config = lib.mkMerge [ + { } + (lib.mkIf (config.me.buildingIso) { + # boot.loader.systemd-boot.memtest86.enable = true; + boot.loader.grub.memtest86.enable = true; + }) + ]; +} From ccbc999744ac13cd70ff173667832b99354ad406 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 19:27:49 -0500 Subject: [PATCH 04/15] Add a global options role. --- nix/configuration/configuration.nix | 1 + .../roles/global_options/default.nix | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 nix/configuration/roles/global_options/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 0b591ca..93effa2 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -9,6 +9,7 @@ { imports = [ ./roles/reset + ./roles/global_options ./util/unfree_polyfill ./roles/iso "${ diff --git a/nix/configuration/roles/global_options/default.nix b/nix/configuration/roles/global_options/default.nix new file mode 100644 index 0000000..a7b77ff --- /dev/null +++ b/nix/configuration/roles/global_options/default.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + + }; + + # options.me.graphicsCardType = lib.mkOption { + # type = lib.types.nullOr ( + # lib.types.enum [ + # "amd" + # "intel" + # "nvidia" + # ] + # ); + # default = null; + # example = "amd"; + # description = "What graphics card type is in the computer."; + # }; + + # options.me.graphical = lib.mkOption { + # type = lib.types.bool; + # default = false; + # example = true; + # description = "Whether we want to install graphical programs."; + # }; +} From 9d49eb9d6aa03fb5409803ab8de8460b927d83f9 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 19:40:54 -0500 Subject: [PATCH 05/15] Add an empty kodi role. --- nix/configuration/configuration.nix | 1 + nix/configuration/roles/blank/default.nix | 21 ++++++++++++++-- nix/configuration/roles/kodi/default.nix | 30 +++++++++++++++++++++++ nix/configuration/roles/sway/default.nix | 9 +++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 nix/configuration/roles/kodi/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 93effa2..b7a8691 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -56,6 +56,7 @@ ./roles/vnc_client ./roles/chromecast ./roles/memtest86 + ./roles/kodi ]; nix.settings.experimental-features = [ diff --git a/nix/configuration/roles/blank/default.nix b/nix/configuration/roles/blank/default.nix index 7f220e5..0b9310b 100644 --- a/nix/configuration/roles/blank/default.nix +++ b/nix/configuration/roles/blank/default.nix @@ -8,6 +8,23 @@ { imports = [ ]; - environment.systemPackages = with pkgs; [ - ]; + options.me = { + blank.enabled = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install blank."; + }; + }; + + config = lib.mkIf config.me.blank.enabled ( + lib.mkMerge [ + { + environment.systemPackages = with pkgs; [ + ]; + } + (lib.mkIf config.me.graphical { + }) + ] + ); } diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix new file mode 100644 index 0000000..e2e227f --- /dev/null +++ b/nix/configuration/roles/kodi/default.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + kodi.enabled = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install kodi."; + }; + }; + + config = lib.mkIf config.me.kodi.enabled ( + lib.mkMerge [ + { + environment.systemPackages = with pkgs; [ + ]; + } + (lib.mkIf config.me.graphical { + }) + ] + ); +} diff --git a/nix/configuration/roles/sway/default.nix b/nix/configuration/roles/sway/default.nix index 74faeb5..634d0a9 100644 --- a/nix/configuration/roles/sway/default.nix +++ b/nix/configuration/roles/sway/default.nix @@ -266,6 +266,15 @@ in ./notification.nix ]; + options.me = { + sway.enabled = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install sway."; + }; + }; + options.me.swayIncludes = lib.mkOption { type = lib.types.listOf lib.types.package; default = [ ]; From d0c1bb1b65b8c5408f029c3f37118b2443174469 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 20:06:33 -0500 Subject: [PATCH 06/15] Do not install sway on neelix. --- nix/configuration/hosts/neelix/default.nix | 2 ++ nix/configuration/hosts/odo/default.nix | 2 ++ nix/configuration/roles/blank/default.nix | 4 ++-- nix/configuration/roles/kodi/default.nix | 8 ++++++-- nix/configuration/roles/sway/default.nix | 4 ++-- nix/configuration/roles/sway/force_focus.nix | 2 +- nix/configuration/roles/sway/iso.nix | 2 +- nix/configuration/roles/sway/lockscreen.nix | 2 +- nix/configuration/roles/sway/notification.nix | 2 +- nix/configuration/roles/sway/rofimoji.nix | 18 +++++++++--------- nix/configuration/roles/sway/screenshot.nix | 2 +- 11 files changed, 28 insertions(+), 20 deletions(-) diff --git a/nix/configuration/hosts/neelix/default.nix b/nix/configuration/hosts/neelix/default.nix index bdcd7dd..34713d2 100644 --- a/nix/configuration/hosts/neelix/default.nix +++ b/nix/configuration/hosts/neelix/default.nix @@ -27,4 +27,6 @@ me.graphical = true; me.graphicsCardType = "intel"; + + me.kodi.enable = true; } diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 52c4081..2ff3b72 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -31,4 +31,6 @@ me.graphical = true; me.graphicsCardType = "amd"; + + me.sway.enable = true; } diff --git a/nix/configuration/roles/blank/default.nix b/nix/configuration/roles/blank/default.nix index 0b9310b..d38650e 100644 --- a/nix/configuration/roles/blank/default.nix +++ b/nix/configuration/roles/blank/default.nix @@ -9,7 +9,7 @@ imports = [ ]; options.me = { - blank.enabled = lib.mkOption { + blank.enable = lib.mkOption { type = lib.types.bool; default = false; example = true; @@ -17,7 +17,7 @@ }; }; - config = lib.mkIf config.me.blank.enabled ( + config = lib.mkIf config.me.blank.enable ( lib.mkMerge [ { environment.systemPackages = with pkgs; [ diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index e2e227f..2a7fac5 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -9,7 +9,7 @@ imports = [ ]; options.me = { - kodi.enabled = lib.mkOption { + kodi.enable = lib.mkOption { type = lib.types.bool; default = false; example = true; @@ -17,13 +17,17 @@ }; }; - config = lib.mkIf config.me.kodi.enabled ( + config = lib.mkIf config.me.kodi.enable ( lib.mkMerge [ { environment.systemPackages = with pkgs; [ ]; } (lib.mkIf config.me.graphical { + users.extraUsers.kodi.isNormalUser = true; + services.cage.user = "kodi"; + services.cage.program = "${pkgs.kodi-wayland}/bin/kodi-standalone"; + services.cage.enable = true; }) ] ); diff --git a/nix/configuration/roles/sway/default.nix b/nix/configuration/roles/sway/default.nix index 634d0a9..e0acb25 100644 --- a/nix/configuration/roles/sway/default.nix +++ b/nix/configuration/roles/sway/default.nix @@ -267,7 +267,7 @@ in ]; options.me = { - sway.enabled = lib.mkOption { + sway.enable = lib.mkOption { type = lib.types.bool; default = false; example = true; @@ -286,7 +286,7 @@ in description = "List of packages to import as sway configs."; }; - config = { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { environment.systemPackages = with pkgs; [ alacritty pcmanfm diff --git a/nix/configuration/roles/sway/force_focus.nix b/nix/configuration/roles/sway/force_focus.nix index 28bf8c8..d276cbf 100644 --- a/nix/configuration/roles/sway/force_focus.nix +++ b/nix/configuration/roles/sway/force_focus.nix @@ -19,7 +19,7 @@ in { imports = [ ]; - config = lib.mkIf config.me.graphical { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { me.swayIncludes = [ force_focus_sway_config ]; diff --git a/nix/configuration/roles/sway/iso.nix b/nix/configuration/roles/sway/iso.nix index 6882e71..66bbb1f 100644 --- a/nix/configuration/roles/sway/iso.nix +++ b/nix/configuration/roles/sway/iso.nix @@ -16,7 +16,7 @@ in { imports = [ ]; - config = lib.mkIf (config.me.buildingIso) { + config = lib.mkIf (config.me.buildingIso && config.me.graphical && config.me.sway.enable) { # Launch a terminal at boot in the live ISO for when hotkeys don't work. me.swayIncludes = [ launch_terminal diff --git a/nix/configuration/roles/sway/lockscreen.nix b/nix/configuration/roles/sway/lockscreen.nix index 79a81c2..7870852 100644 --- a/nix/configuration/roles/sway/lockscreen.nix +++ b/nix/configuration/roles/sway/lockscreen.nix @@ -25,7 +25,7 @@ in { imports = [ ]; - config = lib.mkIf config.me.graphical { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { me.swayIncludes = [ lockscreen_sway_config ]; diff --git a/nix/configuration/roles/sway/notification.nix b/nix/configuration/roles/sway/notification.nix index ae2f40c..2e3a790 100644 --- a/nix/configuration/roles/sway/notification.nix +++ b/nix/configuration/roles/sway/notification.nix @@ -24,7 +24,7 @@ in { imports = [ ]; - config = lib.mkIf config.me.graphical { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { me.swayIncludes = [ notification_sway_config ]; diff --git a/nix/configuration/roles/sway/rofimoji.nix b/nix/configuration/roles/sway/rofimoji.nix index 52929b5..b220e3f 100644 --- a/nix/configuration/roles/sway/rofimoji.nix +++ b/nix/configuration/roles/sway/rofimoji.nix @@ -17,7 +17,7 @@ in { imports = [ ]; - config = lib.mkIf config.me.graphical { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { me.swayIncludes = [ rofimoji_sway_config ]; @@ -49,14 +49,14 @@ in }) (final: prev: { tofi = pkgs.symlinkJoin { - name = "tofi"; - paths = [ prev.tofi ]; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/tofi-drun --add-flags --font=${pkgs.source-sans-pro}/share/fonts/opentype/SourceSansPro-Regular.otf --add-flags --config=${./files/tofi-config} - wrapProgram $out/bin/tofi --add-flags --config=${./files/tofi-config} - ''; - }; + name = "tofi"; + paths = [ prev.tofi ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/tofi-drun --add-flags --font=${pkgs.source-sans-pro}/share/fonts/opentype/SourceSansPro-Regular.otf --add-flags --config=${./files/tofi-config} + wrapProgram $out/bin/tofi --add-flags --config=${./files/tofi-config} + ''; + }; }) ]; }; diff --git a/nix/configuration/roles/sway/screenshot.nix b/nix/configuration/roles/sway/screenshot.nix index c1e55c8..0db8383 100644 --- a/nix/configuration/roles/sway/screenshot.nix +++ b/nix/configuration/roles/sway/screenshot.nix @@ -34,7 +34,7 @@ in { imports = [ ]; - config = lib.mkIf config.me.graphical { + config = lib.mkIf (config.me.graphical && config.me.sway.enable) { me.swayIncludes = [ screenshot_sway_config ]; From 5a5d34911cf866ac37d84c6043a645920f37f795 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 21:00:35 -0500 Subject: [PATCH 07/15] Add /etc/hosts entry for neelix. --- nix/configuration/roles/network/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/configuration/roles/network/default.nix b/nix/configuration/roles/network/default.nix index 17ec9e7..c3a14e8 100644 --- a/nix/configuration/roles/network/default.nix +++ b/nix/configuration/roles/network/default.nix @@ -40,6 +40,7 @@ 10.216.1.1 homeserver 10.216.1.6 media #10.216.1.12 odo + 10.216.1.14 neelix 10.217.1.1 drmario 10.217.2.1 mrmanager ''; From 368c455b7fb5a0f4119159a4d83c0936182a2075 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 22:38:54 -0500 Subject: [PATCH 08/15] Persist ssh keys for kodi user. --- nix/configuration/roles/kodi/default.nix | 44 +++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index 2a7fac5..3661a1b 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -24,10 +24,52 @@ ]; } (lib.mkIf config.me.graphical { - users.extraUsers.kodi.isNormalUser = true; services.cage.user = "kodi"; services.cage.program = "${pkgs.kodi-wayland}/bin/kodi-standalone"; services.cage.enable = true; + + nixpkgs.overlays = [ + (final: prev: { + kodi-wayland = prev.kodi-wayland.withPackages ( + kodiPkgs: with kodiPkgs; [ + joystick + ] + ); + }) + ]; + + users.users.kodi = { + isNormalUser = true; + createHome = true; # https://github.com/NixOS/nixpkgs/issues/6481 + group = "kodi"; + extraGroups = [ ]; + uid = 12000; + packages = with pkgs; [ + tree + ]; + # Generate with `mkpasswd -m scrypt` + hashedPassword = "$7$CU..../....VXvNQ8za3wSGpdzGXNT50/$HcFtn/yvwPMCw4888BelpiAPLAxe/zU87fD.d/N6U48"; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGu+k5lrirokdW5zVdRVBOqEOAvAPlIkG/MdJNc9g5ky" + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIEI6mu6I5Jp+Ib0vJxapGHbEShZjyvzV8jz5DnzDrI39AAAABHNzaDo=" + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIAFNcSXwvy+brYTOGo56G93Ptuq2MmZsjvRWAfMqbmMLAAAABHNzaDo=" + ]; + }; + users.groups.kodi.gid = 12000; + + environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) { + hideMounts = true; + users.kodi = { + directories = [ + { + directory = ".ssh"; + user = "kodi"; + group = "kodi"; + mode = "0755"; + } + ]; + }; + }; }) ] ); From c33a1b6c5039da140fe2a68300a8746ccbdf5baf Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 20 Jan 2025 22:50:44 -0500 Subject: [PATCH 09/15] Set up memtest86 on neelix. --- nix/configuration/roles/boot/default.nix | 2 ++ nix/configuration/roles/kodi/default.nix | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/nix/configuration/roles/boot/default.nix b/nix/configuration/roles/boot/default.nix index a75dfb1..3918e2f 100644 --- a/nix/configuration/roles/boot/default.nix +++ b/nix/configuration/roles/boot/default.nix @@ -41,6 +41,8 @@ # Automatically delete old generations boot.loader.systemd-boot.configurationLimit = 3; + boot.loader.systemd-boot.memtest86.enable = true; + # Check what will be lost with `zfs diff zroot/linux/root@blank` boot.initrd.systemd.enable = lib.mkDefault true; boot.initrd.systemd.services.zfs-rollback = { diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index 3661a1b..2018c3d 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -28,15 +28,16 @@ services.cage.program = "${pkgs.kodi-wayland}/bin/kodi-standalone"; services.cage.enable = true; - nixpkgs.overlays = [ - (final: prev: { - kodi-wayland = prev.kodi-wayland.withPackages ( - kodiPkgs: with kodiPkgs; [ - joystick - ] - ); - }) - ]; + # nixpkgs.overlays = [ + # (final: prev: { + # kodi-wayland = prev.kodi-wayland.withPackages ( + # kodiPkgs: with kodiPkgs; [ + # joystick + # vfs-sftp + # ] + # ); + # }) + # ]; users.users.kodi = { isNormalUser = true; From 48c5aebd827e2be24bbb11d305f315fd06919d9e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 21 Jan 2025 20:56:48 -0500 Subject: [PATCH 10/15] Install jmespath for ansible. --- nix/configuration/configuration.nix | 1 + nix/configuration/hosts/odo/default.nix | 1 + nix/configuration/roles/ansible/default.nix | 46 +++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 nix/configuration/roles/ansible/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index b7a8691..29bbbe7 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -57,6 +57,7 @@ ./roles/chromecast ./roles/memtest86 ./roles/kodi + ./roles/ansible ]; nix.settings.experimental-features = [ diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 2ff3b72..5690f4d 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -33,4 +33,5 @@ me.graphicsCardType = "amd"; me.sway.enable = true; + me.ansible.enable = true; } diff --git a/nix/configuration/roles/ansible/default.nix b/nix/configuration/roles/ansible/default.nix new file mode 100644 index 0000000..58a3d06 --- /dev/null +++ b/nix/configuration/roles/ansible/default.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + ansible.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install ansible."; + }; + }; + + config = lib.mkIf config.me.ansible.enable ( + lib.mkMerge [ + { + environment.systemPackages = with pkgs; [ + ansible + ]; + + nixpkgs.overlays = [ + (final: prev: { + ansible = pkgs.symlinkJoin { + name = "ansible"; + paths = [ + (prev.ansible.overridePythonAttrs { + propagatedBuildInputs = prev.ansible.propagatedBuildInputs ++ [ prev.python3Packages.jmespath ]; + }) + ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/ansible --prefix PATH : ${lib.makeBinPath [ ]} + ''; + }; + }) + ]; + } + ] + ); +} From a739728d418c8512b3187fa464cdb2dbe00f57c6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 21 Jan 2025 21:23:21 -0500 Subject: [PATCH 11/15] Add neelix public key to sftp server. --- ansible/roles/sftp/tasks/common.yaml | 17 +++++++++++++++++ nix/configuration/roles/kodi/default.nix | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/ansible/roles/sftp/tasks/common.yaml b/ansible/roles/sftp/tasks/common.yaml index 4a3821a..f1245ba 100644 --- a/ansible/roles/sftp/tasks/common.yaml +++ b/ansible/roles/sftp/tasks/common.yaml @@ -64,6 +64,23 @@ # force: true # diff: false +- name: Create directories + file: + name: "{{ item }}" + state: directory + mode: 0700 + owner: nochainstounlock + group: nochainstounlock + loop: + - /home/nochainstounlock/.ssh + +- name: Set authorized keys + authorized_key: + user: nochainstounlock + key: | + ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMrjXsXjtxEm47XnRZfo67kJULoc0NBLrB0lPYFiS2Ar kodi@neelix + exclusive: true + - import_tasks: tasks/freebsd.yaml when: 'os_flavor == "freebsd"' diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index 2018c3d..c2249a4 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -68,6 +68,12 @@ group = "kodi"; mode = "0755"; } + { + directory = ".kodi"; + user = "kodi"; + group = "kodi"; + mode = "0755"; + } ]; }; }; From 37aa0e6732e3f4a109c0e42660fd2400ae1b7b36 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 21 Jan 2025 22:19:28 -0500 Subject: [PATCH 12/15] Add a bluetooth role. --- nix/configuration/configuration.nix | 1 + nix/configuration/hosts/neelix/default.nix | 1 + nix/configuration/roles/bluetooth/default.nix | 46 +++++++++++++++++++ nix/configuration/roles/kodi/default.nix | 20 ++++---- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 nix/configuration/roles/bluetooth/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 29bbbe7..076fd14 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -58,6 +58,7 @@ ./roles/memtest86 ./roles/kodi ./roles/ansible + ./roles/bluetooth ]; nix.settings.experimental-features = [ diff --git a/nix/configuration/hosts/neelix/default.nix b/nix/configuration/hosts/neelix/default.nix index 34713d2..b3b0443 100644 --- a/nix/configuration/hosts/neelix/default.nix +++ b/nix/configuration/hosts/neelix/default.nix @@ -29,4 +29,5 @@ me.graphicsCardType = "intel"; me.kodi.enable = true; + me.bluetooth.enable = true; } diff --git a/nix/configuration/roles/bluetooth/default.nix b/nix/configuration/roles/bluetooth/default.nix new file mode 100644 index 0000000..eb026c6 --- /dev/null +++ b/nix/configuration/roles/bluetooth/default.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + bluetooth.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install bluetooth."; + }; + }; + + config = lib.mkIf config.me.bluetooth.enable ( + lib.mkMerge [ + { + environment.systemPackages = with pkgs; [ + ]; + + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + settings = { + General = { + # Enable support for showing battery charge level. + Experimental = true; + }; + }; + }; + + environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) { + hideMounts = true; + directories = [ + "/var/lib/bluetooth" # Bluetooth pairing information. + ]; + }; + } + ] + ); +} diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index c2249a4..39be875 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -28,16 +28,16 @@ services.cage.program = "${pkgs.kodi-wayland}/bin/kodi-standalone"; services.cage.enable = true; - # nixpkgs.overlays = [ - # (final: prev: { - # kodi-wayland = prev.kodi-wayland.withPackages ( - # kodiPkgs: with kodiPkgs; [ - # joystick - # vfs-sftp - # ] - # ); - # }) - # ]; + nixpkgs.overlays = [ + (final: prev: { + kodi-wayland = prev.kodi-wayland.withPackages ( + kodiPkgs: with kodiPkgs; [ + joystick + vfs-sftp + ] + ); + }) + ]; users.users.kodi = { isNormalUser = true; From edc48d00a2f2bd974bb854ec089287b0e42c69bf Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 21 Jan 2025 23:07:05 -0500 Subject: [PATCH 13/15] Add some config files. --- nix/configuration/roles/kodi/default.nix | 13 +++++++ .../DualSense_Wireless_Controller_13b_8a.xml | 38 +++++++++++++++++++ .../roles/kodi/files/mediasources.xml | 5 +++ 3 files changed, 56 insertions(+) create mode 100644 nix/configuration/roles/kodi/files/DualSense_Wireless_Controller_13b_8a.xml create mode 100644 nix/configuration/roles/kodi/files/mediasources.xml diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index 39be875..aa1b885 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -77,6 +77,19 @@ ]; }; }; + + home-manager.users.kodi = + { pkgs, ... }: + { + home.file.".kodi/userdata/mediasources.xml".source = ./files/mediasources.xml; + + home.file.".kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/DualSense_Wireless_Controller_13b_8a.xml".source = + ./files/DualSense_Wireless_Controller_13b_8a.xml; + + # The state version is required and should stay at the version you + # originally installed. + home.stateVersion = "24.11"; + }; }) ] ); diff --git a/nix/configuration/roles/kodi/files/DualSense_Wireless_Controller_13b_8a.xml b/nix/configuration/roles/kodi/files/DualSense_Wireless_Controller_13b_8a.xml new file mode 100644 index 0000000..8389c4b --- /dev/null +++ b/nix/configuration/roles/kodi/files/DualSense_Wireless_Controller_13b_8a.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nix/configuration/roles/kodi/files/mediasources.xml b/nix/configuration/roles/kodi/files/mediasources.xml new file mode 100644 index 0000000..2b5f26b --- /dev/null +++ b/nix/configuration/roles/kodi/files/mediasources.xml @@ -0,0 +1,5 @@ + + + sftp://nochainstounlock@stuff.fizz.buzz:42069/readonly/library/ + + From 4664804d9091b4fb2b27acb03848c8e64d41f5f2 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 22 Jan 2025 20:12:50 -0500 Subject: [PATCH 14/15] Comment out the kodi configs so they remain mutable until I've made a config I like. --- nix/configuration/roles/kodi/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nix/configuration/roles/kodi/default.nix b/nix/configuration/roles/kodi/default.nix index aa1b885..b37bf06 100644 --- a/nix/configuration/roles/kodi/default.nix +++ b/nix/configuration/roles/kodi/default.nix @@ -81,10 +81,13 @@ home-manager.users.kodi = { pkgs, ... }: { - home.file.".kodi/userdata/mediasources.xml".source = ./files/mediasources.xml; + # home.file.".kodi/userdata/mediasources.xml".source = ./files/mediasources.xml; - home.file.".kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/DualSense_Wireless_Controller_13b_8a.xml".source = - ./files/DualSense_Wireless_Controller_13b_8a.xml; + # home.file.".kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/DualSense_Wireless_Controller_13b_8a.xml".source = + # ./files/DualSense_Wireless_Controller_13b_8a.xml; + + # TODO: Maybe .kodi/userdata/sources.xml + # TODO: ./userdata/guisettings.xml:303: 128 # The state version is required and should stay at the version you # originally installed. From 93c4aa4c765c4f70dca262dbbfc8897ba6650a3f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 22 Jan 2025 20:28:58 -0500 Subject: [PATCH 15/15] Clean up the host-specific configs. --- nix/configuration/hosts/neelix/default.nix | 2 -- .../hosts/neelix/power_management.nix | 15 ++------------- .../hosts/neelix/screen_brightness.nix | 14 -------------- nix/configuration/hosts/neelix/wifi.nix | 16 ---------------- 4 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 nix/configuration/hosts/neelix/screen_brightness.nix delete mode 100644 nix/configuration/hosts/neelix/wifi.nix diff --git a/nix/configuration/hosts/neelix/default.nix b/nix/configuration/hosts/neelix/default.nix index b3b0443..926d60c 100644 --- a/nix/configuration/hosts/neelix/default.nix +++ b/nix/configuration/hosts/neelix/default.nix @@ -5,8 +5,6 @@ ./disk-config.nix ./optimized_build.nix ./power_management.nix - ./screen_brightness.nix - ./wifi.nix ]; # Generate with `head -c4 /dev/urandom | od -A none -t x4` diff --git a/nix/configuration/hosts/neelix/power_management.nix b/nix/configuration/hosts/neelix/power_management.nix index 99bdbe2..c63a7a9 100644 --- a/nix/configuration/hosts/neelix/power_management.nix +++ b/nix/configuration/hosts/neelix/power_management.nix @@ -20,24 +20,13 @@ "nowatchdog" ]; + # default performance balance_performance balance_power power + # defaults to balance_performance # systemd.tmpfiles.rules = [ - # "w- /sys/firmware/acpi/platform_profile - - - - low-power" # "w- /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference - - - - power" # "w- /sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference - - - - power" # "w- /sys/devices/system/cpu/cpufreq/policy2/energy_performance_preference - - - - power" # "w- /sys/devices/system/cpu/cpufreq/policy3/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy4/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy5/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy6/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy7/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy8/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy9/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy10/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy11/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy12/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy13/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy14/energy_performance_preference - - - - power" - # "w- /sys/devices/system/cpu/cpufreq/policy15/energy_performance_preference - - - - power" # ]; boot.extraModprobeConfig = '' diff --git a/nix/configuration/hosts/neelix/screen_brightness.nix b/nix/configuration/hosts/neelix/screen_brightness.nix deleted file mode 100644 index 8314d0e..0000000 --- a/nix/configuration/hosts/neelix/screen_brightness.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -{ - imports = [ ]; - - # systemd.tmpfiles.rules = [ - # "w- /sys/class/backlight/amdgpu_bl1/brightness - - - - 85" - # ]; -} diff --git a/nix/configuration/hosts/neelix/wifi.nix b/nix/configuration/hosts/neelix/wifi.nix deleted file mode 100644 index a1c136d..0000000 --- a/nix/configuration/hosts/neelix/wifi.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -{ - imports = [ ]; - - # config = { - # environment.loginShellInit = lib.mkIf (!config.me.buildingIso) '' - # doas iw dev wlan0 set power_save off - # ''; - # }; -}