Skip to content

Commit 1d2cafd

Browse files
committed
refactor(nix): extract settings.nix to root nix/ directory
Extract settings.nix from nix/modules/shared/ to nix/ for better consistency with the modular flake-parts architecture. ## Changes - Moved `nix/modules/shared/settings.nix` β†’ `nix/settings.nix` - Updated `nix/modules/shared/default.nix` to remove settings.nix import - Updated `flake-modules/hosts.nix` to import settings.nix in both: - darwinConfigurations - nixosConfigurations - Updated FLAKE-PARTS-MIGRATION.md documentation ## Rationale This creates a consistent structure where all core system modules are at the same level: ``` nix/ β”œβ”€β”€ settings.nix # Custom options & config β”œβ”€β”€ shared-configuration.nix # Core system configuration └── overlays.nix # Package overlays ``` All three modules are platform-aware (handling both Darwin and Linux) and are imported by all system configurations, maintaining a single unified configuration across all managed systems. ## Content The settings.nix module remains functionally unchanged: - Defines custom `config.my.*` options - Sets up home-manager aliases - Configures XDG directories - Manages environment variables - Platform-specific home directory logic (Darwin vs Linux) Only the file location has changed for better organization.
1 parent 14f2cd0 commit 1d2cafd

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

β€ŽFLAKE-PARTS-MIGRATION.mdβ€Ž

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,26 @@ outputs = inputs @ {flake-parts, ...}:
4545
β”‚ β”œβ”€β”€ per-system.nix # Per-system outputs (formatter, devShells, apps)
4646
β”‚ └── hosts.nix # Darwin & NixOS configurations
4747
β”œβ”€β”€ nix/
48-
β”‚ β”œβ”€β”€ shared-configuration.nix # Shared config for all systems (NEW)
49-
β”‚ β”œβ”€β”€ overlays.nix # Nixpkgs overlays (NEW)
48+
β”‚ β”œβ”€β”€ settings.nix # Custom options & config (EXTRACTED)
49+
β”‚ β”œβ”€β”€ shared-configuration.nix # Shared config for all systems (EXTRACTED)
50+
β”‚ β”œβ”€β”€ overlays.nix # Nixpkgs overlays (EXTRACTED)
5051
β”‚ β”œβ”€β”€ modules/
51-
β”‚ β”‚ β”œβ”€β”€ shared/ # Shared modules
52-
β”‚ β”‚ β”‚ └── settings.nix # Custom options (UNCHANGED)
52+
β”‚ β”‚ β”œβ”€β”€ shared/ # Shared feature modules (shell, git, vim, etc)
5353
β”‚ β”‚ └── darwin/ # Darwin-specific modules
5454
β”‚ └── hosts/ # Host-specific configs
5555
```
5656

5757
#### Module Breakdown
5858

59+
**`nix/settings.nix`** (Extracted from `nix/modules/shared/`)
60+
- Defines custom `config.my.*` options (username, timezone, email, etc.)
61+
- Sets up home-manager aliases (`my.hm.file`, `my.hm.configFile`, etc.)
62+
- Configures XDG directories (platform-aware)
63+
- Environment variable management
64+
- Platform-specific home directory logic (Darwin vs Linux)
65+
66+
This is a NixOS/nix-darwin module that defines reusable options and configuration used across all systems.
67+
5968
**`nix/shared-configuration.nix`** (Extracted from original `sharedConfiguration`)
6069
- Core Nix settings (experimental features, substituters, GC)
6170
- Font configuration (platform-specific)
@@ -87,16 +96,17 @@ This is a NixOS/nix-darwin module that gets imported by all system configuration
8796

8897
The migration achieves a **single Nix configuration that works on any system** managed by the flake:
8998

90-
1. **`nix/shared-configuration.nix`**: Applied to ALL systems (Darwin and NixOS)
91-
2. **`nix/overlays.nix`**: Applied to ALL systems
92-
3. **`nix/modules/shared/settings.nix`**: Custom options available to ALL systems
99+
1. **`nix/settings.nix`**: Custom options and config applied to ALL systems
100+
2. **`nix/shared-configuration.nix`**: Core system config applied to ALL systems (Darwin and NixOS)
101+
3. **`nix/overlays.nix`**: Package customizations applied to ALL systems
93102
4. Platform-specific logic handled via `pkgs.stdenv.isDarwin` conditionals
94103

95104
All systems share the same:
96-
- Nix settings
105+
- Custom options (`config.my.*`)
106+
- Nix settings and configuration
97107
- Overlays and custom packages
98108
- Base home-manager configuration
99-
- Custom options defined in settings.nix
109+
- XDG directory structure
100110

101111
## Benefits of This Migration
102112

@@ -107,15 +117,27 @@ All systems share the same:
107117
5. **Single Source of Truth**: shared-configuration.nix applies universally
108118
6. **Better Organization**: Clear separation between flake outputs and system modules
109119

110-
## settings.nix Unchanged
120+
## Extracted Core Modules
121+
122+
Three core modules have been extracted to the `nix/` directory for better organization:
123+
124+
**`nix/settings.nix`** (moved from `nix/modules/shared/settings.nix`)
125+
- Defines custom `config.my.*` options
126+
- Sets up home-manager aliases
127+
- Configures XDG directories
128+
- Manages environment variables
129+
- Platform-aware home directory logic
130+
131+
**`nix/shared-configuration.nix`** (extracted from `sharedConfiguration` function)
132+
- Core Nix daemon settings
133+
- Cache configuration
134+
- Font packages
135+
- System-wide settings
111136

112-
The `nix/modules/shared/settings.nix` file remains **completely unchanged**. It continues to:
113-
- Define custom `config.my.*` options
114-
- Set up home-manager aliases
115-
- Configure XDG directories
116-
- Manage environment variables
137+
**`nix/overlays.nix`** (extracted from `sharedConfiguration` function)
138+
- All package overlays and customizations
117139

118-
This is because settings.nix is a NixOS/nix-darwin module (not a flake-parts module), and the migration only affects the flake structure, not the system module structure.
140+
These are NixOS/nix-darwin modules (not flake-parts modules), imported directly by system configurations. The content remains functionally identical, only the organization has changed.
119141

120142
## How to Use
121143

β€Žflake-modules/hosts.nixβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ in {
3131
specialArgs = {inherit inputs self;};
3232
inherit system;
3333
modules = [
34+
../nix/settings.nix
3435
../nix/shared-configuration.nix
3536
../nix/overlays.nix
3637
inputs.home-manager.darwinModules.home-manager
@@ -52,6 +53,7 @@ in {
5253
specialArgs = {inherit inputs self;};
5354
inherit system;
5455
modules = [
56+
../nix/settings.nix
5557
../nix/shared-configuration.nix
5658
../nix/overlays.nix
5759
inputs.home-manager.nixosModules.home-manager

β€Žnix/modules/shared/default.nixβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{lib, ...}: {
22
imports = [
3-
./settings.nix
43
./user-shell.nix
54
./mail.nix
65
./gpg.nix

0 commit comments

Comments
Β (0)