feat: initial m3ta-home structure
- flake.nix with nixpkgs, home-manager, nix-colors, m3ta-nixpkgs, agenix, NUR inputs - lib/mkHome.nix: compose HM config from user + identity + context + sets - profiles/base: shell, cli-tools, secrets (always loaded) - profiles/contexts/desktop: WM, apps, theme, ghostty - profiles/contexts/server: minimal headless - profiles/sets/coding: core (git, direnv, jq, rg), editor, lsp, languages, agents - profiles/sets/gaming: steam, gamescope, gpu - profiles/sets/media: obs, ffmpeg, kdenlive, handbrake, yt-dlp - users/m3tam3re/identities: private.nix, work.nix (git, jj, ssh per identity) - users/m3tam3re/preferences: cliphist, difftastic, base packages
This commit is contained in:
11
lib/default.nix
Normal file
11
lib/default.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
# lib/default.nix — Entry point for m3ta-home library functions.
|
||||
#
|
||||
# Provides:
|
||||
# mkHome — compose a complete HM config from user + identity + context + sets
|
||||
# mkDevShell — create project-level dev shells from language sets
|
||||
{inputs}: {
|
||||
mkHome = import ./mkHome.nix {inherit inputs;};
|
||||
|
||||
# TODO: mkDevShell for project-level flake devShells
|
||||
# mkDevShell = import ./mkDevShell.nix { inherit inputs; };
|
||||
}
|
||||
103
lib/mkHome.nix
Normal file
103
lib/mkHome.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
# lib/mkHome.nix — Compose a complete home-manager configuration.
|
||||
#
|
||||
# This is the central function that replaces the old mkHomeConfig from nixos-config.
|
||||
# It assembles imports based on three dimensions:
|
||||
#
|
||||
# WHO you are → user + identity (preferences + git/ssh/jj config)
|
||||
# WHAT you do → context (desktop|server) + sets (coding, gaming, media)
|
||||
# WHERE you are → host (handled by nixos-config, only overrides here)
|
||||
#
|
||||
# Usage:
|
||||
# imports = [ (m3ta-lib.mkHome {
|
||||
# user = "m3tam3re";
|
||||
# identity = "private"; # or "work"
|
||||
# context = "desktop"; # or "server"
|
||||
# sets = [ "coding" "gaming" "media" ];
|
||||
# }) ];
|
||||
#
|
||||
# Then override host-specific settings in the consuming module:
|
||||
# m3ta.home.sets.coding.languages.python.extra = true;
|
||||
# wayland.windowManager.hyprland.settings.monitor = [ ... ];
|
||||
#
|
||||
{inputs}:
|
||||
{lib ? inputs.nixpkgs.lib}:
|
||||
let
|
||||
# --- Module path helpers ---
|
||||
profilePath = ../profiles;
|
||||
userPath = ../users;
|
||||
|
||||
# Always loaded — CLI tools, shell, secrets, overlays
|
||||
baseModule = "${profilePath}/base";
|
||||
|
||||
# Context modules — mutually exclusive (desktop or server)
|
||||
contextModuleMap = {
|
||||
desktop = "${profilePath}/contexts/desktop";
|
||||
server = "${profilePath}/contexts/server";
|
||||
};
|
||||
|
||||
# Feature sets — freely combinable, some have context guards
|
||||
setModuleMap = {
|
||||
coding = "${profilePath}/sets/coding";
|
||||
gaming = "${profilePath}/sets/gaming";
|
||||
media = "${profilePath}/sets/media";
|
||||
};
|
||||
|
||||
# Sets that require desktop context
|
||||
desktopOnlySets = ["gaming" "media"];
|
||||
in {
|
||||
mkHome = {
|
||||
user ? "m3tam3re",
|
||||
identity ? "private",
|
||||
context ? null,
|
||||
sets ? [],
|
||||
}: let
|
||||
# User preferences — always loaded (shell style, editor config, etc.)
|
||||
preferencesPath = "${userPath}/${user}/preferences";
|
||||
|
||||
# Identity — git name/email, SSH match blocks, jj config
|
||||
identityPath = "${userPath}/${user}/identities/${identity}.nix";
|
||||
|
||||
# Resolve context module
|
||||
contextImport =
|
||||
if context == null
|
||||
then []
|
||||
else if builtins.hasAttr context contextModuleMap
|
||||
then [contextModuleMap.${context}]
|
||||
else throw "m3ta-home: unknown context '${context}'. Valid: desktop, server";
|
||||
|
||||
# Resolve set modules
|
||||
setImports =
|
||||
map
|
||||
(s:
|
||||
if builtins.hasAttr s setModuleMap
|
||||
then setModuleMap.${s}
|
||||
else throw "m3ta-home: unknown set '${s}'. Valid: ${lib.concatStringsSep ", " (builtins.attrNames setModuleMap)}")
|
||||
sets;
|
||||
|
||||
# Validation: desktop-only sets
|
||||
usedDesktopOnlySets =
|
||||
builtins.filter (s: builtins.elem s desktopOnlySets) sets;
|
||||
in {
|
||||
imports =
|
||||
[
|
||||
baseModule
|
||||
preferencesPath
|
||||
identityPath
|
||||
]
|
||||
++ contextImport
|
||||
++ setImports;
|
||||
|
||||
assertions =
|
||||
[
|
||||
{
|
||||
assertion = builtins.elem context ["desktop" "server" null];
|
||||
message = "m3ta-home: context must be 'desktop', 'server', or null (got: '${toString context}')";
|
||||
}
|
||||
]
|
||||
++ map (s: {
|
||||
assertion = context == "desktop";
|
||||
message = "m3ta-home: set '${s}' requires context = 'desktop'";
|
||||
})
|
||||
usedDesktopOnlySets;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user