Switch to the dendritic flake-parts layout, with stubs for phase 2
flake.nix now only declares inputs and calls flake-parts with import-tree
over ./modules: every .nix file under modules/ is a flake-parts module.
Features are aspects (flake.modules.nixos.<name> and
flake.modules.homeManager.<name>); importing an aspect enables it, so the
my.* option modules and their enable flags are gone.
- Add the flake-parts glue: modules/flake/ (systems, shared meta data,
host construction through configurations.nixos, overlays, packages,
apps, dev shell, formatter, checks), modules/users/faumaray.nix
(meta.owner) and modules/core/{nixpkgs,home-manager,install-facts}.nix.
config.my is kept as one read-only derived option so install-system
keeps working unchanged.
- Add the aspects that are already final: secrets, ssh, hyprland,
wezterm, git, stylix, proxy-suite, gitea-runner and claude-code, and
the desktop host (modules/hosts/desktop/{host,hardware,disks}.nix).
- Port the always-on basics to the `core` aspect (nix, boot, locale,
networking, users), lanzaboote and plain systemd-boot to the
`secure-boot` and `systemd-boot` aspects, and the installer ISO to
modules/installer/iso.nix. Behaviour is unchanged; the time zone,
default locale, XKB layouts and the firewall setting now live in
modules/hosts/desktop/host.nix.
- Move the Lua files (Hyprland settings, binds, rules; Neovim init.lua)
with git mv, byte-identical.
- Add bare stubs, marked STUB, for the aspects that the next phase
ports: amd, rocm, gaming, vpn, docker, noctalia, audio, fonts, xdg,
apps, shell and neovim. The host evaluates with them, but those
features are not configured until they are ported.
- Remove lib/, overlays/, apps/, modules/nixos/, modules/home/,
modules/installer/default.nix and hosts/desktop/{default,disks,home}.nix.
- flake.lock: add flake-parts, import-tree, stylix and serena with their
transitive inputs (22 new nodes); every existing pin is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZ16yf4acmaSiHq81vyQ6Z
This commit is contained in:
84 files changed
+2121
-1928
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# `nix run .#<app>`: install and key/secret helpers (../../pkgs).
|
||||
{
|
||||
perSystem =
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
app = pkg: description: {
|
||||
program = lib.getExe pkg;
|
||||
meta.description = description;
|
||||
};
|
||||
in
|
||||
{
|
||||
apps = {
|
||||
install = app pkgs.install-system "Install this flake onto this machine from the NixOS installer (wipes the configured disks)";
|
||||
create-keys = app pkgs.create-keys "Create the SSH host key and Secure Boot keys in keys/<host>/";
|
||||
set-password = app pkgs.set-password "Encrypt the login password into secrets/<user>-password.age";
|
||||
secret-from-file = app pkgs.secret-from-file "Encrypt an existing file (e.g. an SSH key) as secrets/<name>.age";
|
||||
switch = app pkgs.switch-system "Rebuild and switch this machine from the flake";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# Development: `nix develop`, `nix fmt` and the formatting check. Both skip
|
||||
# hardware-configuration.nix, which nixos-generate-config (install-system) writes.
|
||||
{ self, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{ inputs', pkgs, ... }:
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "nixos-config";
|
||||
packages = [
|
||||
inputs'.agenix.packages.default
|
||||
inputs'.disko.packages.disko
|
||||
pkgs.age
|
||||
pkgs.ssh-to-age
|
||||
pkgs.sbctl
|
||||
pkgs.git
|
||||
pkgs.nixfmt
|
||||
pkgs.nixd
|
||||
pkgs.shellcheck
|
||||
];
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-tree.override {
|
||||
settings.formatter.nixfmt.excludes = [ "hosts/*/hardware-configuration.nix" ];
|
||||
};
|
||||
|
||||
checks.formatting = pkgs.runCommandLocal "nixfmt-check" { nativeBuildInputs = [ pkgs.nixfmt ]; } ''
|
||||
cd ${self}
|
||||
find . -name '*.nix' ! -path './hosts/*/hardware-configuration.nix' -print0 \
|
||||
| xargs -0 nixfmt --check
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
# Shared data for every aspect: who owns this flake and where the secrets are.
|
||||
# Top-level flake-parts options, not a flake output. Read them in any module
|
||||
# through the flake-parts `config`, bound in a `let` before any lower-level
|
||||
# module so the NixOS/home-manager `config` cannot shadow it:
|
||||
#
|
||||
# { config, ... }:
|
||||
# let
|
||||
# inherit (config.meta) owner;
|
||||
# in
|
||||
# {
|
||||
# flake.modules.nixos.foo = { pkgs, ... }: { users.users.${owner.name}.shell = pkgs.zsh; };
|
||||
# flake.modules.homeManager.foo = { programs.git.settings.user.email = owner.email; };
|
||||
# }
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
options.meta = {
|
||||
owner = mkOption {
|
||||
description = "The single interactive user of every host in this flake.";
|
||||
type = types.submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
description = "Login name.";
|
||||
};
|
||||
fullName = mkOption {
|
||||
type = types.str;
|
||||
description = "Display name (GECOS), also the git author name.";
|
||||
};
|
||||
email = mkOption {
|
||||
type = types.str;
|
||||
description = "E-mail address, used for git.";
|
||||
};
|
||||
uid = mkOption {
|
||||
type = types.int;
|
||||
default = 1000;
|
||||
description = "Numeric user id.";
|
||||
};
|
||||
sshAuthorizedKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Public keys allowed to log in over SSH.";
|
||||
};
|
||||
sshKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ "id_ed25519" ];
|
||||
description = ''
|
||||
Private SSH key names. Each one is installed as ~/.ssh/<name> when
|
||||
secrets/ssh-<name>.age exists (and ~/.ssh/<name>.pub when
|
||||
secrets/ssh-<name>.pub exists).
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
secretsDir = mkOption {
|
||||
type = types.path;
|
||||
default = ../../secrets;
|
||||
defaultText = lib.literalExpression "./secrets";
|
||||
description = ''
|
||||
Directory with the agenix *.age files. A secret is declared only when its
|
||||
file exists, so a fresh clone still evaluates. Flakes only see files that
|
||||
git tracks: `git add` new secrets before building.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
# Host construction. Every `configurations.nixos.<name>.module` (merged from all
|
||||
# files that set it, see modules/hosts/<name>/) becomes
|
||||
# `nixosConfigurations.<name>`, and its toplevel becomes
|
||||
# `checks.<system>.nixos-<name>`, so `nix flake check --no-build` evaluates
|
||||
# every host completely (plain `nix flake check` builds them).
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hosts = config.configurations.nixos;
|
||||
inherit (config.flake) nixosConfigurations;
|
||||
in
|
||||
{
|
||||
options.configurations.nixos = lib.mkOption {
|
||||
description = "NixOS hosts, one deferred module per host.";
|
||||
default = { };
|
||||
type = lib.types.lazyAttrsOf (
|
||||
lib.types.submodule {
|
||||
options.module = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
description = "The host's NixOS module: aspects to import plus host-only values.";
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
config = {
|
||||
flake.nixosConfigurations = lib.mapAttrs (
|
||||
name: host:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
host.module
|
||||
{ networking.hostName = lib.mkDefault name; }
|
||||
];
|
||||
}
|
||||
) hosts;
|
||||
|
||||
perSystem =
|
||||
{ system, ... }:
|
||||
let
|
||||
hostsOnSystem = lib.filterAttrs (
|
||||
name: _: nixosConfigurations.${name}.pkgs.stdenv.hostPlatform.system == system
|
||||
) hosts;
|
||||
toplevel = name: nixosConfigurations.${name}.config.system.build.toplevel;
|
||||
in
|
||||
{
|
||||
checks = lib.mapAttrs' (name: _: lib.nameValuePair "nixos-${name}" (toplevel name)) hostsOnSystem;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
# Overlays exposed as `overlays.<name>`; `default` composes all of them and is
|
||||
# applied to every host (modules/core/nixpkgs.nix), to the installer and to the
|
||||
# per-system package set (modules/flake/packages.nix).
|
||||
{ inputs, lib, ... }:
|
||||
{
|
||||
flake.overlays = rec {
|
||||
# Hyprland's own upstream overlays, built from the pinned `hyprland` flake
|
||||
# input against our nixpkgs. Upstream `default` omits the hyprwm libraries
|
||||
# (aquamarine, hyprutils, hyprland-guiutils, ...); `hyprland-packages`
|
||||
# carries them plus Hyprland, `hyprland-extras` adds the matching portal.
|
||||
hyprland = lib.composeManyExtensions [
|
||||
inputs.hyprland.overlays.hyprland-packages
|
||||
inputs.hyprland.overlays.hyprland-extras
|
||||
];
|
||||
|
||||
# Noctalia from its flake. That flake does not follow our nixpkgs, so the
|
||||
# store path matches noctalia.cachix.org and is downloaded, not compiled.
|
||||
noctalia = final: _prev: {
|
||||
noctalia = inputs.noctalia.packages.${final.stdenv.hostPlatform.system}.default;
|
||||
};
|
||||
|
||||
# This repository's own packages (../../pkgs): install and key helpers.
|
||||
additions =
|
||||
final: _prev:
|
||||
import ../../pkgs {
|
||||
pkgs = final;
|
||||
inherit inputs;
|
||||
};
|
||||
|
||||
# Changes to existing nixpkgs packages. They apply system-wide and to
|
||||
# home-manager (useGlobalPkgs = true).
|
||||
modifications = _final: prev: {
|
||||
# btop with AMD GPU monitoring (ROCm SMI) for the Radeon card.
|
||||
btop = prev.btop.override { rocmSupport = true; };
|
||||
};
|
||||
|
||||
default = lib.composeManyExtensions [
|
||||
hyprland
|
||||
noctalia
|
||||
additions
|
||||
modifications
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
# The per-system package set (our overlay, unfree allowed) and the repository's
|
||||
# own tools as flake packages. They are checks too, so plain `nix flake check`
|
||||
# builds them (writeShellApplication runs shellcheck).
|
||||
{ config, inputs, ... }:
|
||||
let
|
||||
overlay = config.flake.overlays.default;
|
||||
in
|
||||
{
|
||||
perSystem =
|
||||
{ system, pkgs, ... }:
|
||||
let
|
||||
tools = {
|
||||
inherit (pkgs)
|
||||
install-system
|
||||
create-keys
|
||||
set-password
|
||||
secret-from-file
|
||||
switch-system
|
||||
;
|
||||
};
|
||||
in
|
||||
{
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ overlay ];
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
|
||||
packages = tools;
|
||||
checks = tools;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# flake-parts glue: the module classes this flake publishes (flake.modules.nixos.*
|
||||
# and flake.modules.homeManager.*, exported as the `modules` output) and the
|
||||
# systems the per-system outputs are built for.
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [ inputs.flake-parts.flakeModules.modules ];
|
||||
|
||||
systems = [ "x86_64-linux" ];
|
||||
}
|
||||
Reference in new issue
Block a user