feat: nomarchy.lib.mkFlake — one-call downstream wrapper + hardware profiles

Downstream users now own only system.nix and home.nix; their flake.nix is
generated once from the template and never hand-edited. mkFlake (lib.nix)
wires both layers and maps hardwareProfile = "<name>" to nixos-hardware
modules (new input, pinned here, nixpkgs follows ours; unknown names fail
with did-you-mean suggestions). Flake checks evaluate the template through
mkFlake — including a real profile — so drift fails `nix flake check`.

Also from the live-VM testing session: install the home-manager CLI in the
live ISO and pin flake inputs transitively (offline theme switching needs
stylix's own inputs too), plus swww→awww doc updates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-06-10 15:38:57 +01:00
parent 8a0ec763e0
commit 1f22e996dc
9 changed files with 557 additions and 67 deletions

View File

@@ -1,8 +1,13 @@
# My Nomarchy machine
1. `nixos-generate-config --show-hardware-config > hardware-configuration.nix`
2. Edit `flake.nix` (Nomarchy repo URL, username), `system.nix` (hostname,
user), `home.nix` (your packages).
1. Overwrite the placeholder hardware config with the real one:
`nixos-generate-config --show-hardware-config > hardware-configuration.nix`
2. Set `flake.nix` up **once** (Nomarchy repo URL, your username, optionally
a `hardwareProfile` from <https://github.com/NixOS/nixos-hardware> — an
unknown name fails the rebuild with suggestions). After that the flake is
never touched again: your machine lives in `system.nix` (hostname,
services — the login user is created from `username` automatically) and
`home.nix` (your packages).
3. `git init && git add -A` — flakes only see tracked files, including
`theme-state.json`.
4. System: `sudo nixos-rebuild switch --flake .#default`

View File

@@ -1,53 +1,20 @@
{
description = "My Nomarchy machine";
inputs = {
# Pin Nomarchy; nixpkgs and home-manager follow whatever it ships.
nomarchy.url = "github:YOUR-USER/nomarchy"; # <- point at the distro repo
nixpkgs.follows = "nomarchy/nixpkgs";
home-manager.follows = "nomarchy/home-manager";
};
# The only input. nixpkgs, home-manager etc. come pinned through it —
# tested together upstream. This file is written once (by you or the
# installer) and never hand-edited afterwards; your machine lives in
# system.nix and home.nix.
inputs.nomarchy.url = "github:YOUR-USER/nomarchy"; # <- the distro repo
outputs = { self, nomarchy, nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
outputs = { nomarchy, ... }:
nomarchy.lib.mkFlake {
src = ./.;
username = "me"; # <- your login name
pkgs = import nixpkgs {
inherit system;
overlays = [ nomarchy.overlays.default ];
};
in
{
# System layer — rebuilt rarely:
# sudo nixos-rebuild switch --flake .#default
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
nomarchy.nixosModules.nomarchy # the distro
./hardware-configuration.nix # from `nixos-generate-config`
./system.nix # your machine
];
};
# Desktop layer — rebuilt on every theme change, no sudo:
# home-manager switch --flake .#me
# (`nomarchy-theme-sync apply <theme>` runs this for you.)
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
nomarchy.homeModules.nomarchy
./home.nix
{
# Your theme state — written by nomarchy-theme-sync, baked
# in on every switch. Keep it git-tracked.
nomarchy.stateFile = ./theme-state.json;
home = {
inherit username;
homeDirectory = "/home/${username}";
};
}
];
};
# Optional: a nixos-hardware module name for your machine, e.g.
# hardwareProfile = "framework-13-7040-amd";
# Names: https://github.com/NixOS/nixos-hardware
# (the future installer fills this in automatically from DMI data)
};
}

View File

@@ -0,0 +1,15 @@
# PLACEHOLDER — replace with the output of `nixos-generate-config` on the
# target machine. The mkDefault values below only exist so the flake
# evaluates and `nix flake check` passes before first install.
{ lib, ... }:
{
boot.initrd.availableKernelModules = lib.mkDefault [ "xhci_pci" "ahci" "nvme" "usbhid" "sd_mod" ];
fileSystems."/" = lib.mkDefault {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

View File

@@ -2,7 +2,7 @@
# The distro itself comes from nomarchy.nixosModules.nomarchy — override
# any of its defaults here with plain NixOS options (they use mkDefault),
# or via the nomarchy.system.* toggles.
{ pkgs, ... }:
{ pkgs, username, ... }:
{
boot.loader.systemd-boot.enable = true;
@@ -12,7 +12,8 @@
time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8";
users.users.me = { # <- keep in sync with `username` in flake.nix
# Your login user — `username` flows in from flake.nix automatically.
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "video" "input" ];
};