-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
125 lines (114 loc) · 2.91 KB
/
default.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
{ atomi }:
{ nixpkgs, outputs, user_config }:
# Check operating system
let linux = user_config.kernel == "linux"; in
# Obtain Patch
let
darwinPatch = import ./patches-darwin.nix {
inherit atomi nixpkgs;
};
in
let
linuxPatch = import ./patches-linux.nix {
inherit atomi nixpkgs;
};
in
let patches = if linux then linuxPatch else darwinPatch; in
# inject tools
let tools = outputs.home.packages ++ patches.tools; in
let
output1 = builtins.mapAttrs
(n: v:
if n == "home" then
(
builtins.mapAttrs (n1: v1: if n1 == "packages" then tools else v1) v
) else v)
outputs;
in
#inject ZSH
let zsh = output1.programs.zsh.initExtra; in
let zshNew = patches.preZSH + zsh + patches.postZSH; in
let
output2 = builtins.mapAttrs
(n: v:
if n == "programs" then
(
builtins.mapAttrs
(n1: v1:
if n1 == "zsh" then
(
builtins.mapAttrs (n2: v2: if n2 == "initExtra" then zshNew else v2) v1
) else v1)
v
) else v)
output1;
in
# inject envVars
let envVars = output2.home.sessionVariables // patches.envVars; in
let
output3 = builtins.mapAttrs
(n: v:
if n == "home" then
(
builtins.mapAttrs (n1: v1: if n1 == "sessionVariables" then envVars else v1) v
) else v)
output2;
in
# inject PATH
let path = output3.home.sessionPath ++ patches.path; in
let
output4 = builtins.mapAttrs
(n: v:
if n == "home" then
(
builtins.mapAttrs (n1: v1: if n1 == "sessionPath" then path else v1) v
) else v)
output3;
in
# inject program configurations
let programs = output4.programs // patches.programs; in
let
output5 = builtins.mapAttrs (n: v: if n == "programs" then programs else v) output4;
in
# inject oh-my-zsh-plugins
let omz-plugins = output5.programs.zsh.oh-my-zsh.plugins ++ patches.oh-my-zsh-plugins; in
let
output6 = builtins.mapAttrs
(n: v:
if n == "programs" then
(
builtins.mapAttrs
(n1: v1:
if n1 == "zsh" then
(
builtins.mapAttrs
(n2: v2:
if n2 == "oh-my-zsh" then
(
builtins.mapAttrs (n3: v3: if n3 == "plugins" then omz-plugins else v3) v2
) else v2)
v1
) else v1)
v
) else v)
output5;
in
# inject shell aliases
let aliases = output6.programs.zsh.shellAliases // patches.shellAliases; in
let
output7 = builtins.mapAttrs
(n: v:
if n == "programs" then
(
builtins.mapAttrs
(n1: v1:
if n1 == "zsh" then
(
builtins.mapAttrs (n2: v2: if n2 == "shellAliases" then aliases else v2) v1
) else v1)
v
) else v)
output6;
in
# return
output7