-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
211 lines (202 loc) · 6.72 KB
/
flake.nix
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
{
description = "Joe Goldin Nix Config";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
# You can access packages and modules from different nixpkgs revs
# at the same time. Here's an working example:
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# Also see the 'unstable-packages' overlay at 'overlays/default.nix'.
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.05-darwin";
# darwin
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
# Home manager
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# wsl
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
# flake-utils
flake-utils.url = "github:numtide/flake-utils";
# systems
systems.url = "github:nix-systems/default";
# devenv
devenv.url = "github:cachix/devenv";
# nixpkgs-python
nixpkgs-python.url = "github:cachix/nixpkgs-python";
# pre-commit-hooks
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
# brew-nix
brew-nix = {
url = "github:BatteredBunny/brew-nix";
inputs.brew-api.follows = "brew-api";
};
brew-api = {
url = "github:BatteredBunny/brew-api";
flake = false;
};
#disko
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# agenix
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
experimental-features = "nix-command flakes";
};
outputs = {
self,
nixpkgs,
home-manager,
nixos-wsl,
darwin,
devenv,
flake-utils,
systems,
nixpkgs-python,
pre-commit-hooks,
brew-nix,
brew-api,
disko,
agenix,
...
} @ inputs: let
inherit (self) outputs;
username = "joe";
useremail = "[email protected]";
hostname = "${username}-nix";
homeDirectory = nixpkgs.lib.mkForce "/home/${username}";
stateVersion = "24.05";
commonSpecialArgs =
inputs
// {
inherit inputs outputs useremail stateVersion username hostname homeDirectory;
};
eachSystem = nixpkgs.lib.genAttrs (import systems);
basePackages = eachSystem (system: import ./environments/common/pkgs nixpkgs.legacyPackages.${system});
additionalPackages = eachSystem (system: {
# devenv-up = self.devShells.${system}.default.config.procfileScript;
});
in {
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = eachSystem (system: basePackages.${system} // additionalPackages.${system});
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
# Your custom packages and modifications, exported as overlays
overlays = import ./environments/common/overlays {inherit inputs;};
checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
check-yaml.enable = true;
end-of-file-fixer.enable = true;
gitleaks = {
enable = true;
name = "gitleaks";
entry = "${nixpkgs.legacyPackages.${system}.gitleaks}/bin/gitleaks detect --source . -v";
};
};
};
});
devShells = eachSystem (system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
};
});
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#joe-wsl'
nixosConfigurations = {
joe-wsl = nixpkgs.lib.nixosSystem {
specialArgs =
commonSpecialArgs
// {
hostname = "joe-wsl";
};
modules = [
nixos-wsl.nixosModules.default
# > Our main nixos configuration <
./environments/wsl
home-manager.nixosModules.home-manager
({specialArgs, ...}: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.backupFileExtension = "backup"; # enable moving existing files
home-manager.users.${specialArgs.username} = import ./home-manager/wsl;
})
agenix.nixosModules.default
];
};
oracle-cloud-bastion = nixpkgs.lib.nixosSystem {
specialArgs =
commonSpecialArgs
// {
hostname = "bastion";
};
modules = [
disko.nixosModules.disko
# > Our main nixos configuration <
./environments/oracle-cloud
home-manager.nixosModules.home-manager
({specialArgs, ...}: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.backupFileExtension = "backup"; # enable moving existing files
home-manager.users.${specialArgs.username} = import ./home-manager/nixos;
})
agenix.nixosModules.default
({specialArgs, ...}: {
age.secrets.cf = {
file = ./secrets/cf.json.age;
mode = "655";
owner = specialArgs.username;
group = "users";
};
age.identityPaths = ["/home/joe/.ssh/id_ed25519"];
})
];
};
};
# Darwin/macOS configuration entrypoint
# Available through 'darwin-rebuild --flake .#Joes-MacBook-Pro'
darwinConfigurations = {
Joes-MacBook-Pro = darwin.lib.darwinSystem {
system = "aarch64-darwin";
specialArgs =
commonSpecialArgs
// {
username = "joe";
hostname = "Joes-MacBook-Pro";
homeDirectory = nixpkgs.lib.mkForce "/Users/joe";
};
modules = [
# > Our main darwin configuration <
./environments/darwin
home-manager.darwinModules.home-manager
({specialArgs, ...}: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.backupFileExtension = "backup"; # enable moving existing files
home-manager.users.joe.imports = [
./home-manager/darwin
];
})
agenix.nixosModules.default
];
};
};
};
}