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:
Claude committed 2026-10-12 20:55:34 +00:00
1 parent 7dd6853124
commit af18420fd3
84 files changed
+2118 -1925

No files matched your search

-16
View File
@@ -1,16 +0,0 @@
# `nix run .#<app>`: install and key/secret helpers (see ../pkgs).
{ pkgs, ... }:
let
app = pkg: description: {
type = "app";
program = pkgs.lib.getExe pkg;
meta.description = description;
};
in
{
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";
}
Generated
+432 -1
View File
@@ -53,6 +53,74 @@
"type": "github"
}
},
"base16": {
"inputs": {
"fromYaml": "fromYaml"
},
"locked": {
"lastModified": 1755819240,
"narHash": "sha256-qcMhnL7aGAuFuutH4rq9fvAhCpJWVHLcHVZLtPctPlo=",
"owner": "SenchoPens",
"repo": "base16.nix",
"rev": "75ed5e5e3fce37df22e49125181fa37899c3ccd6",
"type": "github"
},
"original": {
"owner": "SenchoPens",
"repo": "base16.nix",
"type": "github"
}
},
"base16-fish": {
"flake": false,
"locked": {
"lastModified": 1765809053,
"narHash": "sha256-XCUQLoLfBJ8saWms2HCIj4NEN+xNsWBlU1NrEPcQG4s=",
"owner": "tomyun",
"repo": "base16-fish",
"rev": "86cbea4dca62e08fb7fd83a70e96472f92574782",
"type": "github"
},
"original": {
"owner": "tomyun",
"repo": "base16-fish",
"rev": "86cbea4dca62e08fb7fd83a70e96472f92574782",
"type": "github"
}
},
"base16-helix": {
"flake": false,
"locked": {
"lastModified": 1776754714,
"narHash": "sha256-E3OAK27smtATTmX45uoTSRsVD+Y+ZiVVfgM/tjpbtYg=",
"owner": "tinted-theming",
"repo": "base16-helix",
"rev": "4d508123037e7851ad36ebf7d9c48b0e9e1eb581",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "base16-helix",
"type": "github"
}
},
"base16-vim": {
"flake": false,
"locked": {
"lastModified": 1732806396,
"narHash": "sha256-e0bpPySdJf0F68Ndanwm+KWHgQiZ0s7liLhvJSWDNsA=",
"owner": "tinted-theming",
"repo": "base16-vim",
"rev": "577fe8125d74ff456cf942c733a85d769afe58b7",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "base16-vim",
"rev": "577fe8125d74ff456cf942c733a85d769afe58b7",
"type": "github"
}
},
"crane": {
"locked": {
"lastModified": 1789760033,
@@ -109,6 +177,22 @@
"type": "github"
}
},
"firefox-gnome-theme": {
"flake": false,
"locked": {
"lastModified": 1783570805,
"narHash": "sha256-ptl5aRlCv9/uRSv2u8Hq8UFVFeZ6Q/bT049bpqNgc3w=",
"owner": "rafaelmardojai",
"repo": "firefox-gnome-theme",
"rev": "5602ed62d638142c1ab31dccd01dfbfb28841225",
"type": "github"
},
"original": {
"owner": "rafaelmardojai",
"repo": "firefox-gnome-theme",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@@ -141,6 +225,79 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fromYaml": {
"flake": false,
"locked": {
"lastModified": 1731966426,
"narHash": "sha256-lq95WydhbUTWig/JpqiB7oViTcHFP8Lv41IGtayokA8=",
"owner": "SenchoPens",
"repo": "fromYaml",
"rev": "106af9e2f715e2d828df706c386a685698f3223b",
"type": "github"
},
"original": {
"owner": "SenchoPens",
"repo": "fromYaml",
"type": "github"
}
},
"gnome-shell": {
"flake": false,
"locked": {
"host": "gitlab.gnome.org",
"lastModified": 1776175984,
"narHash": "sha256-RJFlFW8GiMei6oqUGrMkGEvVqOH8U7Q8abc1yK4VKD8=",
"owner": "GNOME",
"repo": "gnome-shell",
"rev": "e0fdc4c13250e9a9b8ea9594c83925274f4a5dca",
"type": "gitlab"
},
"original": {
"host": "gitlab.gnome.org",
"owner": "GNOME",
"ref": "50.1",
"repo": "gnome-shell",
"type": "gitlab"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@@ -511,6 +668,21 @@
"type": "github"
}
},
"import-tree": {
"locked": {
"lastModified": 1788467110,
"narHash": "sha256-ljEMTXP/rH0tOvDzc9gzwww6KcHRPRnEHzd9lK48V7s=",
"owner": "vic",
"repo": "import-tree",
"rev": "eb1b52eaecc57f7c136d07ae8a93e724dfecac46",
"type": "github"
},
"original": {
"owner": "vic",
"repo": "import-tree",
"type": "github"
}
},
"lanzaboote": {
"inputs": {
"crane": "crane",
@@ -629,6 +801,31 @@
"type": "github"
}
},
"nur": {
"inputs": {
"flake-parts": [
"stylix",
"flake-parts"
],
"nixpkgs": [
"stylix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1785549842,
"narHash": "sha256-DCwBZmGsySF7oKGTRgEv2HvpxVXkHT+38VhTM76k0B4=",
"owner": "nix-community",
"repo": "NUR",
"rev": "a9f987b57594e845e3e5cdd423b9a70846d70308",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NUR",
"type": "github"
}
},
"pre-commit": {
"inputs": {
"flake-compat": "flake-compat_2",
@@ -697,17 +894,71 @@
"type": "github"
}
},
"pyproject-build-systems": {
"inputs": {
"nixpkgs": [
"serena",
"nixpkgs"
],
"pyproject-nix": [
"serena",
"pyproject-nix"
],
"uv2nix": [
"serena",
"uv2nix"
]
},
"locked": {
"lastModified": 1755484659,
"narHash": "sha256-2FfbqsaHVQd12XFFUAinIMAuGO3853LONmva1gT3vKw=",
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"rev": "9778e87c2361810ff15e287ca5895c9da4a0e900",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"type": "github"
}
},
"pyproject-nix": {
"inputs": {
"nixpkgs": [
"serena",
"nixpkgs"
]
},
"locked": {
"lastModified": 1755886095,
"narHash": "sha256-oMQ1YERKqiac28LB1cKjl4d0gjvK98SbGejFMfK0WGE=",
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"rev": "7ea903d50c20d4d3ea45ccaad7ee0d21996780c9",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"disko": "disko",
"flake-parts": "flake-parts",
"home-manager": "home-manager",
"hyprland": "hyprland",
"import-tree": "import-tree",
"lanzaboote": "lanzaboote",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2",
"noctalia": "noctalia",
"proxy-suite": "proxy-suite"
"proxy-suite": "proxy-suite",
"serena": "serena",
"stylix": "stylix"
}
},
"rust-overlay": {
@@ -731,6 +982,66 @@
"type": "github"
}
},
"serena": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"pyproject-build-systems": "pyproject-build-systems",
"pyproject-nix": "pyproject-nix",
"uv2nix": "uv2nix"
},
"locked": {
"lastModified": 1786299277,
"narHash": "sha256-IrsD4pnu/47M/O9b8H9c7K8WENGv3FihlqzCB6szBXg=",
"owner": "oraios",
"repo": "serena",
"rev": "949a27ef1e5fda1a6e7b561e777bcece345c6ffd",
"type": "github"
},
"original": {
"owner": "oraios",
"ref": "v1.7.0",
"repo": "serena",
"type": "github"
}
},
"stylix": {
"inputs": {
"base16": "base16",
"base16-fish": "base16-fish",
"base16-helix": "base16-helix",
"base16-vim": "base16-vim",
"firefox-gnome-theme": "firefox-gnome-theme",
"flake-parts": [
"flake-parts"
],
"gnome-shell": "gnome-shell",
"nixpkgs": [
"nixpkgs"
],
"nur": "nur",
"systems": "systems_3",
"tinted-kitty": "tinted-kitty",
"tinted-schemes": "tinted-schemes",
"tinted-tmux": "tinted-tmux",
"tinted-zed": "tinted-zed"
},
"locked": {
"lastModified": 1791574276,
"narHash": "sha256-UMnLnZ3JlA7UTBNNNx1rNsXYoPP/cirXLCKGiQ/yDx8=",
"owner": "nix-community",
"repo": "stylix",
"rev": "2856c4c6a845b9bec98828ef197abe176e4806bb",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "stylix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
@@ -746,6 +1057,126 @@
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1774449309,
"narHash": "sha256-brhZ8DmuGtzkCYHJg4HEd602amKm89Y9ytsFZ5uWD1w=",
"owner": "nix-systems",
"repo": "default",
"rev": "c29398b59d2048c4ab79345812849c9bd15e9150",
"type": "github"
},
"original": {
"owner": "nix-systems",
"ref": "future-26.11",
"repo": "default",
"type": "github"
}
},
"tinted-kitty": {
"flake": false,
"locked": {
"lastModified": 1735730497,
"narHash": "sha256-4KtB+FiUzIeK/4aHCKce3V9HwRvYaxX+F1edUrfgzb8=",
"owner": "tinted-theming",
"repo": "tinted-kitty",
"rev": "de6f888497f2c6b2279361bfc790f164bfd0f3fa",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "tinted-kitty",
"type": "github"
}
},
"tinted-schemes": {
"flake": false,
"locked": {
"lastModified": 1785153830,
"narHash": "sha256-fNdfCTeCXU3tZG3TMincd+u68qBHQgCr2Ljr/M1mWP0=",
"owner": "tinted-theming",
"repo": "schemes",
"rev": "9bd28ed313560db3c5b605c63bc4e309e78e3fc8",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "schemes",
"type": "github"
}
},
"tinted-tmux": {
"flake": false,
"locked": {
"lastModified": 1785031658,
"narHash": "sha256-mZp9O2LjzdMzlqQF3l3fjqsuPBzXy+1qTfBEUGjTlpk=",
"owner": "tinted-theming",
"repo": "tinted-tmux",
"rev": "5d2c67f61ea7af36f16865ab6d541cdba41dc257",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "tinted-tmux",
"type": "github"
}
},
"tinted-zed": {
"flake": false,
"locked": {
"lastModified": 1785030526,
"narHash": "sha256-klZf8UviewRkxuu74Bhbq6tqy7oxebQC7UVRWbbtQxU=",
"owner": "tinted-theming",
"repo": "base16-zed",
"rev": "16f5a8adf4a6b1310d0a61ab172de963e8f76a02",
"type": "github"
},
"original": {
"owner": "tinted-theming",
"repo": "base16-zed",
"type": "github"
}
},
"uv2nix": {
"inputs": {
"nixpkgs": [
"serena",
"nixpkgs"
],
"pyproject-nix": [
"serena",
"pyproject-nix"
]
},
"locked": {
"lastModified": 1755887980,
"narHash": "sha256-MD1IhwuoDXQSYcQ/JfEpMxrk6pPl+aHPXSqZLOXLHks=",
"owner": "pyproject-nix",
"repo": "uv2nix",
"rev": "76778b5f457e416688324d19d8f02ec5e22cbe0c",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "uv2nix",
"type": "github"
}
},
"xdph": {
"inputs": {
"aquamarine": [
+23 -70
View File
@@ -1,12 +1,11 @@
{
description = "faumaray's NixOS configuration: Hyprland + Noctalia, agenix, disko, lanzaboote";
description = "faumaray's NixOS configuration: Hyprland + Noctalia, Stylix, agenix, disko, lanzaboote";
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
"https://noctalia.cachix.org"
];
allowUnfree = true;
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"noctalia.cachix.org-1:pCOR47nnMEo5thcxNDtzWpOxNFQsBRglJzxWPp3dkU4="
@@ -17,6 +16,14 @@
# Hyprland git and Noctalia v5 both track nixos-unstable.
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Dendritic glue: every .nix file under ./modules is a flake-parts module,
# imported by import-tree (paths containing `/_` are skipped).
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
import-tree.url = "github:vic/import-tree";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@@ -41,9 +48,10 @@
url = "github:FUFSoB/proxy-suite-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
# Hyprland is consumed through its own overlay (see overlays/default.nix),
# Hyprland is consumed through its own overlay (modules/flake/overlays.nix),
# built against our nixpkgs so mesa/libdrm always match the system.
hyprland = {
url = "github:hyprwm/Hyprland";
@@ -52,76 +60,21 @@
# No `follows` on purpose: keeps the noctalia.cachix.org binary cache usable.
noctalia.url = "github:noctalia-dev/noctalia";
# Theming (modules/theme/stylix.nix). Stylix has no home-manager input.
stylix = {
url = "github:nix-community/stylix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
outputs =
{ self, nixpkgs, ... }@inputs:
let
inherit (nixpkgs) lib;
systems = [ "x86_64-linux" ];
forAllSystems = lib.genAttrs systems;
myLib = import ./lib { inherit inputs self lib; };
pkgsFor =
system:
import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowUnfree = true;
# Serena MCP server for Claude Code (modules/ai/claude-code.nix); not in
# nixpkgs. Pinned to a release tag: bump the tag to update.
serena = {
url = "github:oraios/serena/v1.7.0";
inputs.nixpkgs.follows = "nixpkgs";
};
in
{
lib = myLib;
overlays = import ./overlays { inherit inputs; };
nixosModules.default = ./modules/nixos;
homeModules.default = ./modules/home;
nixosConfigurations = {
desktop = myLib.mkHost {
hostname = "desktop";
system = "x86_64-linux";
};
# Bootable installer ISO with this flake baked in: `nix build .#iso`.
installer = myLib.mkInstaller { system = "x86_64-linux"; };
};
packages = forAllSystems (system: {
iso = self.nixosConfigurations.installer.config.system.build.isoImage;
});
apps = forAllSystems (
system:
import ./apps {
pkgs = pkgsFor system;
inherit inputs self;
}
);
devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell {
name = "nixos-config";
packages = [
inputs.agenix.packages.${system}.default
inputs.disko.packages.${system}.disko
pkgs.age
pkgs.ssh-to-age
pkgs.sbctl
pkgs.git
pkgs.nixfmt
pkgs.nixd
pkgs.shellcheck
];
};
}
);
formatter = forAllSystems (system: (pkgsFor system).nixfmt-tree);
};
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules);
}
-45
View File
@@ -1,45 +0,0 @@
# desktop: AMD CPU + AMD GPU workstation/gaming PC.
# System on the NVMe, part of /home on the SATA SSD (see disko.nix / my.disks).
{ inputs, ... }:
{
imports = [
./hardware-configuration.nix
./disks.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
];
my = {
user = {
name = "faumaray";
fullName = "faumaray";
email = "faumaray@gmail.com";
};
locale = {
timeZone = "Europe/Moscow";
defaultLocale = "en_US.UTF-8";
keyboardLayouts = [
"us"
"ru"
];
keyboardOptions = [ "grp:alt_shift_toggle" ];
};
boot.secureBoot.enable = true;
hardware.amd.enable = true;
desktop.hyprland.enable = true;
gaming.enable = true;
secrets.enable = true;
};
home-manager.users.faumaray = ./home.nix;
# Set once at install time; do not change on upgrades.
system.stateVersion = "26.05";
}
-33
View File
@@ -1,33 +0,0 @@
# Disk layout of `desktop`; the generic logic lives in modules/nixos/hardware/disks.nix.
# The device paths come from disk-ids.json, which `nix run .#install` rewrites
# after you pick the disks (list them with `ls -l /dev/disk/by-id`).
{ lib, ... }:
let
ids = lib.importJSON ./disk-ids.json;
in
{
my.disks = {
enable = true;
system.device = ids.system;
data = {
enable = true;
device = ids.data;
# 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 = { };
};
};
};
}
-28
View File
@@ -1,28 +0,0 @@
# home-manager config for the desktop's user (wired up in ./default.nix).
# The modules live in modules/home; this file only turns them on.
{ osConfig, ... }:
let
name = osConfig.my.user.name;
in
{
home = {
username = name;
homeDirectory = "/home/${name}";
# Set once at install time; do not change on upgrades.
stateVersion = "26.05";
};
my.home = {
hyprland.enable = true;
noctalia.enable = true;
wezterm.enable = true;
neovim.enable = true;
shell.enable = true;
git.enable = true;
ssh.enable = true;
xdg.enable = true;
theming.enable = true;
apps.enable = true;
};
}
-69
View File
@@ -1,69 +0,0 @@
{
inputs,
self,
lib,
}:
let
specialArgs = { inherit inputs self; };
in
{
# Build a full NixOS host from hosts/<hostname>.
mkHost =
{
hostname,
system ? "x86_64-linux",
extraModules ? [ ],
}:
lib.nixosSystem {
inherit specialArgs;
modules = [
{
nixpkgs.hostPlatform = system;
nixpkgs.overlays = [ self.overlays.default ];
nixpkgs.config.allowUnfree = true;
networking.hostName = hostname;
}
inputs.home-manager.nixosModules.home-manager
inputs.agenix.nixosModules.default
inputs.disko.nixosModules.disko
inputs.lanzaboote.nixosModules.lanzaboote
inputs.noctalia.nixosModules.default
inputs.proxy-suite.nixosModules.default
self.nixosModules.default
../hosts/${hostname}
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "hm-backup";
extraSpecialArgs = specialArgs;
sharedModules = [
inputs.noctalia.homeModules.default
self.homeModules.default
];
};
}
]
++ extraModules;
};
# Live installer ISO that carries this flake and the install tooling.
mkInstaller =
{
system ? "x86_64-linux",
}:
lib.nixosSystem {
inherit specialArgs;
modules = [
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
{
nixpkgs.hostPlatform = system;
nixpkgs.overlays = [ self.overlays.default ];
}
../modules/installer
];
};
}
+107
View File
@@ -0,0 +1,107 @@
# Claude Code (pkgs.claude-code, unfree) for the owner, through home-manager's
# programs.claude-code, with:
# codememory MCP server: codebase-memory-mcp (DeusData), code knowledge graph (nixpkgs)
# serena MCP server: semantic code retrieval and editing (inputs.serena)
# rea MCP server and skill: Reverse Engineer Anything (npm rea-agents)
# caveman plugin: skills, commands, agents and hooks (JuliusBrussee/caveman)
# Everything is user scope (~/.claude). A repository's own .claude/settings.json
# still applies on top of it; nothing here sets a model, effort, permissions or
# hooks. MCP servers land in home-manager's generated plugin, so their tools
# are named mcp__plugin_hm_<server>__<tool>.
{ inputs, ... }:
{
flake.modules.homeManager.claude-code =
{
lib,
pkgs,
...
}:
let
serena = inputs.serena.packages.${pkgs.stdenv.hostPlatform.system}.serena;
# REA has no Nix package: the MCP server runs from npm through npx
# (pinned version, fetched on first start: not hermetic). Its skill comes
# from the same npm release. Knobs: reaVersion and the hash below.
reaVersion = "6.4.0";
reaPackage = pkgs.fetchzip {
url = "https://registry.npmjs.org/rea-agents/-/rea-agents-${reaVersion}.tgz";
hash = "sha256-aJTYn9CZchdwJLBMn9no4C2EGBO6XemsH3J0GU1DqWM=";
};
# `rea` on PATH and as the MCP command; npx needs node for the package's
# own `#!/usr/bin/env node` scripts.
rea = pkgs.writeShellApplication {
name = "rea";
runtimeInputs = [ pkgs.nodejs ];
text = ''exec npx --yes "rea-agents@${reaVersion}" "$@"'';
};
# Knobs: tag and hash.
caveman = pkgs.fetchFromGitHub {
owner = "JuliusBrussee";
repo = "caveman";
tag = "v3.2.0";
hash = "sha256-GfC8e+EGL7kotZQfZ9kD7ZEWJfhmXujHOHpMxeU3bEo=";
};
in
{
programs.claude-code = {
enable = true;
# Claude Code also writes ~/.claude/settings.json itself; merge the
# declared keys into a writable file on every switch instead of
# replacing it with a read-only link.
mutableSettings = true;
# Serena (Python) can take longer than the default MCP start timeout.
settings.env.MCP_TIMEOUT = "60000";
mcpServers = {
# To use another code-memory server, replace this one entry.
codememory = {
command = lib.getExe pkgs.codebase-memory-mcp;
args = [ ];
};
serena = {
command = lib.getExe serena;
args = [
"start-mcp-server"
"--context"
"claude-code"
"--project-from-cwd"
"--open-web-dashboard"
"false"
];
};
rea = {
command = lib.getExe rea;
args = [ "mcp" ];
};
};
skills.reverse-engineer-anything = "${reaPackage}/skills/reverse-engineer-anything";
# Loaded as a personal plugin (Claude Code >= 2.1.157).
plugins.caveman = caveman;
};
# The CLIs themselves; caveman's hooks need `node` on PATH (they exit
# silently without it).
home.packages = [
pkgs.codebase-memory-mcp
serena
rea
pkgs.nodejs
];
# caveman switches every new session into its terse style unless its
# default mode says otherwise. Start with it off (turn it on per session
# with /caveman), so agents in repositories like this one keep their
# normal reports. Written once; caveman may change it later.
home.activation.cavemanDefaultMode = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -e "$HOME/.config/caveman/config.json" ]; then
run mkdir -p "$HOME/.config/caveman"
run sh -c 'echo "{\"defaultMode\": \"off\"}" > "$HOME/.config/caveman/config.json"'
fi
'';
};
}
+23
View File
@@ -0,0 +1,23 @@
# Secure Boot through lanzaboote. Keys live in /var/lib/sbctl (create them with
# `sbctl create-keys` before the first boot). A host that does not want Secure
# Boot imports the `systemd-boot` aspect instead; import only one of the two.
{ inputs, ... }:
{
flake.modules.nixos.secure-boot =
{ lib, pkgs, ... }:
{
imports = [ inputs.lanzaboote.nixosModules.lanzaboote ];
boot = {
lanzaboote = {
enable = true;
pkiBundle = "/var/lib/sbctl";
configurationLimit = 10;
};
# lanzaboote installs the boot entries itself.
loader.systemd-boot.enable = lib.mkForce false;
};
environment.systemPackages = [ pkgs.sbctl ];
};
}
+11
View File
@@ -0,0 +1,11 @@
# Plain systemd-boot, the alternative to the `secure-boot` aspect (lanzaboote):
# a host imports one of the two.
{
flake.modules.nixos.systemd-boot = {
boot.loader.systemd-boot = {
enable = true;
configurationLimit = 10;
editor = false;
};
};
}
+7 -15
View File
@@ -1,27 +1,19 @@
# Git identity and defaults. The name and email come from my.user so the
# identity is defined once, in the host file.
{
config,
lib,
pkgs,
osConfig,
...
}:
# Git identity and defaults. The identity is the owner's (meta.owner), defined
# once in modules/users/faumaray.nix.
{ config, ... }:
let
cfg = config.my.home.git;
inherit (config.meta) owner;
in
{
options.my.home.git.enable = lib.mkEnableOption "Git and GitHub CLI configuration";
config = lib.mkIf cfg.enable {
flake.modules.homeManager.git = {
programs = {
git = {
enable = true;
settings = {
user = {
name = osConfig.my.user.fullName;
inherit (osConfig.my.user) email;
name = owner.fullName;
inherit (owner) email;
};
init.defaultBranch = "main";
pull.rebase = true;
+4
View File
@@ -0,0 +1,4 @@
# STUB (T3): replaced in phase 2
{
flake.modules.homeManager.neovim = { };
}
File renamed without changes.
+4
View File
@@ -0,0 +1,4 @@
# STUB (T3): replaced in phase 2
{
flake.modules.homeManager.shell = { };
}
+14
View File
@@ -0,0 +1,14 @@
# Boot basics every host shares: EFI variable access, systemd in the initrd and
# the latest kernel. The boot loader itself is an aspect of its own: the host
# imports `secure-boot` (lanzaboote) or `systemd-boot`.
{
flake.modules.nixos.core =
{ lib, pkgs, ... }:
{
boot = {
loader.efi.canTouchEfiVariables = true;
initrd.systemd.enable = true;
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
};
};
}
+16
View File
@@ -0,0 +1,16 @@
# home-manager as a NixOS module. Aspects add their home-manager half to the
# owner (`home-manager.users.<owner>.imports`), so every home-manager module
# also receives `osConfig` (the NixOS configuration) and `inputs`.
{ inputs, ... }:
{
flake.modules.nixos.core = {
imports = [ inputs.home-manager.nixosModules.home-manager ];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "hm-backup";
extraSpecialArgs = { inherit inputs; };
};
};
}
+30
View File
@@ -0,0 +1,30 @@
# Read-only facts for pkgs/install-system/install-system.sh, which evaluates
# `nixosConfigurations.<host>.config.my` and reads user.name, user.uid,
# boot.secureBoot.enable and secrets.enable. Everything here is derived from
# the real configuration; no aspect may read `config.my`.
{ config, lib, ... }:
let
inherit (config.meta) owner;
in
{
flake.modules.nixos.core =
{ config, ... }:
{
options.my = lib.mkOption {
type = lib.types.raw;
readOnly = true;
internal = true;
description = "Facts for install-system (derived; do not set, do not read in aspects).";
};
config.my = {
user = {
inherit (owner) name;
inherit (config.users.users.${owner.name}) uid;
};
# Only the secure-boot aspect imports lanzaboote.
boot.secureBoot.enable = config.boot.lanzaboote.enable or false;
secrets.enable = config.age.secrets != { };
};
};
}
+13
View File
@@ -0,0 +1,13 @@
# The parts of the locale setup that do not depend on the machine. The host
# sets the time zone, the default locale and the XKB layouts
# (modules/hosts/<name>/host.nix); the console follows those layouts, and so
# does Hyprland (modules/desktop/hyprland, through osConfig).
{
flake.modules.nixos.core = {
# Russian stays available for apps and games even with an English UI.
i18n.extraLocales = [ "ru_RU.UTF-8/UTF-8" ];
# TTY and initrd keymap follow the XKB layout set by the host.
console.useXkbConfig = true;
};
}
+13
View File
@@ -0,0 +1,13 @@
# NetworkManager with the OpenVPN plugin. The owner joins the `networkmanager`
# group in users.nix. Whether a firewall runs is the host's decision
# (modules/hosts/<name>/host.nix).
{
flake.modules.nixos.core =
{ pkgs, ... }:
{
networking.networkmanager = {
enable = true;
plugins = [ pkgs.networkmanager-openvpn ];
};
};
}
+54
View File
@@ -0,0 +1,54 @@
# Nix daemon settings, binary caches, garbage collection and flake registry.
{ config, inputs, ... }:
let
inherit (config.meta) owner;
in
{
flake.modules.nixos.core = {
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true;
# root is already trusted by default; this adds the admin group.
trusted-users = [ "@wheel" ];
warn-dirty = false;
# Same caches as flake.nixConfig, so the system keeps using them after
# install without the "untrusted flake settings" prompt.
extra-substituters = [
"https://nix-community.cachix.org"
"https://noctalia.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"noctalia.cachix.org-1:pCOR47nnMEo5thcxNDtzWpOxNFQsBRglJzxWPp3dkU4="
];
};
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
# `nix shell nixpkgs#foo` and <nixpkgs> use the exact nixpkgs of this flake
# instead of fetching a different revision.
channel.enable = false;
registry.nixpkgs.flake = inputs.nixpkgs;
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
};
programs = {
# Nicer `nixos-rebuild` front-end that knows where the flake lives.
nh = {
enable = true;
flake = "/home/${owner.name}/nixos-config";
};
# Lets prebuilt binaries (editors' language servers, game launchers) run.
nix-ld.enable = true;
};
};
}
+15
View File
@@ -0,0 +1,15 @@
# Every host uses this flake's overlay and allows unfree packages (Steam,
# TeamSpeak, Claude Code). home-manager shares this package set
# (useGlobalPkgs, modules/core/home-manager.nix).
{ config, ... }:
let
overlay = config.flake.overlays.default;
in
{
flake.modules.nixos.core = {
nixpkgs = {
overlays = [ overlay ];
config.allowUnfree = true;
};
};
}
+56
View File
@@ -0,0 +1,56 @@
# The owner's account (meta.owner, modules/users/faumaray.nix): the only
# interactive user. The `docker` and `gamemode` groups are added by the docker
# and gaming aspects.
{ config, ... }:
let
inherit (config.meta) owner;
passwordSecret = "${owner.name}-password";
in
{
flake.modules.nixos.core =
{
config,
lib,
pkgs,
...
}:
let
hasPasswordSecret = config.age.secrets ? ${passwordSecret};
in
{
users.mutableUsers = true;
users.users.${owner.name} = {
isNormalUser = true;
inherit (owner) uid;
description = owner.fullName;
extraGroups = [
"wheel"
"networkmanager"
"video"
"audio"
"input"
"render"
];
shell = pkgs.zsh;
openssh.authorizedKeys.keys = owner.sshAuthorizedKeys;
# Real password comes from agenix; otherwise a throwaway one so the first
# boot can never lock the user out.
hashedPasswordFile = lib.mkIf hasPasswordSecret config.age.secrets.${passwordSecret}.path;
initialPassword = lib.mkIf (!hasPasswordSecret) "changeme";
};
# Required by `shell = pkgs.zsh` (puts zsh into /etc/shells).
programs.zsh.enable = true;
security.sudo.wheelNeedsPassword = true;
warnings = lib.optional (!hasPasswordSecret) ''
User "${owner.name}" has the temporary password "changeme". Run `passwd` after
the first login, or add secrets/${passwordSecret}.age (hashed with
`mkpasswd -m yescrypt`, encrypted with agenix) and `git add` it.
'';
};
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T1): replaced in phase 2
{
flake.modules.homeManager.apps = { };
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T1): replaced in phase 2
{
flake.modules.nixos.audio = { };
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T1): replaced in phase 2
{
flake.modules.nixos.fonts = { };
}
File renamed without changes.
+135
View File
@@ -0,0 +1,135 @@
# Hyprland desktop, both halves of one feature:
# NixOS UWSM-managed compositor, SDDM with autologin of the owner,
# portals, keyring and the small services a desktop needs.
# home-manager the user configuration. Hyprland reads Lua: the real config
# is in the .lua files next to this file; Nix only passes in the
# values that come from elsewhere (`require("nixvars")`).
# The NixOS half adds the home-manager half to the owner, so a host imports
# `nixos.hyprland` once. Noctalia, audio and fonts are separate aspects.
{ config, ... }:
let
inherit (config.meta) owner;
hmHyprland = config.flake.modules.homeManager.hyprland;
in
{
flake.modules.nixos.hyprland =
{ pkgs, ... }:
{
home-manager.users.${owner.name}.imports = [ hmHyprland ];
# package/portalPackage stay default: the overlay swaps in the flake builds.
programs.hyprland = {
enable = true;
withUWSM = true;
xwayland.enable = true;
};
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
settings.Autologin = {
Session = "hyprland.desktop";
User = owner.name;
};
};
xdg.portal.extraPortals = [
pkgs.xdg-desktop-portal-gtk
pkgs.xdg-desktop-portal-hyprland
];
security.polkit.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.dconf.enable = true;
# Electron/Chromium apps use native Wayland.
environment.sessionVariables.NIXOS_OZONE_WL = "1";
# Removable drives and trash/mounts in the file manager.
services.udisks2.enable = true;
services.gvfs.enable = true;
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
};
environment.systemPackages = with pkgs; [
wl-clipboard
cliphist
grim
slurp
brightnessctl
playerctl
pavucontrol
kdePackages.dolphin
kdePackages.dolphin-plugins
hyprpicker
];
};
flake.modules.homeManager.hyprland =
{
config,
lib,
pkgs,
osConfig,
...
}:
let
cursor = config.home.pointerCursor;
# Exposed to the Lua files as `require("nixvars")`. Keyboard layouts come
# from the NixOS configuration (services.xserver.xkb, set by the host),
# the cursor from home-manager (set by Stylix, theme/stylix.nix).
nixVars = {
kbLayout = osConfig.services.xserver.xkb.layout;
kbOptions = osConfig.services.xserver.xkb.options;
terminal = "wezterm";
fileManager = "dolphin";
cursorSize = if cursor.enable then cursor.size else 24;
cursorTheme = if cursor.enable then cursor.name else "";
};
in
{
wayland.windowManager.hyprland = {
enable = true;
configType = "lua";
# The NixOS half (programs.hyprland) installs the compositor and the
# portal, built from the flake overlay. Installing them again here would
# put a second copy in the user profile.
package = null;
portalPackage = null;
# UWSM owns the session and graphical-session.target; HM's own
# hyprland-session.target and dbus import would only duplicate that.
systemd.enable = false;
xwayland.enable = true;
# Loaded in name order; `nixvars` is a helper module, not loaded on its
# own. Stylix's colours are rendered after these files (hl.config in
# hyprland.lua), so they override the colours in settings.lua.
extraLuaFiles = {
nixvars = {
content = "return ${lib.generators.toLua { } nixVars}\n";
autoLoad = false;
};
"10-settings" = ./settings.lua;
"20-binds" = ./binds.lua;
"30-rules" = ./rules.lua;
};
};
# Tools the binds call (screenshots, file manager).
home.packages = with pkgs; [
grim
slurp
wl-clipboard
kdePackages.dolphin
kdePackages.dolphin-plugins
];
};
}
File renamed without changes.
File renamed without changes.
+5
View File
@@ -0,0 +1,5 @@
# STUB (T1): replaced in phase 2
{
flake.modules.nixos.noctalia = { };
flake.modules.homeManager.noctalia = { };
}
+50
View File
@@ -0,0 +1,50 @@
# WezTerm terminal (SUPER+Return in Hyprland). Colours and the font come from
# Stylix (theme/stylix.nix: scheme "stylix", Monaspace Krypton + Noto Color
# Emoji, size 12); this file holds the rest of the configuration.
{
flake.modules.homeManager.wezterm =
{ lib, ... }:
let
action = lib.generators.mkLuaInline;
in
{
programs.wezterm = {
enable = true;
settings = {
# Wayland-native, no client-side titlebar (Hyprland draws the borders).
enable_wayland = true;
window_decorations = "NONE";
window_padding = {
left = 8;
right = 8;
top = 8;
bottom = 8;
};
# A tab bar only when there is more than one tab.
hide_tab_bar_if_only_one_tab = true;
use_fancy_tab_bar = false;
scrollback_lines = 20000;
audible_bell = "Disabled";
check_for_updates = false;
# Hyprland owns SUPER and ALT+Tab, so splits live on CTRL+SHIFT.
# phys: keys are layout independent and work with the ru layout.
keys = [
{
key = "phys:D";
mods = "CTRL|SHIFT";
action = action "wezterm.action.SplitHorizontal { domain = 'CurrentPaneDomain' }";
}
{
key = "phys:E";
mods = "CTRL|SHIFT";
action = action "wezterm.action.SplitVertical { domain = 'CurrentPaneDomain' }";
}
];
};
};
};
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T1): replaced in phase 2
{
flake.modules.homeManager.xdg = { };
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T2): replaced in phase 2
{
flake.modules.nixos.docker = { };
}
+67
View File
@@ -0,0 +1,67 @@
# Gitea Actions runner "performance" for git.faumaray.com, running jobs in
# rootful Docker (dev/docker.nix). The registration token is an agenix secret:
# secrets/gitea-runner-token.age one line `TOKEN=<registration token>`
# (nix run .#secret-from-file -- gitea-runner-token.age <file>)
# Without that file the runner is not configured and a warning says so.
{ config, lib, ... }:
let
tokenSecret = config.meta.secretsDir + "/gitea-runner-token.age";
hasToken = builtins.pathExists tokenSecret;
in
{
flake.modules.nixos.gitea-runner =
{ config, ... }:
{
age.secrets = lib.optionalAttrs hasToken {
gitea-runner-token = {
file = tokenSecret;
mode = "0400";
};
};
# An instance without token or tokenFile fails the upstream assertion, so
# the instance only exists when the secret does.
services.gitea-actions-runner.instances = lib.optionalAttrs hasToken {
performance = {
enable = true;
url = "https://git.faumaray.com";
name = "Perfrormance Runner";
tokenFile = config.age.secrets.gitea-runner-token.path;
labels = [
"ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest"
"voelin-release:docker://docker.gitea.com/runner-images:ubuntu-latest"
"ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04"
"ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04"
"echoion-release-serial:docker://git.faumaray.ru/void/echoion-release-builder:gcc-16.1.0"
];
settings = {
runner = {
capacity = 5;
timeout = "3h";
fetch_timeout = "5s";
fetch_interval = "1s";
};
cache = {
enabled = true;
host = "192.168.255.242"; # or "localhost" if not using isolated docker containers
port = 8088;
dir = "/var/lib/gitea-runner/cache";
};
container = {
# Ensure the job container passes standard bridge mode
network_mode = "bridge";
# Provide the job containers an alias to reach the host system
options = "--add-host=host.docker.internal:host-gateway";
};
};
};
};
warnings = lib.optional (!hasToken) ''
The Gitea Actions runner "performance" is not configured: secrets/gitea-runner-token.age
is missing. Put `TOKEN=<new registration token>` in a file, then
`nix run .#secret-from-file -- gitea-runner-token.age <file>` and `git add` it.
'';
};
}
+20
View File
@@ -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";
};
};
}
+34
View File
@@ -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
'';
};
}
+70
View File
@@ -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.
'';
};
};
}
+54
View File
@@ -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;
};
};
}
+44
View File
@@ -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
];
};
}
+32
View File
@@ -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;
};
}
+9
View File
@@ -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" ];
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T2): replaced in phase 2
{
flake.modules.nixos.gaming = { };
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T2): replaced in phase 2
{
flake.modules.nixos.amd = { };
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T2): replaced in phase 2
{
flake.modules.nixos.rocm = { };
}
-33
View File
@@ -1,33 +0,0 @@
# Everyday desktop applications.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.home.apps;
in
{
options.my.home.apps.enable = lib.mkEnableOption "desktop applications";
config = lib.mkIf cfg.enable {
programs = {
firefox.enable = true;
mpv.enable = true;
imv.enable = true;
zathura.enable = true;
};
home.packages = with pkgs; [
vesktop # Discord client with working screen sharing on Wayland
telegram-desktop
file-roller
teamspeak6-client
loupe # image viewer
zenity
procps
networkmanager-openvpn
];
};
}
-17
View File
@@ -1,17 +0,0 @@
# Home-manager modules, all behind `my.home.<name>.enable` (default false).
# Loaded for every user through home-manager.sharedModules (see lib/default.nix);
# hosts/<name>/home.nix turns the wanted ones on.
{
imports = [
./hyprland
./noctalia.nix
./wezterm.nix
./neovim
./shell.nix
./git.nix
./ssh.nix
./xdg.nix
./theming.nix
./apps.nix
];
}
-65
View File
@@ -1,65 +0,0 @@
# Hyprland user configuration. Hyprland 0.56 reads Lua, so the real config lives
# in the plain .lua files next to this module; Nix only passes in the few
# values that come from the system config (keyboard layouts, cursor, apps).
{
config,
lib,
pkgs,
osConfig,
...
}:
let
cfg = config.my.home.hyprland;
cursor = config.home.pointerCursor;
# Exposed to the Lua files as `require("nixvars")`.
nixVars = {
kbLayout = lib.concatStringsSep "," osConfig.my.locale.keyboardLayouts;
kbOptions = lib.concatStringsSep "," osConfig.my.locale.keyboardOptions;
terminal = "wezterm";
fileManager = "dolphin";
cursorSize = if cursor.enable then cursor.size else 24;
cursorTheme = if cursor.enable then cursor.name else "";
};
in
{
options.my.home.hyprland.enable = lib.mkEnableOption "Hyprland user configuration (Lua)";
config = lib.mkIf cfg.enable {
wayland.windowManager.hyprland = {
enable = true;
configType = "lua";
# The NixOS module (programs.hyprland) installs the compositor and the
# portal, built from the flake overlay. Installing them again here would
# put a second copy in the user profile.
package = null;
portalPackage = null;
# UWSM owns the session and graphical-session.target; HM's own
# hyprland-session.target and dbus import would only duplicate that.
systemd.enable = false;
xwayland.enable = true;
# Loaded in name order; `nixvars` is a helper module, not loaded on its own.
extraLuaFiles = {
nixvars = {
content = "return ${lib.generators.toLua { } nixVars}\n";
autoLoad = false;
};
"10-settings" = ./settings.lua;
"20-binds" = ./binds.lua;
"30-rules" = ./rules.lua;
};
};
# Tools the binds call (screenshots, file manager).
home.packages = with pkgs; [
grim
slurp
wl-clipboard
kdePackages.dolphin
kdePackages.dolphin-plugins
];
};
}
-54
View File
@@ -1,54 +0,0 @@
# Neovim with LSP, completion, fuzzy finding and format-on-save.
# The editor config is in init.lua next to this file.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.home.neovim;
in
{
options.my.home.neovim.enable = lib.mkEnableOption "Neovim editor";
config = lib.mkIf cfg.enable {
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
plugins = with pkgs.vimPlugins; [
nvim-treesitter.withAllGrammars
nvim-lspconfig
blink-cmp
telescope-nvim
telescope-fzf-native-nvim
plenary-nvim
lualine-nvim
gitsigns-nvim
which-key-nvim
oil-nvim
conform-nvim
catppuccin-nvim
nvim-web-devicons
mini-nvim
];
# Language servers, formatters and search tools, visible to nvim only.
extraPackages = with pkgs; [
nixd
nixfmt
lua-language-server
stylua
bash-language-server
shfmt
ripgrep
fd
];
initLua = builtins.readFile ./init.lua;
};
};
}
-47
View File
@@ -1,47 +0,0 @@
# Noctalia v5 shell (bar, launcher, notifications, lock screen, wallpaper).
# The module itself comes from the noctalia flake (home-manager sharedModules).
# Settings are validated at build time by `noctalia config validate`, so only
# keys from the upstream schema may appear here. Anything changed in the
# settings window at runtime is stored separately and overrides this file.
{
config,
lib,
...
}:
let
cfg = config.my.home.noctalia;
in
{
options.my.home.noctalia.enable = lib.mkEnableOption "Noctalia shell";
config = lib.mkIf cfg.enable {
programs.noctalia = {
enable = true;
# A user service instead of hl.exec_cmd, so it restarts on failure and
# follows graphical-session.target (managed by UWSM).
systemd.enable = true;
settings = {
theme = {
mode = "dark";
source = "builtin";
builtin = "Catppuccin";
};
shell = {
# Installed system-wide (modules/nixos/desktop/fonts.nix).
font_family = "Monaspace Krypton";
telemetry_enabled = false;
# No other polkit agent is started in the session.
polkit_agent = true;
# Apps started from the launcher get their own systemd scope, so
# restarting the shell service does not kill them.
launch_apps_as_systemd_services = true;
};
};
};
};
}
-84
View File
@@ -1,84 +0,0 @@
# Interactive shell: zsh with starship prompt, fzf, zoxide, eza, bat, direnv.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.home.shell;
in
{
options.my.home.shell.enable = lib.mkEnableOption "zsh shell environment and CLI tools";
config = lib.mkIf cfg.enable {
programs = {
zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
autocd = true;
history = {
size = 50000;
save = 50000;
# Share between open terminals, skip duplicates and space-prefixed lines.
share = true;
ignoreDups = true;
ignoreSpace = true;
extended = true;
};
shellAliases = {
cat = "bat";
".." = "cd ..";
g = "git";
# nh builds, diffs and activates the flake in one step.
rebuild = "nh os switch";
rebuild-boot = "nh os boot";
rebuild-test = "nh os test";
};
};
starship = {
enable = true;
settings = {
add_newline = false;
# Short marker inside `nix shell` / `nix develop`.
nix_shell.format = "[$symbol$state]($style) ";
};
};
fzf = {
enable = true;
defaultCommand = "fd --type f --hidden --exclude .git";
fileWidget.command = "fd --type f --hidden --exclude .git";
changeDirWidget.command = "fd --type d --hidden --exclude .git";
};
# `z dir` jumps to frecent directories, `zi` picks with fzf.
zoxide.enable = true;
# ls, ll, la, lt and lla aliases come from the zsh integration.
eza = {
enable = true;
icons = "auto";
git = true;
};
bat.enable = true;
direnv = {
enable = true;
nix-direnv.enable = true;
};
btop.enable = true;
fastfetch.enable = true;
};
# fd backs the fzf commands above.
home.packages = [ pkgs.fd ];
};
}
-81
View File
@@ -1,81 +0,0 @@
# SSH client, agent and the user's keys.
# Private keys are agenix secrets (decrypted at boot into /run/agenix); this
# module only links them into ~/.ssh so ssh finds them at the usual path.
{
config,
lib,
osConfig,
...
}:
let
cfg = config.my.home.ssh;
secrets = osConfig.my.secrets;
# Keys that actually have an encrypted secret in the repo. Without a secret
# nothing is linked, so a fresh install still boots and ssh falls back to
# whatever key the user generates by hand.
keys = lib.filter (k: osConfig.age.secrets ? "ssh-${k}") secrets.userSshKeys;
pubFile = k: secrets.dir + "/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
{
options.my.home.ssh.enable = lib.mkEnableOption "SSH client, agent and agenix-provided keys";
config = lib.mkIf cfg.enable {
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. The
# system must not start another agent (programs.ssh.startAgent).
services.ssh-agent.enable = true;
home.file = keyFiles // pubFiles;
};
}
-51
View File
@@ -1,51 +0,0 @@
# Dark GTK and Qt look, icons and cursor. Noctalia themes the shell itself;
# this keeps the apps consistent with it.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.home.theming;
in
{
options.my.home.theming.enable = lib.mkEnableOption "GTK/Qt theme, icons and cursor";
config = lib.mkIf cfg.enable {
gtk = {
enable = true;
colorScheme = "dark";
theme = {
name = "adw-gtk3-dark";
package = pkgs.adw-gtk3;
};
iconTheme = {
name = "Papirus-Dark";
package = pkgs.papirus-icon-theme;
};
};
# gtk.enable above lets GTK apps pick the cursor up from here.
home.pointerCursor = {
enable = true;
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
gtk.enable = true;
};
# Qt apps follow the GTK settings, with the Adwaita dark widget style.
qt = {
enable = true;
platformTheme.name = "gtk3";
style.name = "adwaita-dark";
};
# libadwaita and GTK 4 apps read the preference from dconf. The system
# needs programs.dconf.enable for this to be applied.
dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
};
}
-50
View File
@@ -1,50 +0,0 @@
# WezTerm terminal (SUPER+Return in Hyprland). The fonts it asks for
# (JetBrainsMono Nerd Font, Noto Color Emoji) come from modules/nixos/desktop/fonts.nix.
{
config,
lib,
...
}:
let
cfg = config.my.home.wezterm;
in
{
options.my.home.wezterm.enable = lib.mkEnableOption "WezTerm terminal";
config = lib.mkIf cfg.enable {
programs.wezterm = {
enable = true;
extraConfig = ''
local act = wezterm.action
local config = wezterm.config_builder()
config.color_scheme = 'Catppuccin Mocha'
config.font = wezterm.font_with_fallback { 'Monaspace Krypton', 'Noto Color Emoji' }
config.font_size = 12.0
-- Wayland-native, no client-side titlebar (Hyprland draws the borders).
config.enable_wayland = true
config.window_decorations = 'NONE'
config.window_padding = { left = 8, right = 8, top = 8, bottom = 8 }
-- A tab bar only when there is more than one tab.
config.hide_tab_bar_if_only_one_tab = true
config.use_fancy_tab_bar = false
config.scrollback_lines = 20000
config.audible_bell = 'Disabled'
config.check_for_updates = false
-- Hyprland owns SUPER and ALT+Tab, so splits live on CTRL+SHIFT.
-- phys: keys are layout independent and work with the ru layout.
config.keys = {
{ key = 'phys:D', mods = 'CTRL|SHIFT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
{ key = 'phys:E', mods = 'CTRL|SHIFT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
}
return config
'';
};
};
}
-67
View File
@@ -1,67 +0,0 @@
# XDG base dirs, the user folders and default applications.
# Documents, Downloads, Music, Pictures and Videos are separate subvolumes on
# the data SSD mounted into $HOME (my.disks); Desktop, Templates and Public
# are plain directories on the system disk. Home-manager's default folder
# names already match, so only the unwanted ones are changed.
{
config,
lib,
...
}:
let
cfg = config.my.home.xdg;
firefox = "firefox.desktop";
fileManager = "Dolphin.desktop";
imageViewer = "org.gnome.Loupe.desktop";
mediaPlayer = "mpv.desktop";
pdfViewer = "org.pwmt.zathura.desktop";
archiveManager = "org.gnome.FileRoller.desktop";
in
{
options.my.home.xdg.enable = lib.mkEnableOption "XDG directories and default applications";
config = lib.mkIf cfg.enable {
xdg = {
enable = true;
userDirs = {
enable = true;
createDirectories = true;
# No ~/Projects: code lives wherever the user clones it.
projects = null;
};
mimeApps = {
enable = true;
defaultApplications = {
"text/html" = firefox;
"x-scheme-handler/http" = firefox;
"x-scheme-handler/https" = firefox;
"x-scheme-handler/about" = firefox;
"x-scheme-handler/unknown" = firefox;
"inode/directory" = fileManager;
"image/*" = imageViewer;
"video/*" = mediaPlayer;
"audio/*" = mediaPlayer;
"application/pdf" = pdfViewer;
"application/zip" = archiveManager;
"application/x-tar" = archiveManager;
"application/x-7z-compressed" = archiveManager;
"application/vnd.rar" = archiveManager;
};
};
# "Open in terminal" actions (desktop entries with Terminal=true) use WezTerm.
terminal-exec = {
enable = true;
settings.default = [ "org.wezfurlong.wezterm.desktop" ];
};
};
};
}
+165
View File
@@ -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.
'';
};
}
+14
View File
@@ -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
];
};
}
+69
View File
@@ -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";
};
}
-80
View File
@@ -1,80 +0,0 @@
# Installer ISO (`nix build .#iso`): the minimal NixOS installer plus this
# flake and the install tooling. Wired up in lib/default.nix (mkInstaller).
{
lib,
pkgs,
inputs,
self,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
# Every flake input including nested ones, so the sources are on the ISO and
# a locked flake installs without re-downloading them.
allInputs = builtins.genericClosure {
startSet = map (i: {
key = toString i.outPath;
inherit i;
}) (lib.attrValues inputs);
operator =
x:
map (i: {
key = toString i.outPath;
inherit i;
}) (lib.attrValues (x.i.inputs or { }));
};
in
{
nix.settings = {
experimental-features = [
"nix-command"
"flakes"
];
# The flake's nixConfig lists binary caches (Noctalia, nix-community).
accept-flake-config = true;
};
# nmtui / nmcli instead of wpa_supplicant.
networking.networkmanager = {
enable = true;
plugins = with pkgs; [
networkmanager-openvpn
];
};
networking.wireless.enable = lib.mkForce false;
environment.systemPackages = [
pkgs.install-system
pkgs.create-keys
pkgs.set-password
pkgs.secret-from-file
pkgs.git
pkgs.jq
pkgs.age
pkgs.sbctl
pkgs.btrfs-progs
pkgs.neovim
inputs.disko.packages.${system}.disko
inputs.agenix.packages.${system}.default
];
# The flake itself, read-only. install-system copies it before changing it.
environment.etc."nixos-config".source = self;
system.extraDependencies = map (x: x.i.outPath) allInputs;
users.motd = ''
NixOS installer for the "desktop" flake
1. Network: nmtui (Ethernet works out of the box)
2. Install: sudo install-system
(flake: /etc/nixos-config, or --flake DIR for a copy on a stick;
--keys-dir DIR for keys/ on a mounted stick)
3. Keys: create-keys, set-password, secret-from-file (see the README)
install-system asks which disks to use and erases them only after you type the host name.
'';
}
+108
View File
@@ -0,0 +1,108 @@
# Installer ISO (`nix build .#iso`): the minimal NixOS installer plus this
# flake and the install tooling. The installer is not a host: it imports no
# other aspect and has no home-manager.
{
config,
inputs,
lib,
...
}:
let
overlay = config.flake.overlays.default;
in
{
flake.modules.nixos.installer =
{ pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) system;
# Every flake input including nested ones, so the sources are on the ISO and
# a locked flake installs without re-downloading them.
allInputs = builtins.genericClosure {
startSet = map (i: {
key = toString i.outPath;
inherit i;
}) (lib.attrValues inputs);
operator =
x:
map (i: {
key = toString i.outPath;
inherit i;
}) (lib.attrValues (x.i.inputs or { }));
};
in
{
nix.settings = {
experimental-features = [
"nix-command"
"flakes"
];
# The flake's nixConfig lists binary caches (Noctalia, nix-community).
accept-flake-config = true;
};
# nmtui / nmcli instead of wpa_supplicant.
networking.networkmanager = {
enable = true;
plugins = with pkgs; [
networkmanager-openvpn
];
};
networking.wireless.enable = lib.mkForce false;
environment.systemPackages = [
pkgs.install-system
pkgs.create-keys
pkgs.set-password
pkgs.secret-from-file
pkgs.git
pkgs.jq
pkgs.age
pkgs.sbctl
pkgs.btrfs-progs
pkgs.neovim
inputs.disko.packages.${system}.disko
inputs.agenix.packages.${system}.default
];
# The flake itself, read-only. install-system copies it before changing it.
environment.etc."nixos-config".source = inputs.self;
system.extraDependencies = map (x: x.i.outPath) allInputs;
users.motd = ''
NixOS installer for the "desktop" flake
1. Network: nmtui (Ethernet works out of the box)
2. Install: sudo install-system
(flake: /etc/nixos-config, or --flake DIR for a copy on a stick;
--keys-dir DIR for keys/ on a mounted stick)
3. Keys: create-keys, set-password, secret-from-file (see the README)
install-system asks which disks to use and erases them only after you type the host name.
'';
};
flake.nixosConfigurations.installer = inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
{
nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.overlays = [ overlay ];
}
config.flake.modules.nixos.installer
];
};
perSystem =
{ system, ... }:
{
# The ISO is built for x86_64-linux only.
packages = lib.optionalAttrs (system == "x86_64-linux") {
iso = config.flake.nixosConfigurations.installer.config.system.build.isoImage;
};
};
}
+67
View File
@@ -0,0 +1,67 @@
# proxy-suite (github:FUFSoB/proxy-suite-flake): zapret DPI bypass, the
# Telegram WebSocket proxy and the GUI. The MTProto secret is an agenix secret:
# secrets/tg-ws-proxy-secret.age the secret (`openssl rand -hex 16`)
# (nix run .#secret-from-file -- tg-ws-proxy-secret.age <file>)
# proxy-suite reads it through systemd LoadCredential, so root ownership is
# enough. Without the file the Telegram proxy stays off and a warning says so.
{
config,
inputs,
lib,
...
}:
let
tgSecret = config.meta.secretsDir + "/tg-ws-proxy-secret.age";
hasTgSecret = builtins.pathExists tgSecret;
in
{
flake.modules.nixos.proxy-suite =
{ config, ... }:
{
imports = [ inputs.proxy-suite.nixosModules.default ];
age.secrets = lib.optionalAttrs hasTgSecret {
tg-ws-proxy-secret = {
file = tgSecret;
mode = "0400";
};
};
services.proxy-suite = {
enable = true;
proxy = {
enable = false;
};
# perAppRouting = {
# enable = true;
# createDefaultProfiles = true;
# proxychains.enable = true;
# tun.enable = true;
# tproxy.enable = true;
# zapret.enable = true;
# };
zapret = {
enable = true;
zapret-discord-youtube.configName = "general(ALT)";
};
tgWsProxy = {
enable = hasTgSecret;
secretFile = if hasTgSecret then config.age.secrets.tg-ws-proxy-secret.path else null;
bypassTransparentProxy = true;
};
gui.enable = true;
};
warnings = lib.optional (!hasTgSecret) ''
The Telegram WebSocket proxy (services.proxy-suite.tgWsProxy) is off:
secrets/tg-ws-proxy-secret.age is missing. Create a new secret with
`openssl rand -hex 16`, then `nix run .#secret-from-file -- tg-ws-proxy-secret.age <file>`
and `git add` it.
'';
};
}
+4
View File
@@ -0,0 +1,4 @@
# STUB (T2): replaced in phase 2
{
flake.modules.nixos.vpn = { };
}
-49
View File
@@ -1,49 +0,0 @@
# Bootloader: lanzaboote (Secure Boot) or plain systemd-boot, plus kernel.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.boot;
in
{
options.my.boot.secureBoot.enable = lib.mkEnableOption ''
Secure Boot through lanzaboote. Keys live in /var/lib/sbctl (create them
with `sbctl create-keys` before the first boot). When disabled the system
uses plain systemd-boot
'';
config = lib.mkMerge [
{
boot = {
loader.efi.canTouchEfiVariables = true;
initrd.systemd.enable = true;
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
};
}
(lib.mkIf cfg.secureBoot.enable {
boot = {
lanzaboote = {
enable = true;
pkiBundle = "/var/lib/sbctl";
configurationLimit = 10;
};
# lanzaboote installs the boot entries itself.
loader.systemd-boot.enable = lib.mkForce false;
};
environment.systemPackages = [ pkgs.sbctl ];
})
(lib.mkIf (!cfg.secureBoot.enable) {
boot.loader.systemd-boot = {
enable = true;
configurationLimit = 10;
editor = false;
};
})
];
}
-57
View File
@@ -1,57 +0,0 @@
# Time zone, locale and keyboard layout (also used by the console and by the
# home-manager Hyprland module through osConfig).
{ config, lib, ... }:
let
cfg = config.my.locale;
inherit (lib) mkOption types;
in
{
options.my.locale = {
timeZone = mkOption {
type = types.str;
example = "Europe/Moscow";
description = "IANA time zone name.";
};
defaultLocale = mkOption {
type = types.str;
default = "en_US.UTF-8";
description = "Default system locale (LANG).";
};
keyboardLayouts = mkOption {
type = types.listOf types.str;
default = [ "us" ];
example = [
"us"
"ru"
];
description = "XKB layouts, in switching order.";
};
keyboardOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "grp:alt_shift_toggle" ];
description = "XKB options such as the layout toggle shortcut.";
};
};
config = {
time.timeZone = cfg.timeZone;
i18n = {
inherit (cfg) defaultLocale;
# Russian stays available for apps and games even with an English UI.
extraLocales = [ "ru_RU.UTF-8/UTF-8" ];
};
services.xserver.xkb = {
layout = lib.concatStringsSep "," cfg.keyboardLayouts;
options = lib.concatStringsSep "," cfg.keyboardOptions;
};
# TTY and initrd keymap follow the XKB layout above.
console.useXkbConfig = true;
};
}
-93
View File
@@ -1,93 +0,0 @@
# NetworkManager with the default (closed) firewall. The user joins the
# `networkmanager` group in users.nix.
{
config,
lib,
pkgs,
...
}:
{
networking = {
networkmanager = {
enable = true;
plugins = with pkgs; [
networkmanager-openvpn
];
};
firewall.enable = false;
};
programs.nm-applet.enable = true;
programs.amnezia-vpn.enable = true;
services.proxy-suite = {
enable = true;
proxy = {
enable = false;
};
# perAppRouting = {
# enable = true;
# createDefaultProfiles = true;
# proxychains.enable = true;
# tun.enable = true;
# tproxy.enable = true;
# zapret.enable = true;
# };
zapret = {
enable = true;
zapret-discord-youtube.configName = "general(ALT)";
};
tgWsProxy = {
enable = true;
secret = "637854682629bfdca35fe9c58e797915";
bypassTransparentProxy = true;
};
gui.enable = true;
};
virtualisation.docker.enable = true;
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
virtualisation.docker.storageDriver = "btrfs";
services.gitea-actions-runner.instances."performance" = {
enable = true;
url = "https://git.faumaray.com";
name = "Perfrormance Runner";
token = "DJrTt1RLMROrXxVBDF1XVvo7wiKhHVxmofBBjl4S";
labels = [
"ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest"
"voelin-release:docker://docker.gitea.com/runner-images:ubuntu-latest"
"ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04"
"ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04"
"echoion-release-serial:docker://git.faumaray.ru/void/echoion-release-builder:gcc-16.1.0"
];
settings = {
runner = {
capacity = 5;
timeout = "3h";
fetch_timeout = "5s";
fetch_interval = "1s";
};
cache = {
enabled = true;
host = "192.168.255.242"; # or "localhost" if not using isolated docker containers
port = 8088;
dir = "/var/lib/gitea-runner/cache";
};
container = {
# Ensure the job container passes standard bridge mode
network_mode = "bridge";
# Provide the job containers an alias to reach the host system
options = "--add-host=host.docker.internal:host-gateway";
};
};
};
}
-53
View File
@@ -1,53 +0,0 @@
# Nix daemon settings, binary caches, garbage collection and flake registry.
{
config,
inputs,
...
}:
{
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true;
# root is already trusted by default; this adds the admin group.
trusted-users = [ "@wheel" ];
warn-dirty = false;
# Same caches as flake.nixConfig, so the system keeps using them after
# install without the "untrusted flake settings" prompt.
extra-substituters = [
"https://nix-community.cachix.org"
"https://noctalia.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"noctalia.cachix.org-1:pCOR47nnMEo5thcxNDtzWpOxNFQsBRglJzxWPp3dkU4="
];
};
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
# `nix shell nixpkgs#foo` and <nixpkgs> use the exact nixpkgs of this flake
# instead of fetching a different revision.
channel.enable = false;
registry.nixpkgs.flake = inputs.nixpkgs;
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
};
programs = {
# Nicer `nixos-rebuild` front-end that knows where the flake lives.
nh = {
enable = true;
flake = "/home/${config.my.user.name}/nixos-config";
};
# Lets prebuilt binaries (editors' language servers, game launchers) run.
nix-ld.enable = true;
};
}
-90
View File
@@ -1,90 +0,0 @@
# The primary (only) interactive user.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.user;
inherit (lib) mkOption types;
passwordSecret = "${cfg.name}-password";
hasPasswordSecret = config.age.secrets ? ${passwordSecret};
in
{
options.my.user = {
name = mkOption {
type = types.str;
example = "faumaray";
description = "Login name of the primary user.";
};
fullName = mkOption {
type = types.str;
description = "Display name (GECOS), also used for git.";
};
email = mkOption {
type = types.str;
description = "E-mail address, used for git.";
};
uid = mkOption {
type = types.int;
default = 1000;
description = "Numeric user id.";
};
extraGroups = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Groups in addition to the ones every desktop user gets.";
};
sshAuthorizedKeys = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Public keys allowed to log in over SSH.";
};
};
config = {
users.mutableUsers = true;
users.users.${cfg.name} = {
isNormalUser = true;
inherit (cfg) uid;
description = cfg.fullName;
extraGroups = [
"wheel"
"networkmanager"
"video"
"audio"
"input"
"render"
"docker"
]
++ lib.optional config.my.gaming.enable "gamemode"
++ cfg.extraGroups;
shell = pkgs.zsh;
openssh.authorizedKeys.keys = cfg.sshAuthorizedKeys;
# Real password comes from agenix; otherwise a throwaway one so the first
# boot can never lock the user out.
hashedPasswordFile = lib.mkIf hasPasswordSecret config.age.secrets.${passwordSecret}.path;
initialPassword = lib.mkIf (!hasPasswordSecret) "changeme";
};
# Required by `shell = pkgs.zsh` (puts zsh into /etc/shells).
programs.zsh.enable = true;
security.sudo.wheelNeedsPassword = true;
warnings = lib.optional (!hasPasswordSecret) ''
User "${cfg.name}" has the temporary password "changeme". Run `passwd` after
the first login, or add secrets/${passwordSecret}.age (hashed with
`mkpasswd -m yescrypt`, encrypted with agenix) and `git add` it.
'';
};
}
-24
View File
@@ -1,24 +0,0 @@
# Every NixOS module of this flake (exported as `nixosModules.default`).
# Each file declares its own `my.*` options and is inert until enabled.
{
imports = [
./core/nix.nix
./core/boot.nix
./core/locale.nix
./core/users.nix
./core/networking.nix
./hardware/amd.nix
./hardware/disks.nix
./security/secrets.nix
./security/ssh.nix
./desktop/hyprland.nix
./desktop/noctalia.nix
./desktop/audio.nix
./desktop/fonts.nix
./gaming/steam.nix
];
}
-24
View File
@@ -1,24 +0,0 @@
# PipeWire as the single audio server (ALSA, PulseAudio and JACK clients).
{ config, lib, ... }:
{
config = lib.mkIf config.my.desktop.hyprland.enable {
services = {
pipewire = {
enable = true;
alsa = {
enable = true;
# 32-bit ALSA clients: Wine/Proton games.
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
wireplumber.enable = true;
};
pulseaudio.enable = false;
};
# Lets PipeWire take realtime scheduling for low-latency audio.
security.rtkit.enable = true;
};
}
-28
View File
@@ -1,28 +0,0 @@
# System fonts and the default families fontconfig falls back to.
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkIf config.my.desktop.hyprland.enable {
fonts = {
packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-color-emoji
inter
nerd-fonts.jetbrains-mono
nerd-fonts.symbols-only
monaspace
];
fontconfig.defaultFonts = {
monospace = [ "Monaspace Radon" ];
sansSerif = [ "Inter" ];
emoji = [ "Noto Color Emoji" ];
};
};
};
}
-88
View File
@@ -1,88 +0,0 @@
# Hyprland session: UWSM-managed compositor, greetd login, portals, keyring and
# the small system services a desktop needs. Noctalia, audio and fonts are
# separate files gated on the same option.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.desktop.hyprland;
in
{
options.my.desktop.hyprland.enable = lib.mkEnableOption "the Hyprland desktop session";
config = lib.mkIf cfg.enable {
# package/portalPackage stay default: the overlay swaps in the flake builds.
programs.hyprland = {
enable = true;
withUWSM = true;
xwayland.enable = true;
};
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
settings = {
Autologin = {
Session = "hyprland.desktop";
User = "faumaray";
};
};
};
services.greetd = {
enable = false;
# Keeps boot messages from drawing over the greeter.
useTextGreeter = true;
settings.default_session = {
command = lib.concatStringsSep " " [
(lib.getExe pkgs.tuigreet)
"--time"
"--remember"
"--remember-user-session"
"--asterisks"
"--sessions ${config.services.displayManager.sessionData.desktops}/share/wayland-sessions"
];
user = "greeter";
};
};
xdg.portal.extraPortals = [
pkgs.xdg-desktop-portal-gtk
pkgs.xdg-desktop-portal-hyprland
];
security.polkit.enable = true;
services.gnome.gnome-keyring.enable = true;
security.pam.services.greetd.enableGnomeKeyring = true;
programs.dconf.enable = true;
# Electron/Chromium apps use native Wayland.
environment.sessionVariables.NIXOS_OZONE_WL = "1";
# Removable drives and trash/mounts in the file manager.
services.udisks2.enable = true;
services.gvfs.enable = true;
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
};
environment.systemPackages = with pkgs; [
wl-clipboard
cliphist
grim
slurp
brightnessctl
playerctl
pavucontrol
kdePackages.dolphin
kdePackages.dolphin-plugins
hyprpicker
];
};
}
-19
View File
@@ -1,19 +0,0 @@
# Noctalia shell, system side. The user service is started by home-manager
# (modules/home), so `programs.noctalia.systemd` stays off here.
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkIf config.my.desktop.hyprland.enable {
programs.noctalia = {
enable = true;
package = pkgs.noctalia;
# NetworkManager, Bluetooth, UPower and power-profiles-daemon, which the
# shell's panels talk to.
recommendedServices.enable = true;
};
};
}
-57
View File
@@ -1,57 +0,0 @@
# Steam + Proton, gamescope, gamemode and MangoHud.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.gaming;
in
{
options.my.gaming.enable = lib.mkEnableOption "the gaming stack (Steam, Proton-GE, gamescope, gamemode)";
config = lib.mkIf cfg.enable {
programs = {
steam = {
enable = true;
remotePlay.openFirewall = true;
localNetworkGameTransfers.openFirewall = true;
dedicatedServer.openFirewall = false;
gamescopeSession.enable = true;
extraCompatPackages = [ pkgs.proton-ge-bin ];
protontricks.enable = true;
# Steam Input on Wayland (controllers acting as keyboard/mouse).
extest.enable = true;
};
gamescope = {
enable = false;
# Lets gamescope raise its own priority.
capSysNice = true;
};
gamemode = {
enable = true;
settings = {
general.renice = 10;
gpu = {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = 0;
amd_performance_level = "high";
};
};
};
};
hardware.steam-hardware.enable = true;
environment.systemPackages = with pkgs; [
mangohud
protonplus
];
# Some Proton games exhaust the default map count and crash.
boot.kernel.sysctl."vm.max_map_count" = 2147483642;
};
}
-71
View File
@@ -1,71 +0,0 @@
# AMD CPU + Radeon GPU. nixos-hardware (common-cpu-amd, -pstate, -gpu-amd,
# -pc-ssd) is imported by the host; defaults that overlap use mkDefault.
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.hardware.amd;
in
{
options.my.hardware.amd = {
enable = lib.mkEnableOption "AMD CPU and Radeon GPU support";
rocm.enable = lib.mkEnableOption "ROCm/HIP compute stack (rocminfo, rocm-smi, /opt/rocm/hip)";
lact.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "LACT daemon for GPU monitoring, fan curves and overclocking.";
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
hardware = {
graphics = {
enable = true;
# Steam/Proton and Wine need the 32-bit Mesa drivers.
enable32Bit = true;
};
amdgpu = {
initrd.enable = lib.mkDefault true;
opencl.enable = true;
};
cpu.amd.updateMicrocode = lib.mkDefault true;
};
boot.kernelModules = [ "kvm-amd" ];
environment.systemPackages = with pkgs; [
vulkan-tools
mesa-demos
radeontop
nvtopPackages.amd
lm_sensors
];
}
(lib.mkIf cfg.lact.enable {
services.lact.enable = true;
# LACT needs the overdrive bit in amdgpu.ppfeaturemask to tune clocks.
hardware.amdgpu.overdrive.enable = true;
})
(lib.mkIf cfg.rocm.enable {
environment.systemPackages = with pkgs.rocmPackages; [
rocminfo
rocm-smi
];
# Many HIP applications look for the runtime in /opt/rocm/hip.
systemd.tmpfiles.rules = [ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ];
})
]
);
}
-216
View File
@@ -1,216 +0,0 @@
# Declarative disk layout, generated into `disko.devices` from `my.disks`.
#
# 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 user's home (~/Games, ~/Music, ...)
#
# `disko-install` / the install script partitions the disks from this; on a
# running system the same data produces the matching `fileSystems` entries.
{
config,
lib,
...
}:
let
cfg = config.my.disks;
inherit (lib) mkOption types;
user = config.my.user.name;
home = "/home/${user}";
folders = cfg.data.homeFolders;
hasFolders = cfg.data.enable && folders != { };
# Compression keeps the NVMe small-write friendly; noatime avoids metadata writes.
btrfsOptions = [
"compress=zstd:1"
"noatime"
];
placeholderDevices = lib.filter (d: lib.hasInfix "CHANGE-ME" d) (
[ cfg.system.device ] ++ lib.optional cfg.data.enable cfg.data.device
);
in
{
options.my.disks = {
enable = lib.mkEnableOption "the disko-managed disk layout";
system = {
device = mkOption {
type = types.str;
example = "/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_1TB_S6XXXXXXXXXXXX";
description = "Whole disk for the ESP and the btrfs root. Use a stable /dev/disk/by-id path.";
};
espSize = mkOption {
type = types.str;
default = "2G";
description = "Size of the EFI system partition (mounted on /boot).";
};
swapSize = mkOption {
type = types.str;
default = "16G";
description = "Size of the swapfile in the @swap subvolume.";
};
};
data = {
enable = lib.mkEnableOption "the second (data) disk";
device = mkOption {
type = types.str;
example = "/dev/disk/by-id/ata-Samsung_SSD_870_EVO_2TB_S6XXXXXXXXXXXX";
description = "Whole disk holding the home folder subvolumes.";
};
mountOptions = mkOption {
type = types.listOf types.str;
default = [
"compress=zstd:1"
"noatime"
# The machine still boots (to the system disk) if the SSD is missing.
"nofail"
"x-systemd.device-timeout=10s"
];
description = "Mount options of every data subvolume.";
};
homeFolders = mkOption {
type = types.attrsOf (
types.submodule (
{ name, ... }:
{
options.subvolume = mkOption {
type = types.str;
default = "@" + lib.toLower name;
defaultText = lib.literalExpression ''"@" + lib.toLower name'';
description = "Btrfs subvolume backing this folder.";
};
}
)
);
default = { };
example = lib.literalExpression ''{ Games = { }; Music.subvolume = "@tunes"; }'';
description = ''
Folders of the home directory that live on the data disk. The attribute
name is the folder name and is mounted at /home/<user>/<name>.
'';
};
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
disko.devices.disk.system = {
type = "disk";
inherit (cfg.system) device;
content = {
type = "gpt";
partitions = {
ESP = {
size = cfg.system.espSize;
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 = cfg.system.swapSize;
};
};
};
};
};
};
};
# Logs must be mounted before journald starts in stage 2.
fileSystems."/var/log".neededForBoot = true;
services.btrfs.autoScrub = {
enable = true;
interval = "monthly";
fileSystems = [
"/"
]
++ lib.optional hasFolders "${home}/${lib.head (lib.attrNames folders)}";
};
warnings = lib.optional (placeholderDevices != [ ]) ''
my.disks still has placeholder device paths (${lib.concatStringsSep ", " placeholderDevices}).
Run `nix run .#install`, or edit hosts/desktop/disk-ids.json, before installing.
'';
}
(lib.mkIf cfg.data.enable {
disko.devices.disk.data = {
type = "disk";
inherit (cfg.data) device;
content = {
type = "gpt";
partitions.data = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [
"-f"
"-L"
"data"
];
subvolumes = lib.mapAttrs' (
name: folder:
lib.nameValuePair folder.subvolume {
mountpoint = "${home}/${name}";
inherit (cfg.data) mountOptions;
}
) folders;
};
};
};
};
# Subvolume roots are created root-owned; hand them to the user. The
# home directory itself is listed first so the mount points have a parent.
systemd.tmpfiles.rules = [
"d ${home} 0700 ${user} users -"
]
++ lib.mapAttrsToList (name: _: "d ${home}/${name} 0755 ${user} users -") folders;
})
]
);
}
-75
View File
@@ -1,75 +0,0 @@
# agenix secrets. Every secret file is optional: a secret is only declared when
# its .age file exists in `my.secrets.dir`, so a fresh clone still evaluates.
#
# <user>-password.age hashed login password (mkpasswd -m yescrypt)
# ssh-<key>.age private SSH key, installed for the user (home-manager
# links it to ~/.ssh/<key>)
{
config,
inputs,
lib,
pkgs,
...
}:
let
cfg = config.my.secrets;
user = config.my.user.name;
secretFile = name: cfg.dir + "/${name}.age";
exists = name: builtins.pathExists (secretFile name);
passwordSecrets = lib.optionalAttrs (exists "${user}-password") {
"${user}-password" = {
file = secretFile "${user}-password";
mode = "0400";
};
};
sshSecrets = lib.listToAttrs (
map (
key:
lib.nameValuePair "ssh-${key}" {
file = secretFile "ssh-${key}";
owner = user;
mode = "0400";
}
) (lib.filter (key: exists "ssh-${key}") cfg.userSshKeys)
);
in
{
options.my.secrets = {
enable = lib.mkEnableOption "agenix secrets from the repository's secrets/ directory";
dir = lib.mkOption {
type = lib.types.path;
default = ../../../secrets;
defaultText = lib.literalExpression "../../../secrets";
description = ''
Directory holding the *.age files. In a flake only files tracked by git
are visible, so `git add` new secrets before building.
'';
};
userSshKeys = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"id_ed25519"
"id_ed25519_work"
];
description = "SSH key names; each maps to secrets/ssh-<name>.age if present.";
};
};
config = lib.mkIf cfg.enable {
# 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
];
};
}
-21
View File
@@ -1,21 +0,0 @@
# Key-only OpenSSH server. The host key is also the agenix identity.
{
services.openssh = {
enable = true;
openFirewall = true;
settings = {
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
PermitRootLogin = "no";
};
hostKeys = [
{
type = "ed25519";
path = "/etc/ssh/ssh_host_ed25519_key";
}
];
};
# The keyring (NixOS) and home-manager provide the agent.
programs.ssh.startAgent = false;
}
+59
View File
@@ -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
];
};
}
+105
View File
@@ -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;
};
}
+140
View File
@@ -0,0 +1,140 @@
# Theme: one palette, fonts, cursor and icons for the whole desktop, applied by
# Stylix (github:nix-community/stylix).
# NixOS Stylix itself (its home-manager module is added to every
# home-manager user and inherits these settings), the TTY
# palette and the default font families.
# home-manager which programs Stylix themes.
# Targets are opt-in (`autoEnable = false`): Stylix touches only what is listed
# here. A new program that Stylix supports gets its `stylix.targets.<name>`
# line in this file.
{ config, inputs, ... }:
let
inherit (config.meta) owner;
hmTheme = config.flake.modules.homeManager.theme;
in
{
flake.modules.nixos.theme =
{ pkgs, ... }:
{
imports = [ inputs.stylix.nixosModules.stylix ];
home-manager.users.${owner.name}.imports = [ hmTheme ];
stylix = {
enable = true;
# With autoEnable Stylix would also write GNOME, KDE, X resources, gedit,
# gdu, Blender, ... configs and rebuild gtksourceview through an overlay.
autoEnable = false;
polarity = "dark";
# Catppuccin Mocha, from tinted-theming/schemes base16/catppuccin-mocha.yaml.
# Inline, so evaluation needs no import-from-derivation. Another scheme:
# base16Scheme = "${pkgs.base16-schemes}/share/themes/<name>.yaml";
base16Scheme = {
scheme = "Catppuccin Mocha";
author = "https://github.com/catppuccin/catppuccin";
slug = "catppuccin-mocha";
variant = "dark";
base00 = "1e1e2e"; # base
base01 = "181825"; # mantle
base02 = "313244"; # surface0
base03 = "45475a"; # surface1
base04 = "585b70"; # surface2
base05 = "cdd6f4"; # text
base06 = "f5e0dc"; # rosewater
base07 = "b4befe"; # lavender
base08 = "f38ba8"; # red
base09 = "fab387"; # peach
base0A = "f9e2af"; # yellow
base0B = "a6e3a1"; # green
base0C = "94e2d5"; # teal
base0D = "89b4fa"; # blue
base0E = "cba6f7"; # mauve
base0F = "f2cdcd"; # flamingo
};
# No wallpaper: Noctalia draws it, so every Stylix wallpaper part stays off.
image = null;
fonts = {
monospace = {
package = pkgs.monaspace;
name = "Monaspace Radon";
};
sansSerif = {
package = pkgs.inter;
name = "Inter";
};
serif = {
package = pkgs.noto-fonts;
name = "Noto Serif";
};
emoji = {
package = pkgs.noto-fonts-color-emoji;
name = "Noto Color Emoji";
};
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
icons = {
enable = true;
package = pkgs.papirus-icon-theme;
dark = "Papirus-Dark";
light = "Papirus-Light";
};
targets = {
# TTY palette (vt.default_{red,grn,blu} kernel parameters).
console.enable = true;
# fontconfig default families from `fonts` above, and their packages.
fontconfig.enable = true;
font-packages.enable = true;
# programs.dconf, which home-manager's GTK settings need.
gtk.enable = true;
};
};
};
flake.modules.homeManager.theme = {
stylix.targets = {
gtk = {
enable = true;
# No Flatpak here: do not write ~/.themes or Flatpak overrides.
flatpakSupport.enable = false;
};
qt.enable = true;
hyprland.enable = true;
noctalia = {
enable = true;
# Keep Noctalia's own panel opacities and the shell font chosen for it.
opacity.enable = false;
fonts.override.sansSerif.name = "Monaspace Krypton";
};
wezterm = {
enable = true;
fonts.override.monospace.name = "Monaspace Krypton";
};
bat.enable = true;
btop.enable = true;
fzf.enable = true;
starship.enable = true;
mpv.enable = true;
zathura.enable = true;
# Not enabled:
# - neovim: cli/neovim/init.lua still sets the catppuccin colorscheme;
# Stylix's mini.base16 would run after it and stack a second one.
# - firefox: needs a declared profile (programs.firefox.profiles);
# declaring one would replace the existing Firefox profile.
};
# libadwaita/GTK 4 apps read the preference from dconf.
gtk.colorScheme = "dark";
dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
};
}
+13
View File
@@ -0,0 +1,13 @@
# faumaray, the owner of this flake. Identity data only; the aspects read it
# through `config.meta.owner` (schema: modules/flake/meta.nix).
{
meta.owner = {
name = "faumaray";
fullName = "faumaray";
email = "faumaray@gmail.com";
sshKeys = [
"id_ed25519"
"id_ed25519_work"
];
};
}
-7
View File
@@ -1,7 +0,0 @@
# Adds this repository's own packages (./pkgs) to pkgs.
{ inputs }:
final: _prev:
import ../pkgs {
pkgs = final;
inherit inputs;
}
-32
View File
@@ -1,32 +0,0 @@
# Overlays exposed as `self.overlays.<name>`; `default` composes all of them
# and is applied to every host (see lib/default.nix).
{ inputs }:
let
inherit (inputs.nixpkgs) lib;
in
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, as published on noctalia.cachix.org.
noctalia = import ./noctalia.nix { inherit inputs; };
# Our own packages from ./pkgs (install tooling and helpers).
additions = import ./additions.nix { inherit inputs; };
# Tweaks to existing nixpkgs packages.
modifications = import ./modifications.nix { inherit inputs; };
default = lib.composeManyExtensions [
hyprland
noctalia
additions
modifications
];
}
-8
View File
@@ -1,8 +0,0 @@
# Changes to existing nixpkgs packages. Add `name = prev.name.override { ... }`
# or `.overrideAttrs` entries here; they apply system-wide and to home-manager
# (useGlobalPkgs = true).
{ inputs }:
_final: prev: {
# btop with AMD GPU monitoring (ROCm SMI) for the Radeon card.
btop = prev.btop.override { rocmSupport = true; };
}
-7
View File
@@ -1,7 +0,0 @@
# Use the Noctalia build from its own flake. That flake does not follow our
# nixpkgs, so the store path matches noctalia.cachix.org and is downloaded
# instead of compiled.
{ inputs }:
final: _prev: {
noctalia = inputs.noctalia.packages.${final.stdenv.hostPlatform.system}.default;
}