From 44062a87b479834507fc008c0b79b5d4d6452aa1 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Tue, 29 Jul 2025 13:56:25 -0400 Subject: [PATCH] abstracted host definitions in flake.nix --- flake.lock | 210 ++++---------------------- flake.nix | 197 ++++-------------------- lib/default.nix | 17 +++ lib/mk_host.nix | 60 ++++++++ modules/home/environment/waybar.nix | 53 ++----- overlay/scripts/commands/toolbelt.nix | 4 +- 6 files changed, 150 insertions(+), 391 deletions(-) create mode 100644 lib/default.nix create mode 100644 lib/mk_host.nix diff --git a/flake.lock b/flake.lock index b1c08d3..5380573 100755 --- a/flake.lock +++ b/flake.lock @@ -135,22 +135,6 @@ } }, "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1747046372, - "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -210,25 +194,7 @@ }, "flake-utils": { "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_4" + "systems": "systems_3" }, "locked": { "lastModified": 1731533236, @@ -260,28 +226,6 @@ "type": "github" } }, - "ghostty": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2", - "zig": "zig", - "zon2nix": "zon2nix" - }, - "locked": { - "lastModified": 1752781573, - "narHash": "sha256-lciLQos2xk62PrLi/RbD12V8Da5xAysPnhP4KvI3Jho=", - "owner": "ghostty-org", - "repo": "ghostty", - "rev": "155ddc3f8f0e99731d30f15653c62ac7e2476c46", - "type": "github" - }, - "original": { - "owner": "ghostty-org", - "repo": "ghostty", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ @@ -343,7 +287,7 @@ }, "hypr-contrib": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1752069516, @@ -427,9 +371,9 @@ "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_3", "pre-commit-hooks": "pre-commit-hooks", - "systems": "systems_2", + "systems": "systems", "xdph": "xdph" }, "locked": { @@ -574,8 +518,8 @@ "inputs": { "hyprutils": "hyprutils_2", "hyprwayland-scanner": "hyprwayland-scanner_2", - "nixpkgs": "nixpkgs_5", - "systems": "systems_3" + "nixpkgs": "nixpkgs_4", + "systems": "systems_2" }, "locked": { "lastModified": 1750371999, @@ -691,21 +635,6 @@ "type": "github" } }, - "impermanence": { - "locked": { - "lastModified": 1737831083, - "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", - "owner": "nix-community", - "repo": "impermanence", - "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "impermanence", - "type": "github" - } - }, "ixx": { "inputs": { "flake-utils": [ @@ -751,19 +680,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1748189127, - "narHash": "sha256-zRDR+EbbeObu4V2X5QCd2Bk5eltfDlCr5yvhBwUT6pY=", - "rev": "7c43f080a7f28b2774f3b3f43234ca11661bf334", - "type": "tarball", - "url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.802491.7c43f080a7f2/nixexprs.tar.xz" - }, - "original": { - "type": "tarball", - "url": "https://channels.nixos.org/nixos-25.05/nixexprs.tar.xz" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1712163089, "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=", @@ -779,7 +695,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1751792365, "narHash": "sha256-J1kI6oAj25IG4EdVlg2hQz8NZTBNYvIS0l4wpr9KcUo=", @@ -795,7 +711,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_4": { "locked": { "lastModified": 1748929857, "narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=", @@ -811,7 +727,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_5": { "locked": { "lastModified": 1752480373, "narHash": "sha256-JHQbm+OcGp32wAsXTE/FLYGNpb+4GLi5oTvCxwSoBOA=", @@ -827,7 +743,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_6": { "locked": { "lastModified": 1751792365, "narHash": "sha256-J1kI6oAj25IG4EdVlg2hQz8NZTBNYvIS0l4wpr9KcUo=", @@ -850,7 +766,7 @@ "nixpkgs" ], "nuschtosSearch": "nuschtosSearch", - "systems": "systems_5" + "systems": "systems_4" }, "locked": { "lastModified": 1752762787, @@ -893,7 +809,7 @@ }, "nuschtosSearch": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "ixx": "ixx", "nixpkgs": [ "nixvim", @@ -916,7 +832,7 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "gitignore": "gitignore", "nixpkgs": [ "hyprland", @@ -940,13 +856,11 @@ "root": { "inputs": { "disko": "disko", - "ghostty": "ghostty", "home-manager": "home-manager", "hypr-contrib": "hypr-contrib", "hyprland": "hyprland", "hyprpicker": "hyprpicker", - "impermanence": "impermanence", - "nixpkgs": "nixpkgs_6", + "nixpkgs": "nixpkgs_5", "nixvim": "nixvim", "spicetify-nix": "spicetify-nix", "stylix": "stylix" @@ -957,7 +871,7 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems_6" + "systems": "systems_5" }, "locked": { "lastModified": 1752381641, @@ -982,9 +896,9 @@ "firefox-gnome-theme": "firefox-gnome-theme", "flake-parts": "flake-parts_2", "gnome-shell": "gnome-shell", - "nixpkgs": "nixpkgs_7", + "nixpkgs": "nixpkgs_6", "nur": "nur", - "systems": "systems_7", + "systems": "systems_6", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -1007,16 +921,16 @@ }, "systems": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "default-linux", "type": "github" } }, @@ -1037,16 +951,16 @@ }, "systems_3": { "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default-linux", + "repo": "default", "type": "github" } }, @@ -1095,21 +1009,6 @@ "type": "github" } }, - "systems_7": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "tinted-foot": { "flake": false, "locked": { @@ -1231,61 +1130,6 @@ "repo": "xdg-desktop-portal-hyprland", "type": "github" } - }, - "zig": { - "inputs": { - "flake-compat": [ - "ghostty", - "flake-compat" - ], - "flake-utils": [ - "ghostty", - "flake-utils" - ], - "nixpkgs": [ - "ghostty", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1748261582, - "narHash": "sha256-3i0IL3s18hdDlbsf0/E+5kyPRkZwGPbSFngq5eToiAA=", - "owner": "mitchellh", - "repo": "zig-overlay", - "rev": "aafb1b093fb838f7a02613b719e85ec912914221", - "type": "github" - }, - "original": { - "owner": "mitchellh", - "repo": "zig-overlay", - "type": "github" - } - }, - "zon2nix": { - "inputs": { - "flake-utils": [ - "ghostty", - "flake-utils" - ], - "nixpkgs": [ - "ghostty", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1742104771, - "narHash": "sha256-LhidlyEA9MP8jGe1rEnyjGFCzLLgCdDpYeWggibayr0=", - "owner": "jcollie", - "repo": "zon2nix", - "rev": "56c159be489cc6c0e73c3930bd908ddc6fe89613", - "type": "github" - }, - "original": { - "owner": "jcollie", - "repo": "zon2nix", - "rev": "56c159be489cc6c0e73c3930bd908ddc6fe89613", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f4f2313..f7e9f7f 100755 --- a/flake.nix +++ b/flake.nix @@ -7,8 +7,6 @@ hyprpicker.url = "github:hyprwm/hyprpicker"; stylix.url = "github:danth/stylix"; disko.url = "github:nix-community/disko"; - impermanence.url = "github:nix-community/impermanence"; - ghostty.url = "github:ghostty-org/ghostty"; nixvim = { url = "github:nix-community/nixvim"; @@ -32,176 +30,39 @@ }; }; - outputs = { self, home-manager, disko, nixpkgs, impermanence, nixvim, stylix, ... }@inputs: + outputs = { ... }@inputs: let - system = "x86_64-linux"; - username = "pagedmov"; - nixpkgsConfig = { - allowUnfree = true; - }; - in { - homeConfigurations = { - oganessonHome = let host = "oganesson"; in home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { inherit host; root = self; }) - ]; - }; - extraSpecialArgs = { - inherit host self username inputs; - }; - - modules = [ - ./hosts/desktop/home.nix - ./modules/home - stylix.homeModules.stylix - nixvim.homeManagerModules.nixvim - ]; - }; - phosphorousHome = let host = "phosphorous"; in home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { inherit host; root = self; }) - ]; - }; - extraSpecialArgs = { - inherit host self username inputs; - }; - - modules = [ - ./hosts/work/home.nix - ./modules/home - stylix.homeModules.stylix - nixvim.homeManagerModules.nixvim - ]; - }; - - mercuryHome = let host = "mercury"; in home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { inherit host; root = self; }) - ]; - }; - extraSpecialArgs = { - inherit host self username inputs; - }; - - modules = [ - ./hosts/laptop/home.nix - ./modules/home - stylix.homeModules.stylix - nixvim.homeManagerModules.nixvim - ]; - }; - - xenonHome = let host = "xenon"; in home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { inherit host; root = self; }) - ]; - }; - extraSpecialArgs = { - inherit host self username inputs; - }; - - modules = [ - ./hosts/server/home.nix - ./modules/home - stylix.homeModules.stylix - nixvim.homeManagerModules.nixvim - ]; - }; + movLib = import ./lib { + inherit inputs; + username = "pagedmov"; }; - nixosConfigurations = { - oganesson = nixpkgs.lib.nixosSystem { # Desktop - specialArgs = { - inherit self inputs username; - host = "oganesson"; - overlays = [ - (import ./overlay/overlay.nix { root = self; }) - ]; - }; - inherit system; - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { root = self; }) - ]; - }; - modules = [ - ./hosts/desktop/config.nix - ./modules/sys - stylix.nixosModules.stylix - ]; - }; - - phosphorous = nixpkgs.lib.nixosSystem { # Desktop - specialArgs = { - inherit self inputs username; - host = "oganesson"; - overlays = [ - (import ./overlay/overlay.nix { root = self; }) - ]; - }; - inherit system; - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - overlays = [ - (import ./overlay/overlay.nix { root = self; }) - ]; - }; - modules = [ - ./hosts/work/config.nix - ./modules/sys - stylix.nixosModules.stylix - ]; - }; - - mercury = nixpkgs.lib.nixosSystem { # Laptop - specialArgs = { - inherit self inputs username; - host = "mercury"; - }; - inherit system; - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - }; - modules = [ - ./hosts/laptop/config.nix - ./modules/sys - stylix.nixosModules.stylix - ]; - }; - - xenon = nixpkgs.lib.nixosSystem { # Server - specialArgs = { - inherit self inputs username; - host = "xenon"; - }; - inherit system; - pkgs = import nixpkgs { - inherit system; - config = nixpkgsConfig; - }; - modules = [ - ./hosts/server/config.nix - ./modules/sys + hosts = movLib.foldHosts [ + { + host = "oganesson"; + hostDir = "desktop"; + kind = "both"; + } + { + host = "phosphorous"; + hostDir = "work"; + kind = "both"; + } + { + host = "mercury"; + hostDir = "laptop"; + kind = "both"; + } + { + host = "xenon"; + hostDir = "server"; + kind = "both"; + extraNixosModules = [ ./modules/server - stylix.nixosModules.stylix ]; - }; - }; + } + ]; + in { + inherit (hosts) nixosConfigurations homeConfigurations; }; } diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..ff92af2 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,17 @@ +{ inputs, username, nixpkgsConfig ? { allowUnfree = true; } }: + +let + mkHost = import ./mk_host.nix; +in +{ + inherit mkHost; + foldHosts = hosts: inputs.nixpkgs.lib.foldl' + (acc: host: + let result = mkHost ({ inherit inputs username nixpkgsConfig; } // host); + in { + nixosConfigurations = acc.nixosConfigurations // result.nixosConfigurations; + homeConfigurations = acc.homeConfigurations // result.homeConfigurations; + }) + { nixosConfigurations = {}; homeConfigurations = {}; } + hosts; +} diff --git a/lib/mk_host.nix b/lib/mk_host.nix new file mode 100644 index 0000000..553b924 --- /dev/null +++ b/lib/mk_host.nix @@ -0,0 +1,60 @@ +{ + inputs, + username, + nixpkgsConfig ? { allowUnfree = true; }, + host, + hostDir, + system ? "x86_64-linux", + kind, + extraNixosModules ? [], + extraHomeModules ? [], + overlay ? true +}: + +let + nixosModules = [ + ../hosts/${hostDir}/config.nix + ../modules/sys + inputs.stylix.nixosModules.stylix + ] ++ extraNixosModules; + homeModules = [ + ../hosts/${hostDir}/home.nix + ../modules/home + inputs.stylix.homeModules.stylix + inputs.nixvim.homeManagerModules.nixvim + ] ++ extraHomeModules; + pkgs = import inputs.nixpkgs { + inherit system; + config = nixpkgsConfig; + overlays = if overlay then [ + (import ../overlay/overlay.nix { inherit host; root = inputs.self; }) + ] else []; + }; + specialArgs = { + inherit inputs username host; + self = inputs.self; + }; + + nixosCfg = + if kind == "nixos" || kind == "both" then + inputs.nixpkgs.lib.nixosSystem { + inherit system pkgs specialArgs; + modules = nixosModules; + } + else + null; + + homeCfg = + if kind == "home" || kind == "both" then + inputs.home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = specialArgs; + modules = homeModules; + } + else + null; +in + { + nixosConfigurations = if kind == "nixos" || kind == "both" then { ${host} = nixosCfg; } else {}; + homeConfigurations = if kind == "home" || kind == "both" then { ${host + "Home"} = homeCfg; } else {}; + } diff --git a/modules/home/environment/waybar.nix b/modules/home/environment/waybar.nix index 4a72b99..283b9a9 100755 --- a/modules/home/environment/waybar.nix +++ b/modules/home/environment/waybar.nix @@ -1,7 +1,6 @@ -{ pkgs, host, lib, config, ... }: +{ pkgs, lib, config, ... }: let - desktop = (host == "oganesson"); layout = config.movOpts.envConfig.hyprlandConfig.workspaceLayout; workspaces = { format = "{icon}"; @@ -55,20 +54,7 @@ let lighter = scheme.base05; light = scheme.base04; }; - colors = { - color0 = scheme.base08; - color1 = scheme.base09; - color2 = scheme.base0A; - color3 = scheme.base0B; - color4 = scheme.base0C; - color5 = scheme.base0D; - color6 = scheme.base0E; - color7 = scheme.base0F; - }; monitors = config.movOpts.envConfig.hyprlandConfig.monitorNames; - circle-gauge = [ "󰝦" "󰪞" "󰪟" "󰪠" "󰪡" "󰪢" "󰪣" "󰪤" "󰪥" ]; - cava-gauge = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ]; - battery-gauge = [ "󰁺" "󰁻" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; bar-gauge = [ "░░░░░░░░" "█░░░░░░░" @@ -80,6 +66,17 @@ let "███████░" "████████" ]; + bar-gauge-critical = [ + "░░░░░░░░" + "█░░░░░░░" + "██░░░░░░" + "███░░░░░" + "████░░░░" + "█████░░░" + "██████░░" + "!!!!!!!!" + "CRITICAL" + ]; in { options = { movOpts.envConfig.waybarConfig.enable = @@ -159,17 +156,7 @@ in { interval = 20; format = "MEM: [ {icon} ] {percentage}%"; tooltip-format = "MEM_TOT\t: {total}GiB\nSWP_TOT\t: {swapTotal}GiB\n\nMEM_USD\t: {used:0.1f}GiB\nSWP_USD\t: {swapUsed:0.1f}GiB"; - format-icons = [ - "░░░░░░░░" - "█░░░░░░░" - "██░░░░░░" - "███░░░░░" - "████░░░░" - "█████░░░" - "██████░░" - "!!!!!!!!" - "CRITICAL" - ]; + format-icons = bar-gauge-critical; }; cpu = { @@ -177,23 +164,13 @@ in { interval = 1; format = "CPU: [ {icon} ] {usage}%"; tooltip = true; - format-icons = [ - "░░░░░░░░" - "█░░░░░░░" - "██░░░░░░" - "███░░░░░" - "████░░░░" - "█████░░░" - "██████░░" - "!!!!!!!!" - "CRITICAL" - ]; + format-icons = bar-gauge-critical; }; }; }; style = '' * { - font-size: 14px; + font-size: 16px; border: none; font-family: EnvyCodeR Nerd Font Mono; font-weight: Bold; diff --git a/overlay/scripts/commands/toolbelt.nix b/overlay/scripts/commands/toolbelt.nix index e421948..4442447 100755 --- a/overlay/scripts/commands/toolbelt.nix +++ b/overlay/scripts/commands/toolbelt.nix @@ -26,8 +26,8 @@ pkgs.writeShellApplication { cliphist decode "$selection" | wl-copy } btop_cmd() { - - if [ "$(cat /etc/hostname)" = "oganesson" ]; then + hostname="$(cat /etc/hostname)" + if [ "$hostname" = "oganesson" ] || [ "$hostname" = "phosphorous" ]; then hyprctl dispatch resizeactive 20% 155% && moveonscreen --center && btop &&