From fb7b45f98d91dac764bee263bf51a37053e34b24 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Tue, 15 Oct 2024 03:25:56 -0400 Subject: [PATCH] feat!: change machine hostnames Instead of merely naming my systems "laptop", "desktop", etc. (boring), I now have them named after Aristotelian elements (cool). This also gives me an excuse to refactor my flake file. --- README.md | 2 +- config/battery.nix | 2 +- config/config.nix | 18 ++--- config/login.nix | 2 +- flake.nix | 68 +++++++++---------- .../{mobile.nix => air.nix} | 0 .../{desktop.nix => earth.nix} | 0 .../{laptop.nix => fire.nix} | 0 home-manager/wayland/eww/eww.yuck | 52 +++++++------- home-manager/wayland/waybar.nix | 4 +- home-manager/wayland/wltools.nix | 2 +- machine.nix | 7 ++ platform.nix | 7 -- 13 files changed, 81 insertions(+), 83 deletions(-) rename hardware-configuration/{mobile.nix => air.nix} (100%) rename hardware-configuration/{desktop.nix => earth.nix} (100%) rename hardware-configuration/{laptop.nix => fire.nix} (100%) create mode 100644 machine.nix delete mode 100644 platform.nix diff --git a/README.md b/README.md index e278f2c..168d310 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is my repository for my NixOS configurations for each of my devices, most of which share the majority of their code. -## Screenshot (Laptop) +## Screenshot (`toki-fire`) ![screenshot](/assets/screenshot.png) diff --git a/config/battery.nix b/config/battery.nix index 7ccad1e..bfb66c8 100644 --- a/config/battery.nix +++ b/config/battery.nix @@ -1,5 +1,5 @@ { config, lib, ... }: -lib.mkIf (config.platform == "laptop") { +lib.mkIf (config.machine == "fire") { services.upower = { enable = true; diff --git a/config/config.nix b/config/config.nix index 05d580b..e288ea6 100644 --- a/config/config.nix +++ b/config/config.nix @@ -1,15 +1,15 @@ { config, pkgs, lib, username, fullname, ... }: let - inherit (config) platform; - isMobile = platform == "mobile"; + inherit (config) machine; + isMobile = machine == "air"; hashedPassword = - if platform == "desktop" then - "$6$HYibiGhDN.JgLtw6$cecU7NjfumTUJSkFNFQG4uVgdd3tTPLGxK0zHAwYn3un/V43IUlyVBNKoRMLCQk65RckbD/.AjsLFVFKUUHVA/" - else if platform == "laptop" then - "$6$y3eb1phxFWnParRT$w1LNfxJ2ByHoiBa5ywh4STGuIK/r4Tnyxx2Xe/nlovrE6LuuLAVdKRFAroUTtUI/d2BNGI9ErjZ2z2Dl7w/t00" - else # if platform == "mobile" - "$6$vmmMT7pEY1W0Bj9R$Kb6nuwdg/KzCrGcUPkEo2jJ6a2NJRikiOeN8/I8ObU1K6rVYvgYqPVgPg9NkLaUScdh1PWcabuvaHCFLMw14A0"; + if machine == "earth" then + "$y$j9T$rpQs/Fnsxh4DNw4qDSvTu.$nzA1EskOnWrYM.Iba7q73O.QPEn3DFWrX2.KY8mKza." + else if machine == "fire" then + "$y$j9T$EXc0TFu9LQhQ9YGrOkb7u0$LpwNG0XpUIVSltLqUw7CAOLSsI2rZr1RTBnJai5dkM7" + else # if machine == "air" + "$y$j9T$zF34p.W/HFKrWde5Rb1nq/$1Q5IN9IT.IQ6SLg8InUZM5L27.jQV.cRtNENnUPp0ZC"; in { nix.package = pkgs.nixFlakes; @@ -24,7 +24,7 @@ in boot.loader.systemd-boot.enable = !isMobile; boot.loader.efi.canTouchEfiVariables = !isMobile; - networking.hostName = "kiana-${platform}"; + networking.hostName = "toki-${machine}"; networking.wireless.enable = false; networking.networkmanager.enable = true; diff --git a/config/login.nix b/config/login.nix index d714d7b..08c68e2 100644 --- a/config/login.nix +++ b/config/login.nix @@ -10,7 +10,7 @@ let mv * $out/share/sddm/themes/tokyo-night-sddm ''; }; -in lib.mkIf (config.platform != "mobile") { +in lib.mkIf (config.machine != "air") { environment.systemPackages = with pkgs.libsForQt5; [ tokyo-night-sddm # Theme qtbase diff --git a/flake.nix b/flake.nix index 7ff82b4..60cbbde 100644 --- a/flake.nix +++ b/flake.nix @@ -31,52 +31,51 @@ outputs = { self, moduleArgs = { inherit username fullname email; } // inputs; mkConfig = - { platform, + { machine, system ? "x86_64-linux", configModules ? [ ./config ], configExtraModules ? [], homeModules ? [ ./home-manager ], homeExtraModules ? [] }: - nixpkgs.lib.nixosSystem { - inherit system; - modules = - configModules ++ - configExtraModules ++ - [ - ./platform.nix - { _module.args = moduleArgs; - inherit platform; } - ./hardware-configuration/${platform}.nix + { + "toki-${machine}" = nixpkgs.lib.nixosSystem { + inherit system; + modules = + configModules ++ + configExtraModules ++ + [ + ./machine.nix + { _module.args = moduleArgs; + inherit machine; } + ./hardware-configuration/${machine}.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = moduleArgs; - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = moduleArgs; - - home-manager.sharedModules = [ ./platform.nix { inherit platform; } ]; - home-manager.users.${username} = { - imports = homeModules ++ homeExtraModules; - }; - } - ]; + home-manager.sharedModules = [ ./machine.nix { inherit machine; } ]; + home-manager.users.${username} = { + imports = homeModules ++ homeExtraModules; + }; + } + ]; + }; }; in { - nixosConfigurations = { - "${username}-desktop" = mkConfig { - platform = "desktop"; - }; - - "${username}-laptop" = mkConfig { - platform = "laptop"; + nixosConfigurations = + mkConfig { + machine = "earth"; + } // + mkConfig { + machine = "fire"; configExtraModules = [ nixos-hardware.nixosModules.microsoft-surface-pro-intel ]; - }; - - "${username}-mobile" = mkConfig { - platform = "mobile"; + } // + mkConfig { + machine = "air"; system = "aarch64-linux"; configExtraModules = [ ./mobile/config.nix @@ -89,6 +88,5 @@ outputs = { self, ./mobile/home-manager.nix ]; }; - }; }; } diff --git a/hardware-configuration/mobile.nix b/hardware-configuration/air.nix similarity index 100% rename from hardware-configuration/mobile.nix rename to hardware-configuration/air.nix diff --git a/hardware-configuration/desktop.nix b/hardware-configuration/earth.nix similarity index 100% rename from hardware-configuration/desktop.nix rename to hardware-configuration/earth.nix diff --git a/hardware-configuration/laptop.nix b/hardware-configuration/fire.nix similarity index 100% rename from hardware-configuration/laptop.nix rename to hardware-configuration/fire.nix diff --git a/home-manager/wayland/eww/eww.yuck b/home-manager/wayland/eww/eww.yuck index 20dcd39..92f2272 100644 --- a/home-manager/wayland/eww/eww.yuck +++ b/home-manager/wayland/eww/eww.yuck @@ -249,7 +249,7 @@ ;; Bar Layout -(defwidget laptop_bar_left_edge [] +(defwidget fire_bar_left_edge [] (box :orientation "h" :space-evenly false :halign "start" @@ -257,17 +257,17 @@ (bar_window :class-limit 60 :title-limit 50))) -(defwidget laptop_bar_left_wing [] +(defwidget fire_bar_left_wing [] (box :orientation "h" :space-evenly false :halign "end" :hexpand true (bar_time :width 175))) -(defwidget laptop_bar_center [] +(defwidget fire_bar_center [] (bar_workspaces)) -(defwidget laptop_bar_right_wing [] +(defwidget fire_bar_right_wing [] (box :orientation "h" :space-evenly false :hexpand true @@ -275,7 +275,7 @@ :artist-limit 30 :title-limit 25))) -(defwidget laptop_bar_right_edge [] +(defwidget fire_bar_right_edge [] (box :orientation "h" :space-evenly false :halign "end" @@ -292,22 +292,22 @@ (bar_sep) (bar_idleinhibit))) -(defwidget laptop_bar_layout [] +(defwidget fire_bar_layout [] (centerbox :class "bar" :orientation "h" (box :orientation "h" :space-evenly false :hexpand true - (laptop_bar_left_edge) - (laptop_bar_left_wing)) - (laptop_bar_center) + (fire_bar_left_edge) + (fire_bar_left_wing)) + (fire_bar_center) (box :orientation "h" :space-evenly false - (laptop_bar_right_wing) - (laptop_bar_right_edge)))) + (fire_bar_right_wing) + (fire_bar_right_edge)))) -(defwidget desktop_bar_left_edge [] +(defwidget earth_bar_left_edge [] (box :orientation "h" :space-evenly false :halign "start" @@ -315,17 +315,17 @@ (bar_window :class-limit 90 :title-limit 80))) -(defwidget desktop_bar_left_wing [] +(defwidget earth_bar_left_wing [] (box :orientation "h" :space-evenly false :halign "end" :hexpand true (bar_time :width 175))) -(defwidget desktop_bar_center [] +(defwidget earth_bar_center [] (bar_workspaces)) -(defwidget desktop_bar_right_wing [] +(defwidget earth_bar_right_wing [] (box :orientation "h" :space-evenly false :hexpand true @@ -333,7 +333,7 @@ :artist-limit 30 :title-limit 25))) -(defwidget desktop_bar_right_edge [] +(defwidget earth_bar_right_edge [] (box :orientation "h" :space-evenly false :halign "end" @@ -348,22 +348,22 @@ (bar_sep) (bar_idleinhibit))) -(defwidget desktop_bar_layout [] +(defwidget earth_bar_layout [] (centerbox :class "bar" :orientation "h" (box :orientation "h" :space-evenly false :hexpand true - (desktop_bar_left_edge) - (desktop_bar_left_wing)) - (desktop_bar_center) + (earth_bar_left_edge) + (earth_bar_left_wing)) + (earth_bar_center) (box :orientation "h" :space-evenly false - (desktop_bar_right_wing) - (desktop_bar_right_edge)))) + (earth_bar_right_wing) + (earth_bar_right_edge)))) -(defwindow laptop_bar +(defwindow fire_bar :monitor 0 :geometry (geometry :width "100%" :height "3%" @@ -372,9 +372,9 @@ :stacking "fg" :exclusive true :focusable false - (laptop_bar_layout)) + (fire_bar_layout)) -(defwindow desktop_bar +(defwindow earth_bar :monitor 0 :geometry (geometry :width "100%" :height "3%" @@ -383,4 +383,4 @@ :stacking "fg" :exclusive true :focusable false - (desktop_bar_layout)) + (earth_bar_layout)) diff --git a/home-manager/wayland/waybar.nix b/home-manager/wayland/waybar.nix index b470853..d41d1ec 100644 --- a/home-manager/wayland/waybar.nix +++ b/home-manager/wayland/waybar.nix @@ -15,7 +15,7 @@ modules-center = [ "hyprland/window" ]; modules-right = - if config.platform == "laptop" then + if config.machine == "fire" then [ "battery" "pulseaudio" "backlight" "network" "clock" "idle_inhibitor" ] else [ "pulseaudio" "network" "clock" "idle_inhibitor" ]; @@ -217,7 +217,7 @@ #pulseaudio { background-color: @altblend; ${ - if config.platform == "laptop" then + if config.machine == "fire" then '' margin: 3px 0px 3px 2px; padding-right: 5px; diff --git a/home-manager/wayland/wltools.nix b/home-manager/wayland/wltools.nix index a417f06..0c1448e 100644 --- a/home-manager/wayland/wltools.nix +++ b/home-manager/wayland/wltools.nix @@ -143,7 +143,7 @@ # WLuma - # systemd.user.services.wluma = lib.mkIf (config.platform == "laptop") { + # systemd.user.services.wluma = lib.mkIf (config.machine== "fire") { # Install.WantedBy = [ "graphical-session.target" ]; # Unit = { diff --git a/machine.nix b/machine.nix new file mode 100644 index 0000000..c3d7e77 --- /dev/null +++ b/machine.nix @@ -0,0 +1,7 @@ +{ lib, ... }: +{ + options.machine = lib.mkOption { + description = "The machine hostname to configure for"; + type = lib.types.enum [ "earth" "fire" "air" "water" ]; + }; +} diff --git a/platform.nix b/platform.nix deleted file mode 100644 index cf06ca2..0000000 --- a/platform.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ lib, ... }: -{ - options.platform = lib.mkOption { - description = "The platform to configure for"; - type = lib.types.str; - }; -}