refactor(common): modularize common host module
check / lint (push) Successful in 14s

This commit is contained in:
2026-10-11 17:34:29 +02:00
parent deeffb8b8b
commit 7f5d7914c4
13 changed files with 124 additions and 81 deletions
+6 -75
View File
@@ -1,92 +1,23 @@
{
inputs,
outputs,
dotsPath,
myUtils,
config,
...
}:
{ lib, ... }:
let
inherit (inputs.nixpkgs) lib;
homeDir = ../../home/hosts + "/${config.host.name}";
in
{
imports = [
inputs.home-manager.nixosModules.default
./embedded.nix
./home-manager.nix
./host.nix
./nix.nix
./nixpkgs.nix
./upgrades.nix
];
options.nixpkgs.allowedUnfree = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
config = {
system.stateVersion = lib.mkDefault "25.05";
boot.zfs.forceImportRoot = lib.mkDefault false;
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
optimise = {
automatic = true;
dates = [ "05:00" ];
};
gc = {
automatic = true;
dates = "weekly";
options = lib.mkDefault "--delete-older-than 30d";
};
settings.experimental-features = [
"nix-command"
"flakes"
];
settings.trusted-public-keys = [
"nix-signing-key:M6ouQRFl/bZ5QQrceQUyar6P7o8qg4wwVkxD1SSLL2k="
];
};
system.autoUpgrade = {
enable = true;
flags = [
"--recreate-lock-file"
"--commit-lock-file"
"--print-build-logs"
"--refresh"
];
dates = "05:00";
randomizedDelaySec = "45min";
allowReboot = false;
};
nixpkgs.config.allowUnfreePredicate =
pkg: builtins.elem (lib.getName pkg) config.nixpkgs.allowedUnfree;
environment.defaultPackages = lib.mkForce [ ];
environment.pathsToLink = [
"/share/applications"
"/share/xdg-desktop-portal"
];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit
inputs
outputs
dotsPath
myUtils
;
};
sharedModules = [
{
host.username = lib.mkDefault config.host.username;
}
];
users = lib.optionalAttrs (builtins.pathExists homeDir) {
${config.host.username} = import homeDir;
};
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{ lib, config, ... }:
{
config = lib.mkIf (config.host.role == "embedded") {
system.autoUpgrade.enable = false;
nix.settings.max-jobs = 0;
zramSwap = {
enable = true;
memoryPercent = 100;
};
services.journald.settings.Journal.SystemMaxUse = "100M";
};
}
+37
View File
@@ -0,0 +1,37 @@
{
inputs,
outputs,
dotsPath,
myUtils,
config,
lib,
...
}:
let
homeDir = ../../home/hosts + "/${config.host.name}";
in
{
imports = [ inputs.home-manager.nixosModules.default ];
config.home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit
inputs
outputs
dotsPath
myUtils
;
};
sharedModules = [
{
host.username = lib.mkDefault config.host.username;
}
];
users = lib.optionalAttrs (builtins.pathExists homeDir) {
${config.host.username} = import homeDir;
};
};
}
+10
View File
@@ -10,6 +10,16 @@
type = lib.types.str;
};
role = lib.mkOption {
type = lib.types.enum [
"desktop"
"embedded"
"laptop"
"server"
"vm"
];
};
tags = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
+23
View File
@@ -0,0 +1,23 @@
{ inputs, lib, ... }:
{
config.nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
optimise = {
automatic = true;
dates = [ "05:00" ];
};
gc = {
automatic = true;
dates = "weekly";
options = lib.mkDefault "--delete-older-than 30d";
};
settings.experimental-features = [
"nix-command"
"flakes"
];
settings.trusted-public-keys = [
"nix-signing-key:M6ouQRFl/bZ5QQrceQUyar6P7o8qg4wwVkxD1SSLL2k="
];
};
}
+11
View File
@@ -0,0 +1,11 @@
{ lib, config, ... }:
{
options.nixpkgs.allowedUnfree = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
config.nixpkgs.config.allowUnfreePredicate =
pkg: builtins.elem (lib.getName pkg) config.nixpkgs.allowedUnfree;
}
+16
View File
@@ -0,0 +1,16 @@
{ lib, ... }:
{
config.system.autoUpgrade = {
enable = lib.mkDefault true;
flags = [
"--recreate-lock-file"
"--commit-lock-file"
"--print-build-logs"
"--refresh"
];
dates = "05:00";
randomizedDelaySec = "45min";
allowReboot = false;
};
}