Add NixOS modules: boot, users, AMD, disko layout, secrets, Hyprland, Steam
- my.disks generates disko: NVMe btrfs (@root/@home/@nix/@log/@swap) + SATA SSD btrfs with one subvolume per ~/Games, Downloads, Documents, Music, Pictures, Videos, Storage (nofail) - lanzaboote Secure Boot, systemd initrd, latest kernel - AMD CPU/GPU: amdgpu initrd, OpenCL, LACT, optional ROCm - agenix with host-key identity, optional password and SSH key secrets - Hyprland (UWSM, XWayland) + greetd/tuigreet, Noctalia services, PipeWire, fonts - Steam + Proton-GE, gamescope, gamemode - overlays: compose Hyprland's hyprland-packages + hyprland-extras (upstream default lacks the hyprwm dependency overlays) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J1cugeLkfFLZMpiztQ8TyN
This commit is contained in:
21 files changed
+972
-4
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# 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;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
# 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;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# NetworkManager with the default (closed) firewall. The user joins the
|
||||
# `networkmanager` group in users.nix.
|
||||
{
|
||||
networking = {
|
||||
networkmanager.enable = true;
|
||||
firewall.enable = true;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
# 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"
|
||||
]
|
||||
++ 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.
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user