-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
213 lines (195 loc) · 5.68 KB
/
flake.nix
File metadata and controls
213 lines (195 loc) · 5.68 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
{
description = "A modular home-manager configuration for dotfiles";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
tmuxinator-nix = {
url = "github:flyinggrizzly/tmuxinator-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
gwt = {
url = "github:flyinggrizzly/gwt";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
home-manager,
tmuxinator-nix,
...
}@inputs:
let
# Helper function to get the appropriate pkgs for a platform
getPkgs =
platform:
import nixpkgs {
system = platform;
config = {
allowUnfree = true;
};
};
# Supported systems for testing
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
# Helper to create flake outputs for each system
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
# Helper functions
helpers = {
claude.commandDirToTable =
path:
let
files = builtins.readDir path;
regularFiles = nixpkgs.lib.filterAttrs (name: type: type == "regular") files;
in
nixpkgs.lib.mapAttrs' (name: _: {
name = nixpkgs.lib.removeSuffix ".md" name;
value = builtins.readFile (path + "/${name}");
}) regularFiles;
};
# Library functions
lib = {
inherit helpers;
# Core function that creates the basic home configuration
# This is reused by both standaloneHome and nixosHome
prepareHome =
{
username,
stateVersion,
platform,
shell ? { },
neovim ? { },
git ? { },
desktop ? { },
darwin ? { },
excludePackages ? [ ],
extraModules ? [ ],
}:
let
pkgs = getPkgs platform;
# The home-manager configuration module that both functions use
homeConfig =
{
pkgs,
...
}:
{
imports = [
./modules/neovim.nix
./modules/git.nix
./modules/shell.nix
./modules/desktop.nix
./modules/darwin.nix
./modules/exclude-packages.nix
] ++ extraModules; # Direct import of extra modules
# Basic home configuration
home = {
inherit username stateVersion;
homeDirectory = if pkgs.stdenv.isDarwin then "/Users/${username}" else "/home/${username}";
};
programs.home-manager.enable = true;
modules = {
inherit
shell
neovim
git
desktop
darwin
excludePackages
;
};
};
in
{
inherit homeConfig pkgs;
specialArgs = {
# This is passed to the home-manager module through extraSpecialArgs for both nixos and
# standalone cases, so that we can access the lib.constants data in our config
inherit tmuxinator-nix helpers;
};
hmModules = [
homeConfig
inputs.tmuxinator-nix.homeManagerModules.default
inputs.gwt.homeManagerModules.default
];
};
# Function for standalone home-manager configuration
standaloneHome =
args:
let
prepared = lib.prepareHome args;
in
home-manager.lib.homeManagerConfiguration {
pkgs = prepared.pkgs;
modules = prepared.hmModules;
extraSpecialArgs = prepared.specialArgs;
};
# Function for NixOS module integration
nixosHome =
args:
let
prepared = lib.prepareHome args;
inherit (args) username;
in
{
imports = [ home-manager.nixosModules.home-manager ];
home-manager = {
users.${username} =
{ config, ... }:
{
imports = prepared.hmModules;
};
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = prepared.specialArgs;
};
};
};
in
{
inherit lib home-manager helpers;
templates = {
standalone = {
path = ./templates/standalone;
description = "Standalone home-manager configuration template";
};
nixos = {
path = ./templates/nixos;
description = "NixOS configuration with home-manager integration";
};
};
homeConfigurations = {
"seandmr@m1-grizzly" = lib.standaloneHome {
username = "seandmr";
stateVersion = "24.11";
platform = "aarch64-darwin";
darwin.enable = true;
desktop = {
enable = true;
ghostty.enable = true;
kitty.enable = false;
transmission.enable = true;
};
};
};
packages = forAllSystems (
system:
let
testPkgs = getPkgs system;
tests = import ./tests {
pkgs = testPkgs;
inherit (self) lib;
};
in
tests
);
};
}