forked from hardselius/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
157 lines (135 loc) · 5.03 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
{
description = "Adam Williams' dotfiles";
inputs = {
nixpkgs-stable.url = "github:NixOS/nixpkgs/24.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
darwin.url = "github:LnL7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, darwin, home-manager, flake-utils, ... }@inputs:
let
inherit (darwin.lib) darwinSystem;
inherit (inputs.nixpkgs-unstable.lib)
attrValues makeOverridable optionalAttrs singleton;
systems = [ "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
nixpkgsConfig = with inputs; rec {
config = { allowUnfree = true; };
overlays = attrValues self.overlays;
};
homeManagerStateVersion = "24.11";
primaryUserInfo = {
username = "adam.williams";
email = "[email protected]";
fullName = "Adam Williams";
github = "awill1988";
};
nixDarwinCommonModules = attrValues self.darwinModules ++ [
home-manager.darwinModules.home-manager
({ config, lib, pkgs, ... }:
let inherit (config.users) primaryUser;
in rec {
nixpkgs = nixpkgsConfig;
users.users.${primaryUser.username} = {
home = "/Users/${primaryUser.username}";
shell = pkgs.zsh;
};
home-manager.useGlobalPkgs = true;
home-manager.users.${primaryUser.username} = {
imports = attrValues self.homeManagerModules;
home.stateVersion = homeManagerStateVersion;
home.user-info = config.users.primaryUser;
};
})
];
in {
darwinConfigurations = rec {
# Minimal configuration to bootstrap systems
bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin";
modules = [
self.darwinModules.common
self.darwinModules.darwin-bootstrap
{ nixpkgs = nixpkgsConfig; }
];
};
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# My macOS configuration
macbook-x86 = darwinSystem {
system = "x86_64-darwin";
modules = nixDarwinCommonModules ++ [
./system/darwin/host-mac.nix
{ users.primaryUser = primaryUserInfo; }
];
};
macbook-arm = darwinSystem {
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
./system/darwin/host-mac.nix
{ users.primaryUser = primaryUserInfo; }
];
};
};
darwinModules = {
common = import ./system/common.nix;
packages = import ./system/packages.nix;
darwin-bootstrap = import ./system/darwin/bootstrap.nix;
darwin-packages = import ./system/darwin/packages.nix;
darwin-system = import ./system/darwin/system.nix;
users-primaryUser = import ./modules/users.nix;
};
homeManagerModules = {
home-config-files = import ./home/config-files.nix;
home-git = import ./home/git.nix;
home-git-ignores = import ./home/git-ignores.nix;
home-packages = import ./home/packages.nix;
home-shells = import ./home/shells.nix;
home-terminal = import ./home/terminal.nix;
home-user-info = { lib, ... }: {
options.home.user-info = (self.darwinModules.users-primaryUser {
inherit lib;
}).options.users.primaryUser;
};
};
overlays = {
pkgs-master = _: prev: {
pkgs-master = import inputs.nixpkgs-master {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-stable = _: prev: {
pkgs-stable = import inputs.nixpkgs-stable {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-unstable = _: prev: {
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
# Overlay useful on Macs with Apple Silicon
apple-silicon = _: prev:
optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs-unstable {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
};
};
extra = import ./overlays/extra.nix;
};
devShell = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rnix-lsp nixpkgs-fmt ];
});
formatter =
forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
};
}