Files
Nomarchy/lib.nix
Bernardo Magri eda8461304 feat(system): Plymouth splash, distroName, allowUnfree, offline-pin hardening
- Plymouth boot splash ported from the legacy branch (modules/nixos/
  plymouth/): logo + eased progress + LUKS entry, background tinted from
  theme-state.json via the new nomarchy.system.stateFile (wired by
  mkFlake/lib.nix; null → Tokyo Night fallback). Default on; OFF on the
  live ISO (boot-message visibility on the install medium). Pulls
  boot.initrd.systemd, which also drives the keyboard-at-LUKS feature.
- system.nixos.distroName = "Nomarchy" (os-release PRETTY_NAME,
  systemd-boot entries, ISO menu label). distroId left "nixos" (feeds
  DEFAULT_HOSTNAME + upstream isNixos checks — roadmapped).
- nixpkgs.config.allowUnfree distro-wide (here + both import-nixpkgs
  sites) — unblocks claude-code for the menu's ask-Claude module.
- systemd-boot.configurationLimit = 10 so entries don't fill the ESP.
- Live ISO: nomarchy.idle.enable = false — hypridle was suspending the
  VM mid-install (the install-hung regression); installed systems keep it.
- flake.nix offline pins (verified 0-leak via a foreign-identity
  gap-analysis probe): the repo's own standalone HM gen + inputDerivations,
  mustache-go + stdenv (stylix re-renders base16 per switch), microcode-amd/
  intel (enableRedistributableFirmware activated updateMicrocode →
  source-build cascade), buildEnv's builder.pl, findXMLCatalogs, and the
  representativeInstall mirror (xkb/initrd-systemd/microcode).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 07:37:32 +01:00

100 lines
3.9 KiB
Nix

# Downstream sugar: one call wires a whole machine flake.
# Users own ONLY system.nix, home.nix and theme-state.json; their flake.nix
# is generated once (by `nix flake init -t` or the future installer) and
# never hand-edited. The raw exports (nixosModules/homeModules/overlays)
# in flake.nix remain the escape hatch for power users.
{ nixpkgs, home-manager, nixos-hardware, nomarchy }:
{
mkFlake =
{ src # the downstream flake directory (./.)
, username # login name; also the homeConfigurations attr
, hardwareProfile ? null # nixos-hardware module name(s): string, list, or null
, system ? "x86_64-linux"
}:
let
inherit (nixpkgs) lib;
# One profile or several (the installer's autodetection emits a few
# common-* modules alongside the model-specific one).
profileNames =
if hardwareProfile == null then [ ]
else if builtins.isList hardwareProfile then hardwareProfile
else [ hardwareProfile ];
lookupProfile = name:
if builtins.hasAttr name nixos-hardware.nixosModules then
nixos-hardware.nixosModules.${name}
else
throw ''
nomarchy.lib.mkFlake: unknown hardwareProfile "${name}".
${let
close = builtins.filter
(candidate: lib.strings.levenshteinAtMost 3 candidate name)
(builtins.attrNames nixos-hardware.nixosModules);
in
lib.optionalString (close != [ ])
"Did you mean: ${lib.concatStringsSep ", " close}?\n"
}Valid names are the attribute names of nixos-hardware.nixosModules:
https://github.com/NixOS/nixos-hardware
or list them locally with:
nix eval github:NixOS/nixos-hardware#nixosModules --apply builtins.attrNames
Omit hardwareProfile entirely if your machine has no profile.
'';
hardwareModules = map lookupProfile profileNames;
pkgs = import nixpkgs {
inherit system;
overlays = [ nomarchy.overlays.default ];
# Matches nixpkgs.config.allowUnfree in modules/nixos: the system
# and the standalone HM desktop see the same package set.
config.allowUnfree = true;
};
in
{
# System layer — rebuilt rarely:
# sudo nixos-rebuild switch --flake .#default
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit username; };
modules =
[
nomarchy.nixosModules.nomarchy
# The standalone HM CLI ships with the system so theme switching
# (`nomarchy-theme-sync apply` → `home-manager switch`) works
# out of the box — same pinned input as the desktop modules.
{ environment.systemPackages = [ home-manager.packages.${system}.home-manager ]; }
# System-side theme consumers (Plymouth splash background)
# read the same JSON the desktop does.
{ nomarchy.system.stateFile = src + "/theme-state.json"; }
]
++ hardwareModules
++ [
(src + "/hardware-configuration.nix") # from nixos-generate-config
(src + "/system.nix")
];
};
# Desktop layer — every theme change, no sudo:
# home-manager switch --flake .#<username>
# (`nomarchy-theme-sync apply` runs this for you.)
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
nomarchy.homeModules.nomarchy
(src + "/home.nix")
{
# Written by nomarchy-theme-sync; reading it is pure — the
# file is part of the downstream flake's source.
nomarchy.stateFile = src + "/theme-state.json";
home = {
inherit username;
homeDirectory = "/home/${username}";
};
}
];
};
};
}