-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.nix
200 lines (177 loc) · 6.09 KB
/
home.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
{
config,
pkgs,
inputs,
lib,
...
}:
let
# taken from https://github.com/nix-community/home-manager/issues/5757#issuecomment-2297141696
mkExclusionList =
path:
let
content = builtins.readFile path;
lines = builtins.split "\n" content;
nonEmptyLines = lib.filter (
line: (builtins.isString (line) && line != "" && !lib.strings.hasPrefix "#" line)
) lines;
in
nonEmptyLines;
# these come from https://github.com/SterlingHooten/borg-backup-exclusions-macos
macOsExclusions = lib.optionals pkgs.stdenv.isDarwin (
lib.concatMap (path: mkExclusionList path) [
./resources/borgmatic/exclusions/macos/core.lst
./resources/borgmatic/exclusions/macos/applications.lst
./resources/borgmatic/exclusions/macos/programming.lst
]
);
in
{
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "24.05"; # Please read the comment before changing.
imports = [ inputs.sops-nix.homeManagerModules.sops ];
home.homeDirectory = "/Users/szeth";
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
bat
borgmatic
eza
nerdfonts # necessary for agnoster theme
starship
yt-dlp
vscode
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
programs.zoxide.enable = true;
programs.thefuck.enable = true;
programs.direnv = {
enable = true;
enableZshIntegration = true; # see note on other shells below
nix-direnv.enable = true;
};
programs = {
starship =
let
shellConfig = import ./common/shell.nix { inherit pkgs; };
in
shellConfig.programs.starship;
};
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
# for some reason these are flipped
initExtra = ''
eval "$(direnv hook zsh)"
bindkey '^[[Z' complete-word # tab | complete
bindkey '^I' autosuggest-accept # shift + tab | autosuggest
'';
};
programs.git = {
enable = true;
userEmail = "[email protected]";
userName = "szethh";
extraConfig = {
init = {
defaultBranch = "main";
};
};
};
programs.bat.enable = true;
programs.bat.config.theme = "Nord";
programs.vscode = import ./darwin/apps/vscode.nix { inherit pkgs inputs; };
# this does not work yet
programs.firefox = import ./darwin/apps/firefox.nix { inherit pkgs inputs; };
sops = {
# does not seem to work
age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt"; # must have no password!
# It's also possible to use a ssh key, but only when it has no password:
age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ];
age.generateKey = true;
defaultSopsFile = ./secrets/secrets.yaml;
# test secret
secrets.test = {
# sopsFile = ./secrets.yml.enc; # optionally define per-secret files
# %r gets replaced with a runtime directory, use %% to specify a '%'
# sign. Runtime dir is $XDG_RUNTIME_DIR on linux and $(getconf
# DARWIN_USER_TEMP_DIR) on darwin.
# path = "%r/test.txt";
};
};
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
sops.secrets.BORG_PASSPHRASE = { };
### BORG ###
# options here: https://home-manager-options.extranix.com/?query=programs.borg&release=master
# note: the first time we have to manually initialize the repo
# borgmatic init --encryption repokey
programs.borgmatic = {
enable = true;
package = pkgs.borgmatic;
backups = {
"borgbase" = {
location = {
repositories = [ "ssh://[email protected]/./repo" ];
patterns = [
# i figured it's easier to just list what we want to backup
# rather than trying to exclude everything
"R ${config.home.homeDirectory}/uni"
"R ${config.home.homeDirectory}/Zotero"
"R ${config.home.homeDirectory}/gallery-dl"
"R ${config.home.homeDirectory}/Monero"
"R ${config.home.homeDirectory}/MEGAsync"
# todo: do i want to backup dev?
# a lot of stuff is in git already
# but many projects aren't
# "! ${config.home.homeDirectory}/dev"
] ++ macOsExclusions;
excludeHomeManagerSymlinks = true;
};
storage = {
encryptionPasscommand = "cat ${config.sops.secrets.BORG_PASSPHRASE.path}";
};
retention = {
keepWithin = "1d";
keepDaily = 7;
keepWeekly = 4;
keepMonthly = 6;
};
consistency.checks = [
{
name = "repository";
frequency = "2 weeks";
}
{
name = "archives";
frequency = "2 weeks";
}
];
};
};
};
}