mirror of
https://github.com/Death916/nixconfig.git
synced 2026-04-10 02:54:39 -07:00
2.7 KiB
2.7 KiB
NixOS Configuration Refactor
This document outlines the new, modular structure of the NixOS configuration and explains how to revert to the previous setup if necessary.
New Directory Structure
The configuration has been reorganized to be more modular and easier to manage. Here is an overview of the new structure:
.
├── flake.nix
├── home-manager/
│ ├── death916-homelab.nix
│ └── home.nix
├── modules/
│ ├── home-manager/
│ │ └── common.nix
│ └── nixos/
│ ├── common/
│ │ ├── base.nix
│ │ └── tailscale.nix
│ ├── homelab/
│ │ ├── networking.nix
│ │ ├── services.nix
│ │ └── user.nix
│ └── laptop/
│ ├── desktop.nix
│ └── user.nix
├── nixos/
│ ├── configuration.nix
│ └── homelab.nix
├── old_config/ # <-- Your previous configuration is backed up here
└── scripts/
└── nh-push # <-- New helper script
Key Changes
- Modularization: The main
configuration.nixandhomelab.nixfiles have been split into smaller, more focused modules located in themodules/directory. This makes the code cleaner and easier to navigate. - Shared vs. Specific Config: Common settings shared between both the laptop and homelab are now in
modules/nixos/common/andmodules/home-manager/common.nix. Machine-specific configurations are in their respectivelaptop/andhomelab/subdirectories. flake.nix: The flake now usesspecialArgsto pass overlays and other shared values to the modules, reducing redundancy.nh-pushscript: A new script has been added atscripts/nh-push. This script wraps thenh os switchcommand and automatically runsgit pushafter a successful build, streamlining the update process.
How to Revert the Changes
If you encounter any issues with the new configuration, you can easily revert to your previous setup. Your old files are safely archived in the old_config/ directory.
To revert, follow these steps:
-
Delete the new configuration files:
rm -rf flake.nix nixos/ modules/ home-manager/ scripts/ -
Restore the old configuration from the backup:
mv old_config/* . rmdir old_config -
Rebuild your system:
After restoring the files, run your usual NixOS rebuild command, for example:
sudo nixos-rebuild switch --flake .#homelab
This will restore your system to the exact state it was in before these changes were made.