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,165 @@
|
||||
# desktop: disk layout (disko), btrfs, no encryption.
|
||||
# system disk (NVMe): ESP + btrfs "nixos" with @root @home @nix @log @swap
|
||||
# data disk (SATA): btrfs "data", one subvolume per home folder, each
|
||||
# mounted inside the owner's home (~/Games, ~/Music, ...)
|
||||
# The device paths come from hosts/desktop/disk-ids.json, which
|
||||
# `nix run .#install` rewrites after you pick the disks
|
||||
# (list them with `ls -l /dev/disk/by-id`).
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (config.meta) owner;
|
||||
ids = lib.importJSON ../../../hosts/desktop/disk-ids.json;
|
||||
home = "/home/${owner.name}";
|
||||
|
||||
# Each entry becomes a btrfs subvolume on the data disk, mounted at
|
||||
# ~/<Name>. To add a folder later, add `Name = { };` here, create the
|
||||
# subvolume (`btrfs subvolume create /mnt/data/@name`, with the data disk's
|
||||
# top level mounted), then rebuild. Storage is a free-form folder to organise
|
||||
# yourself; Steam's library goes in ~/Games/SteamLibrary.
|
||||
homeFolders = {
|
||||
Games = { };
|
||||
Downloads = { };
|
||||
Documents = { };
|
||||
Music = { };
|
||||
Pictures = { };
|
||||
Videos = { };
|
||||
Storage = { };
|
||||
};
|
||||
subvolumeOf = name: folder: folder.subvolume or ("@" + lib.toLower name);
|
||||
|
||||
# Compression keeps the NVMe small-write friendly; noatime avoids metadata writes.
|
||||
btrfsOptions = [
|
||||
"compress=zstd:1"
|
||||
"noatime"
|
||||
];
|
||||
|
||||
dataMountOptions = btrfsOptions ++ [
|
||||
# The machine still boots (to the system disk) if the SSD is missing.
|
||||
"nofail"
|
||||
"x-systemd.device-timeout=10s"
|
||||
];
|
||||
|
||||
placeholders = lib.filter (lib.hasInfix "CHANGE-ME") [
|
||||
ids.system
|
||||
ids.data
|
||||
];
|
||||
in
|
||||
{
|
||||
configurations.nixos.desktop.module = {
|
||||
imports = [ inputs.disko.nixosModules.disko ];
|
||||
|
||||
disko.devices.disk = {
|
||||
system = {
|
||||
type = "disk";
|
||||
device = ids.system;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
size = "2G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
# Only root may read the ESP (random seed, lanzaboote images).
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
|
||||
root = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [
|
||||
"-f"
|
||||
"-L"
|
||||
"nixos"
|
||||
];
|
||||
subvolumes = {
|
||||
"@root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = btrfsOptions;
|
||||
};
|
||||
"@home" = {
|
||||
mountpoint = "/home";
|
||||
mountOptions = btrfsOptions;
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = btrfsOptions;
|
||||
};
|
||||
"@log" = {
|
||||
mountpoint = "/var/log";
|
||||
mountOptions = btrfsOptions;
|
||||
};
|
||||
# No compression on the swapfile's subvolume.
|
||||
"@swap" = {
|
||||
mountpoint = "/swap";
|
||||
mountOptions = [ "noatime" ];
|
||||
swap.swapfile.size = "16G";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
data = {
|
||||
type = "disk";
|
||||
device = ids.data;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions.data = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [
|
||||
"-f"
|
||||
"-L"
|
||||
"data"
|
||||
];
|
||||
subvolumes = lib.mapAttrs' (
|
||||
name: folder:
|
||||
lib.nameValuePair (subvolumeOf name folder) {
|
||||
mountpoint = "${home}/${name}";
|
||||
mountOptions = dataMountOptions;
|
||||
}
|
||||
) homeFolders;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Logs must be mounted before journald starts in stage 2.
|
||||
fileSystems."/var/log".neededForBoot = true;
|
||||
|
||||
services.btrfs.autoScrub = {
|
||||
enable = true;
|
||||
interval = "monthly";
|
||||
fileSystems = [
|
||||
"/"
|
||||
"${home}/${lib.head (lib.attrNames homeFolders)}"
|
||||
];
|
||||
};
|
||||
|
||||
# Subvolume roots are created root-owned; hand them to the owner. The home
|
||||
# directory itself is listed first so the mount points have a parent.
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${home} 0700 ${owner.name} users -"
|
||||
]
|
||||
++ lib.mapAttrsToList (name: _: "d ${home}/${name} 0755 ${owner.name} users -") homeFolders;
|
||||
|
||||
warnings = lib.optional (placeholders != [ ]) ''
|
||||
hosts/desktop/disk-ids.json still has placeholder device paths (${lib.concatStringsSep ", " placeholders}).
|
||||
Run `nix run .#install`, or edit hosts/desktop/disk-ids.json, before installing.
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# desktop: the generated hardware scan (rewritten by install-system) and the
|
||||
# nixos-hardware profiles for an AMD CPU and GPU on an SSD.
|
||||
{ inputs, ... }:
|
||||
{
|
||||
configurations.nixos.desktop.module = {
|
||||
imports = [
|
||||
../../../hosts/desktop/hardware-configuration.nix
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-amd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-amd
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
# desktop: AMD CPU + AMD GPU workstation/gaming PC. Which aspects it runs, plus
|
||||
# the few values that belong to this machine only. Hardware: hardware.nix,
|
||||
# disks: disks.nix. install-system writes hosts/desktop/disk-ids.json and
|
||||
# hosts/desktop/hardware-configuration.nix at the repository root.
|
||||
{ config, ... }:
|
||||
let
|
||||
inherit (config.meta) owner;
|
||||
nixos = config.flake.modules.nixos;
|
||||
hm = config.flake.modules.homeManager;
|
||||
in
|
||||
{
|
||||
configurations.nixos.desktop.module = {
|
||||
# Aspects with a home-manager half (hyprland, noctalia, ssh, theme) add it
|
||||
# to the owner themselves.
|
||||
imports = with nixos; [
|
||||
core
|
||||
secure-boot
|
||||
amd
|
||||
ssh
|
||||
secrets
|
||||
hyprland
|
||||
noctalia
|
||||
audio
|
||||
fonts
|
||||
theme
|
||||
gaming
|
||||
vpn
|
||||
proxy-suite
|
||||
docker
|
||||
gitea-runner
|
||||
];
|
||||
|
||||
# The owner's own programs (home-manager only). A dynamic attribute such
|
||||
# as `${owner.name}` may appear only once per attribute set, so everything
|
||||
# for the owner's home-manager configuration sits in this one block.
|
||||
home-manager.users.${owner.name} = {
|
||||
imports = with hm; [
|
||||
shell
|
||||
git
|
||||
neovim
|
||||
wezterm
|
||||
xdg
|
||||
apps
|
||||
claude-code
|
||||
];
|
||||
|
||||
# Set once at install time; do not change on upgrades.
|
||||
home.stateVersion = "26.05";
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
time.timeZone = "Europe/Moscow";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
# XKB layouts in switching order. The console follows them
|
||||
# (core/locale.nix) and so does Hyprland (desktop/hyprland, via osConfig).
|
||||
services.xserver.xkb = {
|
||||
layout = "us,ru";
|
||||
options = "grp:alt_shift_toggle";
|
||||
};
|
||||
|
||||
# No packet filter on this machine.
|
||||
networking.firewall.enable = false;
|
||||
|
||||
# Set once at install time; do not change on upgrades.
|
||||
system.stateVersion = "26.05";
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user