-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
197 lines (183 loc) · 5.65 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
apple-silicon.url = "github:tpwrules/nixos-apple-silicon";
neovim.url = "github:nix-community/neovim-nightly-overlay";
neovim.inputs.nixpkgs.follows = "nixpkgs";
drduh.url = "github:drduh/YubiKey-Guide";
drduh.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
nixpkgs,
flake-utils,
darwin,
home-manager,
...
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
dotfiles = ./.;
pkgs = nixpkgs.legacyPackages.${system};
pkgs-force = import "${nixpkgs}" {
inherit system;
config = {
allowBroken = true;
allowUnfree = true;
allowUnsupportedSystem = true;
};
};
pkgs-inputs = # { name = inputs.${name}.packages.${system} }
builtins.mapAttrs (
_:
nixpkgs.lib.attrByPath [
"packages"
system
] { }
) inputs;
pkgs-local = import ./nix/pkgs {
inherit
inputs
system
pkgs
pkgs-inputs
pkgs-local
;
};
dot-nixos-rebuild = pkgs.writeShellApplication {
name = "dot-nixos-rebuild";
runtimeInputs = [ pkgs.nixos-rebuild ];
text = ''
sudo nixos-rebuild --flake "$HOME/dotfiles#''${HOSTNAME:-$(hostname)}" "$@"
'';
};
dot-channel-sync = pkgs.writeShellApplication {
name = "dot-channel-sync";
runtimeInputs = [ pkgs.nix ];
text = ''
nix-channel --add https://github.com/NixOS/nixpkgs/archive/${inputs.nixpkgs.rev}.tar.gz nixpkgs
nix-channel --update nixpkgs
'';
};
dot-darwin-rebuild =
if pkgs-inputs.darwin ? "darwin-rebuild" && pkgs-inputs.darwin.darwin-rebuild.meta.available then
pkgs.writeShellApplication {
name = "dot-darwin-rebuild";
runtimeInputs = [ pkgs-inputs.darwin.darwin-rebuild ];
text = ''
darwin-rebuild --flake "$HOME/dotfiles#''${HOSTNAME:-$(hostname)}" "$@"
'';
}
else
pkgs.empty;
dot-home-manager = pkgs.writeShellApplication {
name = "dot-home-manager";
runtimeInputs = [ pkgs-inputs.home-manager.home-manager ];
text = ''
home-manager --flake "$HOME/dotfiles#$USER@''${HOSTNAME:-$(hostname)}" "$@"
'';
};
specialArgs = {
inherit
inputs
dotfiles
system
pkgs-force
pkgs-inputs
pkgs-local
;
inherit (pkgs) stdenv;
};
in
{
packages = pkgs-local // {
inherit (pkgs) nixos-rebuild;
inherit (pkgs-inputs.darwin) darwin-rebuild;
inherit (pkgs-inputs.home-manager) home-manager;
inherit
dot-nixos-rebuild
dot-channel-sync
dot-darwin-rebuild
dot-home-manager
;
nixosConfigurations = {
MICHON-PC = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./nix/nixos/common
./nix/nixos/desktop
];
};
MICHON-MACBOOK = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./nix/nixos/common
./nix/nixos/macbook
];
};
YUBIKEY = inputs.drduh.nixosConfigurations.yubikeyLive.${system}.extendModules {
modules = [
{
environment.systemPackages = with pkgs; [
neovim
pinentry-curses
];
}
];
};
};
darwinConfigurations = {
MICHON-MACBOOK = darwin.lib.darwinSystem {
inherit specialArgs system;
modules = [
./nix/darwin/common
./nix/darwin/macbook
];
};
};
homeConfigurations = {
"maienm@MICHON-PC" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
modules = [
./nix/home-manager/common
./nix/home-manager/desktop
];
};
"maienm@MICHON-MACBOOK" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
modules = [
./nix/home-manager/common
./nix/home-manager/macbook
];
};
"maienm@neptune" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
modules = [
./nix/home-manager/common
./nix/home-manager/neptune.nix
];
};
};
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
dot-nixos-rebuild
dot-channel-sync
dot-darwin-rebuild
dot-home-manager
python3
python3.pkgs.pytest
];
};
}
);
}