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,59 @@
|
||||
# agenix. The module itself is part of `core`, so `config.age.secrets` always
|
||||
# exists (users.nix, install-facts.nix and the home-manager ssh aspect read
|
||||
# it). The `secrets` aspect decrypts the owner's secrets with the host key.
|
||||
#
|
||||
# Every secret is optional: it is declared only when its .age file exists in
|
||||
# meta.secretsDir, so a fresh clone still evaluates.
|
||||
# <owner>-password.age hashed login password (mkpasswd -m yescrypt)
|
||||
# ssh-<key>.age private SSH key of the owner (meta.owner.sshKeys);
|
||||
# home-manager links it to ~/.ssh/<key> (security/ssh.nix)
|
||||
# Service secrets are declared next to their service (dev/gitea-runner.nix,
|
||||
# network/proxy-suite.nix) with the same pattern.
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (config.meta) owner secretsDir;
|
||||
|
||||
secretFile = name: secretsDir + "/${name}.age";
|
||||
exists = name: builtins.pathExists (secretFile name);
|
||||
|
||||
passwordSecrets = lib.optionalAttrs (exists "${owner.name}-password") {
|
||||
"${owner.name}-password" = {
|
||||
file = secretFile "${owner.name}-password";
|
||||
mode = "0400";
|
||||
};
|
||||
};
|
||||
|
||||
sshSecrets = lib.listToAttrs (
|
||||
map (
|
||||
key:
|
||||
lib.nameValuePair "ssh-${key}" {
|
||||
file = secretFile "ssh-${key}";
|
||||
owner = owner.name;
|
||||
mode = "0400";
|
||||
}
|
||||
) (lib.filter (key: exists "ssh-${key}") owner.sshKeys)
|
||||
);
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.core.imports = [ inputs.agenix.nixosModules.default ];
|
||||
|
||||
flake.modules.nixos.secrets =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# The host key is generated on the install USB (`create-keys`) and copied
|
||||
# to the target, so secrets can be decrypted on the very first boot.
|
||||
age.identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||
|
||||
age.secrets = passwordSecrets // sshSecrets;
|
||||
|
||||
environment.systemPackages = [
|
||||
inputs.agenix.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
pkgs.age
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
# SSH, both halves:
|
||||
# NixOS key-only OpenSSH server; its host key is also the agenix identity.
|
||||
# home-manager the owner's client config, agent and keys. Private keys are
|
||||
# agenix secrets decrypted into /run/agenix (security/secrets.nix);
|
||||
# this only links them into ~/.ssh, reading what the NixOS side
|
||||
# declared through `osConfig.age.secrets`.
|
||||
{ config, ... }:
|
||||
let
|
||||
inherit (config.meta) owner secretsDir;
|
||||
hmSsh = config.flake.modules.homeManager.ssh;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.ssh = {
|
||||
home-manager.users.${owner.name}.imports = [ hmSsh ];
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
hostKeys = [
|
||||
{
|
||||
type = "ed25519";
|
||||
path = "/etc/ssh/ssh_host_ed25519_key";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# home-manager's ssh-agent service provides the agent.
|
||||
programs.ssh.startAgent = false;
|
||||
};
|
||||
|
||||
flake.modules.homeManager.ssh =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Keys that have a secret on this host. Without one nothing is linked, so
|
||||
# a fresh install still works and ssh uses whatever key the user makes.
|
||||
keys = lib.filter (k: osConfig.age.secrets ? "ssh-${k}") owner.sshKeys;
|
||||
|
||||
pubFile = k: secretsDir + "/ssh-${k}.pub";
|
||||
|
||||
# The decrypted file lives outside the store, so link it by absolute path.
|
||||
keyFiles = lib.listToAttrs (
|
||||
map (
|
||||
k:
|
||||
lib.nameValuePair ".ssh/${k}" {
|
||||
source = config.lib.file.mkOutOfStoreSymlink osConfig.age.secrets."ssh-${k}".path;
|
||||
}
|
||||
) keys
|
||||
);
|
||||
|
||||
# Public keys are not secret, so they are plain files from the repo.
|
||||
pubFiles = lib.listToAttrs (
|
||||
map (k: lib.nameValuePair ".ssh/${k}.pub" { source = pubFile k; }) (
|
||||
lib.filter (k: builtins.pathExists (pubFile k)) keys
|
||||
)
|
||||
);
|
||||
in
|
||||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
# Spell the defaults out below instead of relying on the deprecated ones.
|
||||
enableDefaultConfig = false;
|
||||
|
||||
settings = {
|
||||
"*" = {
|
||||
# Load a key into the agent on first use, so the passphrase (if any)
|
||||
# is typed once per login.
|
||||
AddKeysToAgent = "yes";
|
||||
ServerAliveInterval = 60;
|
||||
ServerAliveCountMax = 3;
|
||||
HashKnownHosts = false;
|
||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
||||
};
|
||||
|
||||
"github.com" = {
|
||||
User = "git";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
# Offer only this key, not everything in the agent.
|
||||
IdentitiesOnly = true;
|
||||
};
|
||||
"git.protei.ru" = {
|
||||
User = "git";
|
||||
IdentityFile = "~/.ssh/id_ed25519_work";
|
||||
IdentitiesOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# A plain user service rather than gnome-keyring's agent: no keyring to
|
||||
# unlock, and it sets SSH_AUTH_SOCK for shells, systemd and D-Bus.
|
||||
services.ssh-agent.enable = true;
|
||||
|
||||
home.file = keyFiles // pubFiles;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user