abstracted host definitions in flake.nix

This commit is contained in:
2025-07-29 13:56:25 -04:00
parent bd1851f706
commit 44062a87b4
6 changed files with 150 additions and 391 deletions

210
flake.lock generated
View File

@@ -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",

197
flake.nix
View File

@@ -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;
};
}

17
lib/default.nix Normal file
View File

@@ -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;
}

60
lib/mk_host.nix Normal file
View File

@@ -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 {};
}

View File

@@ -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 = [
""
""
""
""
""
""
""
"<span color='#F07178'>!!!!!!!!</span>"
"<span color='#F07178'>CRITICAL</span>"
];
in {
options = {
movOpts.envConfig.waybarConfig.enable =
@@ -159,17 +156,7 @@ in {
interval = 20;
format = "MEM: [ <span color='#272D38'>{icon}</span> ] <span size='8pt'>{percentage}%</span>";
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 = [
""
""
""
""
""
""
""
"<span color='#F07178'>!!!!!!!!</span>"
"<span color='#F07178'>CRITICAL</span>"
];
format-icons = bar-gauge-critical;
};
cpu = {
@@ -177,23 +164,13 @@ in {
interval = 1;
format = "CPU: [ <span color='#272D38'>{icon}</span> ] <span size='8pt'>{usage}%</span>";
tooltip = true;
format-icons = [
""
""
""
""
""
""
""
"<span color='#272D38'>!!!!!!!!</span>"
"<span color='#272D38'>CRITICAL</span>"
];
format-icons = bar-gauge-critical;
};
};
};
style = ''
* {
font-size: 14px;
font-size: 16px;
border: none;
font-family: EnvyCodeR Nerd Font Mono;
font-weight: Bold;

View File

@@ -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 &&