From a68ee40b016a59c3b1e63746ab9b19a598861870 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 16 Feb 2025 21:22:30 -0600 Subject: [PATCH] chore: migrate foxtrot nixosConfiguration package --- lib/default.nix | 4 +- lib/host.nix | 36 ++ .../nixos/deno-netlify-ddns-client.nix | 6 +- packages/hosts/default.nix | 33 +- packages/hosts/dragon.nix | 2 + packages/hosts/foxtrot.nix | 329 +++--------------- packages/machines.nix | 65 ---- 7 files changed, 101 insertions(+), 374 deletions(-) create mode 100644 lib/host.nix diff --git a/lib/default.nix b/lib/default.nix index 8cfb577..1fc112b 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,4 @@ -{ self, ... }: +{ self, ... }@inputs: let forSelfOverlay = if builtins.hasAttr "overlays" self && builtins.hasAttr "forSelf" self.overlays then @@ -17,4 +17,6 @@ rec { forSystems = nixpkgs: nixpkgs.lib.genAttrs systems; pkgsFor = nixpkgs: system: (import nixpkgs { inherit system; }).extend forSelfOverlay; genPkgs = nixpkgs: func: (forSystems nixpkgs (system: func (pkgsFor nixpkgs system))); + + inherit (import ./host.nix inputs) host stableHost; } diff --git a/lib/host.nix b/lib/host.nix new file mode 100644 index 0000000..1a86be5 --- /dev/null +++ b/lib/host.nix @@ -0,0 +1,36 @@ +inputs: +let + baseHost = + { + nixpkgs, + home-manager, + ... + }: + ( + path: + ( + { + system ? "x86_64-linux", + }: + (nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { + inherit home-manager; + hardware = inputs.hardware.outputs.nixosModules; + diskoConfigurations = inputs.self.outputs.diskoConfigurations; + }; + modules = [ + inputs.self.outputs.nixosModules.default + (import path) + ]; + }) + ) + ); +in +{ + stableHost = baseHost { inherit (inputs) nixpkgs home-manager; }; + host = baseHost { + nixpkgs = inputs.nixpkgs-unstable; + home-manager = inputs.home-manager-unstable; + }; +} diff --git a/lib/modules/nixos/deno-netlify-ddns-client.nix b/lib/modules/nixos/deno-netlify-ddns-client.nix index 2a208b1..8a8f8d9 100644 --- a/lib/modules/nixos/deno-netlify-ddns-client.nix +++ b/lib/modules/nixos/deno-netlify-ddns-client.nix @@ -52,9 +52,9 @@ in }; }; - config = { + config = mkIf cfg.enable { systemd.timers.deno-netlify-ddns-client = { - enable = mkIf cfg.enable true; + enable = true; after = [ "network.target" ]; wantedBy = [ "timers.target" ]; timerConfig = { @@ -65,7 +65,7 @@ in }; systemd.services.deno-netlify-ddns-client = { - enable = mkIf cfg.enable true; + enable = true; after = [ "network.target" ]; script = '' set -eu diff --git a/packages/hosts/default.nix b/packages/hosts/default.nix index 030f84a..f435375 100644 --- a/packages/hosts/default.nix +++ b/packages/hosts/default.nix @@ -1,39 +1,10 @@ inputs: let - baseHost = - { - nixpkgs, - home-manager, - ... - }: - ( - path: - ( - { - system ? "x86_64-linux", - }: - (nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit home-manager; - hardware = inputs.hardware.outputs.nixosModules; - diskoConfigurations = inputs.self.outputs.diskoConfigurations; - }; - modules = [ - inputs.self.outputs.nixosModules.default - (import path) - ]; - }) - ) - ); - stableHost = baseHost { inherit (inputs) nixpkgs home-manager; }; - host = baseHost { - nixpkgs = inputs.nixpkgs-unstable; - home-manager = inputs.home-manager-unstable; - }; + inherit (inputs.self.flakeLib) host stableHost; in { beefcake = stableHost ./beefcake.nix { }; dragon = host ./dragon.nix { }; + foxtrot = host ./foxtrot.nix { }; # arm-dragon = host ./dragon.nix { system = "aarch64-linux"; }; } diff --git a/packages/hosts/dragon.nix b/packages/hosts/dragon.nix index b1f02f0..979bded 100644 --- a/packages/hosts/dragon.nix +++ b/packages/hosts/dragon.nix @@ -49,6 +49,8 @@ lyte.desktop.enable = true; home-manager.users.daniel = { + lyte.shell.enable = true; + lyte.desktop.enable = true; slippi-launcher = { enable = true; isoPath = "${config.users.users.daniel.home}/../games/roms/dolphin/melee.iso"; diff --git a/packages/hosts/foxtrot.nix b/packages/hosts/foxtrot.nix index 2d959d5..8661d8b 100644 --- a/packages/hosts/foxtrot.nix +++ b/packages/hosts/foxtrot.nix @@ -1,211 +1,24 @@ -{ pkgs, ... }: { - imports = [ - { - system.stateVersion = "24.11"; - home-manager.users.daniel.home.stateVersion = "24.11"; - networking.hostName = "foxtrot"; - } - { - swapDevices = [ - # TODO: move this to disko? - # NOTE(oninstall): - /* - sudo btrfs subvolume create /swap - sudo btrfs filesystem mkswapfile --size 32g --uuid clear /swap/swapfile - sudo swapon /swap/swapfile - */ - ]; - # findmnt -no UUID -T /swap/swapfile - # boot.resumeDevice = "/dev/disk/by-uuid/81c3354a-f629-4b6b-a249-7705aeb9f0d5"; - # systemd.sleep.extraConfig = "HibernateDelaySec=180m"; - services.fwupd.enable = true; - services.fwupd.extraRemotes = [ "lvfs-testing" ]; - } - ]; - - environment = { - systemPackages = with pkgs; [ - easyeffects - godot_4 - fractal - prismlauncher - upower - acpi - prismlauncher - radeontop - sops - xh - ]; - }; - - home-manager.users.daniel = { - home = { - pointerCursor = { - size = 40; - }; - }; - - services.easyeffects = { - enable = true; - preset = "philonmetal"; - # clone from https://github.com/ceiphr/ee-framework-presets - # then `cp *.json ~/.config/easyeffects/output` - # TODO: nixify this - }; - - programs.hyprlock.settings = { - label = [ - { - monitor = ""; - font_size = 32; - - halign = "center"; - valign = "center"; - text_align = "center"; - color = "rgba(255, 255, 255, 0.5)"; - - position = "0 -500"; - font_family = "IosevkaLyteTerm"; - text = "cmd[update:30000] acpi"; - - shadow_passes = 3; - shadow_size = 1; - shadow_color = "rgba(0, 0, 0, 1.0)"; - shadow_boost = 1.0; - } - ]; - }; - services.hypridle = - let - secondsPerMinute = 60; - lockSeconds = 10 * secondsPerMinute; - in - { - settings = { - listener = [ - { - timeout = lockSeconds + 55; - on-timeout = ''systemctl suspend''; - } - ]; - }; - }; - - wayland.windowManager.hyprland = { - settings = { - exec-once = [ - "eww open bar0" - ]; - # See https://wiki.hyprland.org/Configuring/Keywords/ for more - monitor = [ - "eDP-1,2880x1920@120Hz,0x0,1.5" - ]; - }; - }; - - wayland.windowManager.sway = { - config = { - output = { - "BOE NE135A1M-NY1 Unknown" = { - mode = "2880x1920@120Hz"; - position = "1092,2160"; - scale = toString (5 / 3); - }; - - "Dell Inc. DELL U2720Q CWTM623" = { - mode = "3840x2160@60Hz"; - position = "0,0"; - scale = toString 1.25; - }; - - /* - "BOE 0x0BCA Unknown" = { - mode = "2256x1504@60Hz"; - position = "0,0"; - scale = toString scale; - }; - - "Dell Inc. DELL U2720Q D3TM623" = { - # desktop left vertical monitor - mode = "1920x1080@60Hz"; - # transform = "90"; - # scale = "1.5"; - position = "${toString (builtins.floor (2256 / scale))},0"; - }; - */ - }; - }; - }; - }; - - hardware.graphics.extraPackages = [ - # pkgs.rocmPackages.clr.icd - pkgs.amdvlk - - # encoding/decoding acceleration - pkgs.libvdpau-va-gl - pkgs.vaapiVdpau - ]; - - hardware.amdgpu = { - amdvlk = { - enable = true; - support32Bit = { - enable = true; - }; - }; - }; - - networking.networkmanager.wifi.powersave = false; - - hardware.framework.amd-7040.preventWakeOnAC = true; + pkgs, + hardware, + diskoConfigurations, + # homeConfigurations, + ... +}: +{ + system.stateVersion = "24.11"; + networking.hostName = "foxtrot"; boot = { - # kernelPackages = pkgs.linuxPackages_latest; - - # https://github.com/void-linux/void-packages/issues/50417#issuecomment-2131802836 fix framework 13 not shutting down - /* - kernelPatches = [ - { - name = "framework13shutdownfix"; - patch = builtins.fetchurl { - url = "https://github.com/void-linux/void-packages/files/15445612/0001-Add-hopefully-a-solution-for-shutdown-regression.PATCH"; - sha256 = "sha256:10zcnzy5hkam2cnxx441b978gzhvnqlcc49k7bpz9dc28xyjik50"; - }; - } - ]; - */ - loader = { efi.canTouchEfiVariables = true; - systemd-boot = { - enable = true; - extraEntries = { - "arch.conf" = '' - title Arch - efi /efi/Arch/grubx64.efi - ''; - }; - }; + systemd-boot.enable = true; }; - - # NOTE(oninstall): - /* - sudo filefrag -v /swap/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}' - the above won't work for btrfs, instead you need btrfs inspect-internal map-swapfile -r /swap/swapfile - https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file - many of these come from https://wiki.archlinux.org/title/Framework_Laptop_13#Suspend - */ kernelParams = [ "rtc_cmos.use_acpi_alarm=1" "amdgpu.sg_display=0" "boot.shell_on_fail=1" "acpi_osi=\"!Windows 2020\"" - - # "nvme.noacpi=1" # maybe causing crashes upon waking? - - # NOTE(oninstall): "resume_offset=3421665" ]; initrd.availableKernelModules = [ @@ -215,87 +28,55 @@ ]; kernelModules = [ "kvm-amd" ]; }; - hardware.bluetooth = { - enable = true; - # TODO: when resuming from hibernation, it would be nice if this would - # simply resume the power state at the time of hibernation - powerOnBoot = false; - package = pkgs.bluez.overrideAttrs ( - finalAttrs: previousAttrs: rec { - version = "5.78"; - src = pkgs.fetchurl { - url = "mirror://kernel/linux/bluetooth/bluez-${version}.tar.xz"; - sha256 = "sha256-gw/tGRXF03W43g9eb0X83qDcxf9f+z0x227Q8A1zxeM="; - }; - patches = [ ]; - buildInputs = previousAttrs.buildInputs ++ [ - pkgs.python3Packages.pygments - ]; - } - ); + imports = with hardware; [ + diskoConfigurations.foxtrot + framework-13-7040-amd + ]; + + networking.networkmanager.wifi.powersave = false; + hardware = { + framework.amd-7040.preventWakeOnAC = true; + bluetooth = { + enable = true; + package = pkgs.bluez.overrideAttrs ( + finalAttrs: previousAttrs: rec { + version = "5.78"; + src = pkgs.fetchurl { + url = "mirror://kernel/linux/bluetooth/bluez-${version}.tar.xz"; + sha256 = "sha256-gw/tGRXF03W43g9eb0X83qDcxf9f+z0x227Q8A1zxeM="; + }; + patches = [ ]; + buildInputs = previousAttrs.buildInputs ++ [ + pkgs.python3Packages.pygments + ]; + } + ); + }; }; powerManagement.cpuFreqGovernor = "ondemand"; - /* - powerManagement.resumeCommands = '' - modprobe -rv mt7921e - modprobe -v mt7921e - ''; - */ - - services.power-profiles-daemon = { - enable = true; - }; - - services.fprintd = { - enable = true; - package = pkgs.fprintd.overrideAttrs { - # Source: https://github.com/NixOS/nixpkgs/commit/87ca2dc071581aea0e691c730d6844f1beb07c9f - # mesonCheckFlags = [ - # PAM related checks are timing out - # "--no-suite" - # "fprintd:TestPamFprintd" - # ]; - }; - }; - - /* - services.tlp = { + services = { + fwupd.extraRemotes = [ "lvfs-testing" ]; + power-profiles-daemon = { enable = true; - settings = { - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_SCALING_GOVERNOR_ON_BAT = "ondemand"; - CPU_MIN_PERF_ON_BAT = 0; - CPU_MAX_PERF_ON_BAT = 80; - - CPU_SCALING_GOVERNOR_ON_AC = "performance"; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - CPU_MIN_PERF_ON_AC = 0; - CPU_MAX_PERF_ON_AC = 100; - }; }; - */ + fprintd = { + enable = true; + }; + }; - networking.firewall.allowedTCPPorts = - let - stardewValley = 24642; - factorio = 34197; - in - [ - 8000 # dev stuff - factorio - stardewValley - 7777 - ]; - networking.firewall.allowedUDPPorts = - let - stardewValley = 24642; - factorio = 34197; - in - [ - 8000 # dev stuff - factorio - stardewValley - 7777 - ]; + networking.wifi.enable = true; + lyte.desktop.enable = true; + + home-manager.users.daniel = { + lyte.shell.enable = true; + lyte.desktop.enable = true; + services.easyeffects = { + enable = true; + preset = "philonmetal"; + # clone from https://github.com/ceiphr/ee-framework-presets + # then `cp *.json ~/.config/easyeffects/output` + # TODO: nixify this + }; + }; } diff --git a/packages/machines.nix b/packages/machines.nix index 9d2695f..d9c5508 100644 --- a/packages/machines.nix +++ b/packages/machines.nix @@ -101,71 +101,6 @@ in ]; }; - foxtrot = nixpkgs-unstable.lib.nixosSystem { - system = "x86_64-linux"; - modules = with nixosModules; [ - home-manager-unstable-defaults - - outputs.diskoConfigurations.foxtrot - hardware.nixosModules.framework-13-7040-amd - - common - kde-connect - password-manager - graphical-workstation - # plasma6 - # virtual-machines - # virtual-machines-gui - laptop - gaming - cross-compiler - - ./nixos/foxtrot.nix - - ( - { pkgs, ... }: - { - home-manager.users.daniel = { - imports = with homeManagerModules; [ - senpai - iex - niri - cargo - linux-desktop-environment-config - ]; - }; - environment.systemPackages = with pkgs; [ - fw-ectool - (writeShellApplication { - name = "reset-wifi-module"; - runtimeInputs = with pkgs; [ kmod ]; - text = '' - modprobe -rv mt7921e - modprobe -v mt7921e - ''; - }) - (writeShellApplication { - name = "perfmode"; - # we use command -v $cmd here because we only want to invoke these calls _if_ the related package is installed on the system - # otherwise, they will likely have no effect anyways - text = '' - command -v powerprofilesctl &>/dev/null && bash -x -c 'powerprofilesctl set balanced' - command -v swaymsg &>/dev/null && bash -x -c 'swaymsg output eDP-1 mode 2880x1920@120Hz' - ''; - }) - (writeShellApplication { - name = "battmode"; - text = '' - command -v powerprofilesctl &>/dev/null && bash -x -c 'powerprofilesctl set power-saver' - command -v swaymsg &>/dev/null && bash -x -c 'swaymsg output eDP-1 mode 2880x1920@60Hz' - ''; - }) - ]; - } - ) - ]; - }; - thablet = nixpkgs-unstable.lib.nixosSystem { system = "x86_64-linux"; modules = with nixosModules; [