Skill站外收录 @skilllib/skill-2014279423728496641
system-planning
提供 NixOS 系统级配置与管理能力,覆盖服务启停、硬件驱动、网络策略、启动参数、用户权限及安全加固等场景,强调声明式配置、原子化更新和可复现性,适用于构建稳定、安全、可维护的生产环境。
效率工具 AI 技能
Skills.MD
# NixOS System Planning Guide
Expert guidance for NixOS system-level configuration, administration, and
maintenance.
## Core Principles
1. **Declarative first** - Define desired state, let NixOS handle the rest
2. **Reproducibility** - Same config should produce same system
3. **Atomic updates** - Changes are all-or-nothing with rollback
4. **Security by default** - Minimize attack surface
5. **Stability focus** - Prioritize reliability over bleeding edge
## System Configuration Workflow
Copy this checklist when making system changes:
```
System Configuration Progress:
- [ ] Step 1: Identify requirements and constraints
- [ ] Step 2: Check existing configuration for conflicts
- [ ] Step 3: Plan changes in staging/VM first
- [ ] Step 4: Implement changes incrementally
- [ ] Step 5: Test each change before next
- [ ] Step 6: Document non-obvious decisions
- [ ] Step 7: Verify rollback works if needed
```
## Configuration Areas
### System Services
```nix
# Enable and configure services
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedTlsSettings = true;
};
```
### Hardware Configuration
```nix
# hardware-configuration.nix (auto-generated, but can extend)
hardware.cpu.intel.updateMicrocode = true;
hardware.enableAllFirmware = true;
# GPU configuration
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true; # For Steam/gaming
};
```
### Networking
```nix
networking = {
hostName = "myhost";
networkmanager.enable = true;
# Firewall
firewall = {
enable = true;
allowedTCPPorts = [ 22 80 443 ];
allowedUDPPorts = [ ];
};
};
```
### Boot Configuration
```nix
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
# Kernel parameters
kernelParams = [ "quiet" "splash" ];
# Kernel modules
kernelModules = [ "kvm-intel" ];
};
```
### User Management
```nix
users.users.myuser = {
isNormalUser = true;
description = "My User";
extraGroups = [ "wheel" "networkmanager" "docker" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAA..."
];
};
# Disable mutable users for reproducibility
users.mutableUsers = false;
```
## Security Hardening
### Essential Security Settings
```nix
security = {
# Sudo configuration
sudo = {
enable = true;
wheelNeedsPassword = true;
};
# Audit logging
auditd.enable = true;
# AppArmor (alternative to SELinux)
apparmor.enable = true;
};
# Disable unnecessary services
services.avahi.enable = false;
# Restrict kernel features
boot.kernel.sysctl = {
"kernel.unprivileged_bpf_disabled" = 1;
"net.core.bpf_jit_harden" = 2;
};
```
### Security Checklist
- [ ] SSH key-only authentication
- [ ] Firewall enabled with minimal ports
- [ ] Automatic security updates configured
- [ ] Audit logging enabled
- [ ] Unnecessary services disabled
- [ ] User privileges minimized
## Performance Tuning
### System Optimization
```nix
# Increase file descriptor limits
security.pam.loginLimits = [{
domain = "*";
type = "soft";
item = "nofile";
value = "65536";
}];
# Zram swap for better memory utilization
zramSwap = {
enable = true;
algorithm = "zstd";
memoryPercent = 50;
};
# SSD optimization
services.fstrim.enable = true;
```
## Maintenance Procedures
### Regular Tasks
| Task | Frequency | Command |
| ------------------ | ------------------- | ------------------------------------- |
| Update system | Weekly | `sudo nixos-rebuild switch --upgrade` |
| Garbage collection | Monthly | `sudo nix-collect-garbage -d` |
| Check disk space | Weekly | `df -h` |
| Review logs | Weekly | `journalctl -p err -b` |
| Test rollback | After major changes | Boot previous generation |
### Troubleshooting Quick Reference
| Issue | Diagnostic | Resolution |
| ------------------- | ---------------------------- | ----------------------- |
| Boot failure | Boot previous generation | Fix config, rebuild |
| Service won't start | `systemctl status <service>` | Check logs, fix config |
| Network issues | `ip addr`, `ping` | Check networking config |
| Disk full | `ncdu /` | Run garbage collection |
| Performance issues | `htop`, `iotop` | Identify bottleneck |
## Decision Guide
### When to Use System vs Home Config
| Configuration | System (nixos/) | Home (home/) |
| ------------------- | --------------- | ------------ |
| System services | Yes | No |
| Hardware drivers | Yes | No |
| Firewall rules | Yes | No |
| User applications | Prefer home | Yes |
| Desktop environment | Either | Prefer home |
| Shell configuration | Either | Prefer home |
## See Also
- **Module placement**: See
[scaffolding-modules](../../khanelinix/scaffolding-modules/) for where to put
system configs
- **Configuration layers**: See
[configuring-layers](../../khanelinix/configuring-layers/) for override
precedence
- **Flake management**: See [managing-flakes](../managing-flakes/) for input and
dependency management
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「system-planning」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次