-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
152 lines (138 loc) · 4.16 KB
/
flake.nix
File metadata and controls
152 lines (138 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
description = "nobv's Nix Darwin configuration with Home Manager";
inputs = {
determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/*";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin";
darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
determinate,
nixpkgs,
nixpkgs-stable,
darwin,
home-manager,
git-hooks,
}:
let
system = "aarch64-darwin";
pkgs = import nixpkgs {
inherit system;
};
# Shared module auto-discovery function
lib = pkgs.lib;
modulesPath = ./modules;
# Get all modules that have default.nix (both directories and single files)
getModules =
dir:
let
contents = builtins.readDir (modulesPath + "/${dir}");
in
lib.mapAttrsToList
(
name: type:
if type == "directory" then modulesPath + "/${dir}/${name}" else modulesPath + "/${dir}/${name}"
)
(
lib.filterAttrs (
name: type:
(type == "directory" && builtins.pathExists (modulesPath + "/${dir}/${name}/default.nix"))
|| (type == "regular" && name == "default.nix")
) contents
);
# Auto-discover all modules
allModules = lib.flatten [
(getModules "ai")
(getModules "browsers")
(getModules "checkers")
(getModules "communication")
(getModules "design")
(getModules "development")
(getModules "editors")
(getModules "languages")
(getModules "media")
(getModules "productivity")
(getModules "security")
(getModules "system")
(getModules "terminal")
(getModules "utilities")
];
# Function to create a Darwin system with machine-specific config
mkDarwinSystem =
{ machine }:
let
machineConfigPath = ./machines/${machine}/config.nix;
machineConfig =
if builtins.pathExists machineConfigPath then
import machineConfigPath
else
throw "Missing required config file: machines/${machine}/config.nix";
username =
if machineConfig.username == "REPLACE_WITH_YOUR_USERNAME" then
throw "Please update machines/${machine}/config.nix with your actual username (currently set to placeholder 'REPLACE_WITH_YOUR_USERNAME')"
else
machineConfig.username;
in
darwin.lib.darwinSystem {
inherit system;
modules = [
determinate.darwinModules.default
home-manager.darwinModules.home-manager
./machines/${machine}
]
++ allModules;
specialArgs = {
inherit
inputs
nixpkgs
nixpkgs-stable
machine
username
;
};
};
in
{
darwinConfigurations = {
# Machine-specific configurations
macbook = mkDarwinSystem { machine = "macbook"; };
macmini = mkDarwinSystem { machine = "macmini"; };
work = mkDarwinSystem { machine = "work"; };
};
formatter.${system} = pkgs.nixfmt-tree;
checks.${system}.pre-commit = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt.enable = true;
};
};
# Development shell for working with the configuration
devShells.${system}.default =
let
inherit (self.checks.${system}.pre-commit) shellHook enabledPackages;
in
pkgs.mkShell {
inherit shellHook;
buildInputs =
enabledPackages
++ (with pkgs; [
just
nixfmt
nix-tree
]);
};
};
}