-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
168 lines (154 loc) · 4.75 KB
/
default.nix
File metadata and controls
168 lines (154 loc) · 4.75 KB
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
let
sources = import ./third_party/sources/sources.nix;
depot = import sources.depot { };
pkgs = depot.third_party.nixpkgs // { inherit depot; };
dotfiles = pkgs.lib.fix (self: {
simple_emacs = import ./simple_emacs { inherit pkgs; };
simple_vim = import ./simple_vim { inherit pkgs; };
# Extend your gitconfig by adding this to your ~/.gitconfig:
# [include]
# path = ~/.nix-profile/etc/gitconfig
gitconfig = pkgs.writeTextFile {
name = "gitconfig";
destination = "/etc/gitconfig";
text = ''
[user]
name = William Carroll
email = wpcarro@gmail.com
[pull]
rebase = true
[rebase]
autoStash = true
updateRefs = true
'';
};
path = pkgs.lib.makeBinPath (with pkgs; [
age
cargo
clang-tools
coreutils
curl
direnv
emacs
entr
fd
findutils
fzf
gawk
gh
git
gitui
gnugrep
gnused
gnutar
gzip
hexyl
hostname
httpie
jq
jsonnet
lazydocker
less
lf
netcat
niv
nix
nmap
openssh
ripgrep
tcpdump
tokei
tree
tshark
uv
vim
which
wrk
zellij
self.simple_emacs
self.simple_vim
]);
# NOTE: This is all a bit insane in PS1, Bash needs \[ and \]
# around non-printing chars for proper readline behavior. Here is
# a breakdown of some of the codes:
# - \e: Bash shorthand for ASCII escape (octal=\033, hex=\x1B)
# - [: Introduces a control sequence
colors = let
wrap = code: x: ''\[\e[${toString code}m\]${x}\[\e[0m\]'';
in {
red = wrap 31;
green = wrap 32;
yellow = wrap 33;
blue = wrap 34;
magenta = wrap 35;
cyan = wrap 36;
};
# NOTE: You can install this with:
# $ nix-env -f path/to/dotfiles -iA dotfiles.bashrc
# $ vim ~/.bashrc # add `source ~/nix-profile/etc/bashrc`
bashrc = pkgs.writeTextFile {
name = "bashrc";
destination = "/etc/bashrc";
text = ''
export PATH=${self.path}:$PATH
alias m='cd ~/programming/matrix'
alias base='cd ~/programming/base'
alias depot='cd ~/programming/depot'
alias dotfiles='cd ~/programming/dotfiles'
alias eb='vim ~/programming/dotfiles/default.nix'
alias sb='nix-env -f ~/programming/dotfiles -iA dotfiles.bashrc && source ~/.bashrc'
alias la='ls -al'
alias rgh='rg --hidden'
alias tpr='tput reset'
# NOTE: These only work on Linux systems running X
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias gst='git status'
alias gd='git diff'
alias gco='git checkout'
alias gcb='git checkout -b'
alias gprom='git pull --rebase origin main'
alias gfrom='git rebase -i --autosquash origin/main'
alias grbc='git rebase --continue'
alias grh='git reset --hard'
alias glp='git log --graph --oneline --decorate-refs=r/ --decorate-refs=refs/remotes/origin/'
alias gpf='git push --force'
alias gcan='git commit --amend --no-edit --no-verify'
alias gca='git commit --amend --no-verify'
alias gcf='git commit --fixup --no-verify'
alias gcp='git cherry-pick'
alias gds='git diff --staged'
alias gsh='git show HEAD'
alias gc='git commit'
alias gp='git push'
alias gpr='gh pr create --title="$(git log -1 --format=%s)" --body="$(git log -1 --format=%b)"'
alias vim='simple_vim'
alias emacs='simple_emacs'
export EDITOR=${self.simple_vim}/bin/simple_vim
export GIT_EDITOR=$EDITOR
# This only exists on machines with single-user installs
if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
source $HOME/.nix-profile/etc/profile.d/nix.sh
fi
# apps
eval "$(direnv hook bash)"
eval "$(fzf --bash)"
# export PATH="$HOME/.local/bin:$PATH" # uv
# sensitive cleartext
[ -f $HOME/secrets.sh ] && source $HOME/secrets.sh
# prompt
fmt_git_branch() {
x=$(git branch --show-current 2>/dev/null)
[ -n "$x" ] && printf "[%s]" "$x"
}
export PS1='${self.colors.red "["}${self.colors.blue "\\u"}${self.colors.yellow "@"}${self.colors.magenta "\\h"}${self.colors.red "]"} ${self.colors.cyan "\\w"} $(fmt_git_branch)\n\t ${self.colors.yellow "λ"} '
'';
};
shell = pkgs.writeShellScriptBin "billsh" ''
exec ${pkgs.bashInteractive}/bin/bash --rcfile ${self.bashrc}/etc/bashrc
'';
});
in
{
inherit pkgs dotfiles;
}