198 Commits

Author SHA1 Message Date
251dce68bb remove mitm ssl instructions 2023-02-20 20:13:52 -05:00
448c97665b move public-keys to root directory 2023-02-20 20:02:21 -05:00
86aa02aae4 rename patches directory to overlays 2023-02-20 20:00:54 -05:00
6cd22bc7ce remove bypass-paywalls-clean
no longer available from mozilla extensions
2023-02-20 17:49:19 -05:00
048de4772c rename 1password module with underscore 2023-02-20 17:49:00 -05:00
700e59e6c8 update outdated readme 2023-02-20 17:48:11 -05:00
07e0afa1e9 fix: iso generating 2023-02-20 17:32:14 -05:00
6577b9e49b initial setup for swan and staff 2023-02-18 10:24:54 -05:00
58a0e6166d allow reading windows ntfs drives 2023-02-17 18:15:23 -05:00
e8c5a10df7 attempt to set default apps for xdg-open 2023-02-17 18:14:57 -05:00
37fa835c66 update lockfile, host name updates 2023-02-12 21:26:12 -05:00
fa69557ced change hostname theme 2023-02-11 14:35:38 +00:00
a9a06fb5fc fix steam games not launching 2023-02-05 17:16:20 -05:00
ceaad9d186 update lockfile, fix age not building 2023-02-02 11:01:12 -05:00
521937e366 fix desktop for new pc build 2023-01-31 09:07:47 -05:00
8915f17ea3 fixes for latest wsl 2023-01-28 15:36:52 +00:00
17799909b2 fix: polybar not showing i3 workspaces 2023-01-21 19:46:56 -05:00
7a4c3b930d firefox working again
still polybar is broken
2023-01-21 10:44:39 -05:00
e7bbee5da0 fix desktop to work with refactor 2023-01-21 09:29:03 -05:00
2dda6a31bd update lockfile, fix treesitter for terraform filetypes 2023-01-09 13:09:12 -05:00
e4d76189e6 update lockfile 2023-01-06 15:46:59 -05:00
0bc8a233d8 enable missing neovim for macbook 2022-12-21 17:48:53 -07:00
524a5aa347 enable missing configs for oracle 2022-12-22 00:47:25 +00:00
b4ddb149cc fix: bad references for server linux 2022-12-22 00:31:25 +00:00
d021baa1bb split nixos from darwin
required because they don't share all attributes
2022-12-21 17:07:58 -07:00
7063bd5f7a fixes for module layout 2022-12-21 14:38:34 -07:00
d040077d3a convert to proper module layout 2022-12-21 14:18:03 -07:00
bf1d2f1e9e update lockfile 2022-12-20 18:23:00 -07:00
fd7c523ebd try to disable splash screen when updating firefox 2022-12-20 18:22:41 -07:00
1b32457956 fix: update dock for hammerspoon shortcuts 2022-12-20 18:22:24 -07:00
50acdd0c58 update packages 2022-12-18 22:19:56 -07:00
a0c99a8449 fix: remove print crowding the hammerspoon log 2022-12-18 17:24:58 -07:00
d1b144f441 upgrade macos to ventura 2022-12-13 21:02:42 -07:00
adb7956213 fixes for python lsp 2022-12-11 09:52:32 -07:00
e011a1c6f1 page readme app 2022-12-10 15:48:15 -07:00
1d8638777c enable rebuild app command 2022-12-10 15:48:05 -07:00
2620b43925 fix firefox colors on macos 2022-12-10 15:47:39 -07:00
7d53a80d49 add gum formatting for default app 2022-12-06 17:40:13 -07:00
9b12369e43 fixes for oracle when updating to latest 2022-12-06 17:56:29 +00:00
427bd1a421 update sources for nixos 22.11 2022-12-06 10:03:06 -07:00
74e346fa63 fix: bad command for terraform-ls 2022-11-30 10:56:30 -07:00
4a803427fb Merge branch 'k9s-color' 2022-11-30 07:39:05 -07:00
d127ccacb0 add declarative k9s color 2022-11-29 23:07:45 -07:00
54e89d3acd add neovim as nix app 2022-11-29 20:48:46 -07:00
b258a40181 working flake build of neovim 2022-11-29 20:40:15 -07:00
dfacb580ae partial setup of neovim for home config 2022-11-29 19:14:14 -07:00
650d1e91a2 only remove firefox quit shortcut on linux 2022-11-29 17:41:34 -07:00
397b08fab4 remove more unnecessary plugin flake inputs 2022-11-29 09:44:10 -07:00
33e8a6bc9b refactor vim settings 2022-11-29 09:35:39 -07:00
7a39acef1a move some lua text to separate files 2022-11-28 22:36:30 -07:00
3438446347 add nvim-tree to flake 2022-11-28 22:11:57 -07:00
dee7c7302a add gruvbox to neovim flake 2022-11-27 22:44:52 -07:00
0d052a6463 toggleterm for build 2022-11-27 22:37:47 -07:00
8b98b8f29d working completion 2022-11-27 22:31:17 -07:00
96c64c4da1 add lsp to neovim flake 2022-11-27 19:11:41 -07:00
47a1823af4 more working plugins 2022-11-27 17:21:18 -07:00
d86534727e start of a WIP rebuild app 2022-11-27 13:10:22 -07:00
13e5b9ddc5 brewfile syntax no longer needed 2022-11-27 13:10:01 -07:00
bb200016cb note about necessary plugins 2022-11-27 13:09:34 -07:00
dc00ef26b5 some working stuff 2022-11-27 13:08:33 -07:00
cf62184744 first neovim build package 2022-11-27 12:29:45 -07:00
97ed5eb33b switch from homebrew to firefox overlay for macos 2022-11-23 15:46:30 -07:00
d672a77ddb fix alt-e in fish for kitty 2022-11-23 14:37:57 -07:00
52f9057ee5 unused n8n setup 2022-11-21 01:04:38 +00:00
7ddd9d9aa4 add discord to macos dock 2022-11-20 12:12:18 -07:00
b9ddaf095c replace alacritty with kitty in macos dock 2022-11-20 12:09:03 -07:00
f304392d58 fix: victormono italic glitch on macos 2022-11-20 11:55:11 -07:00
3beacf9f3c adjust k9s toggleterm keybind 2022-11-20 11:52:33 -07:00
44c4084b57 fix: tfvars recognized as terraform 2022-11-20 11:51:46 -07:00
42237eab13 fix: aerc doesn't recognize config file 2022-11-20 11:38:10 -07:00
2848ae9424 switch kitty to victormono font 2022-11-19 19:40:04 -07:00
a6f9b985fc Revert "force neovim fish shell in toggleterm"
This reverts commit d1f12671b0.
2022-11-19 19:12:04 -07:00
d1f12671b0 force neovim fish shell in toggleterm 2022-11-19 19:12:01 -07:00
30f9f869a7 force fish shell for kitty 2022-11-19 19:11:26 -07:00
e1fc3317b5 adjust aws package layout 2022-11-18 22:35:00 -05:00
07b5f855a6 disable firefox autofill 2022-11-16 15:52:24 -05:00
5178c9f458 fix colorscheme for macbook 2022-11-16 15:52:00 -05:00
2ab37d3298 move noisetorch to linux audio 2022-11-14 10:35:36 -05:00
0176b14350 move qr to nautilusg 2022-11-14 10:35:16 -05:00
8342746b69 fix wsl with new theme 2022-11-10 04:26:38 +00:00
2340b862e5 add noisetorch for mic noise suppression 2022-11-07 20:54:01 -05:00
b04c442c87 replace rnix lsp with nil 2022-11-07 08:04:29 -05:00
5bbba2be39 set back to dark mode default 2022-11-05 19:38:43 -04:00
c871f59791 fixes for light mode 2022-11-05 13:41:09 -04:00
4ea56b0aab fix: remove bell sounds from kitty 2022-11-03 21:20:29 -04:00
7ae0649456 nixpkgs shortcut registries 2022-11-03 11:26:31 -04:00
660ea997df fix standalone home-manager on macos 2022-11-03 11:25:58 -04:00
15f4116178 fixes for kitty on macos 2022-11-03 11:25:36 -04:00
9386008fa2 fix: identity file wrong path on macos 2022-11-03 11:24:03 -04:00
920ec8b43e add terminfo to openssh devices 2022-11-03 08:51:51 -04:00
6241b8e624 fix neovim tree-sitter bug
requires installing tree-sitter and nodejs to environment :(
2022-11-03 08:30:28 -04:00
7741394306 add back removed applications 2022-11-02 22:15:29 -04:00
07fec71ba4 put hashed pass in a separate file 2022-11-02 21:47:11 -04:00
41d289c5db refactor colors and options
preparing for light mode, even though specializations aren't working
2022-11-02 21:29:14 -04:00
b2850e8b79 improve visuals of volume notification 2022-10-31 23:54:29 -04:00
afd44279d2 tweaks to aerc, replace delete with move to trash 2022-10-31 23:43:14 -04:00
d73ccab008 replace pulseaudio with pipewire
closes #8
2022-10-31 23:40:53 -04:00
969e89cda3 set kitty to default in i3 2022-10-31 20:47:42 -04:00
38695b29bd use shift+enter for completion in terminal 2022-10-31 20:47:33 -04:00
40424a0102 temp: disable visidata bc of python errors 2022-10-31 14:46:04 -04:00
d7b711ff02 replace alacritty with kitty on macos 2022-10-31 14:45:51 -04:00
7bd2125438 fix: actually use exa for ls 2022-10-30 20:43:49 -04:00
0448037a6b set kitty tab style to slant 2022-10-30 20:43:34 -04:00
7075371b11 remove warning about dirty git tree 2022-10-30 20:42:32 -04:00
22885f1b27 temp: try to show users in lightdm greeter
still isn't working unfortunately
2022-10-30 20:16:37 -04:00
52edaa7d9c prevent ctrl-q from quitting firefox
will this affect macos?
2022-10-30 20:16:01 -04:00
c74d003a57 change alacritty scrollback keybind to match kitty
add fonts for kitty
2022-10-30 20:15:32 -04:00
2d10939285 clean up flake inputs and allow standalone home-manager
closes #11
2022-10-30 20:14:41 -04:00
b15cd8c0b6 add basic kitty config
closes #7
2022-10-30 20:13:32 -04:00
dfd903d3c9 add aerc and fix nvim 0.8 2022-10-30 13:57:14 -04:00
2af30faf7c update system and fix nvim 2022-10-29 14:42:37 -04:00
b718a01dc4 i think i fixed picom screen tearing 2022-10-29 08:57:14 -04:00
e16674c817 tweaks for i3 and common 2022-10-28 23:58:33 -04:00
bf09e166a9 fix: grub wrong monitor 2022-10-28 23:58:25 -04:00
3dcafb8c25 package ocr script with dependencies 2022-10-25 20:22:17 -04:00
be581dba1f fix: jellyfin dir permissions for nextcloud 2022-10-23 04:16:42 +00:00
941fa359d9 add windows app plaintext list 2022-10-22 15:10:30 +00:00
f6096e3472 replace vimwiki with mkdnflow 2022-10-22 14:29:50 +00:00
cd204f5ac3 move apps declaration to apps directory 2022-10-18 12:31:42 +00:00
4c685eb8dd ignore non-age files in private dir 2022-10-18 12:25:06 +00:00
2694e3288c move generators to hosts directory 2022-10-18 12:21:22 +00:00
af31c65788 fix: generator module references 2022-10-18 12:17:58 +00:00
ef6c920c48 move calibre-web patch to patches directory
still requires overlay because there is no package option
2022-10-18 03:19:23 +00:00
d97e3fda07 gitea litestream permissions fixes 2022-10-16 20:39:04 +00:00
982566a92e add gitea service 2022-10-16 20:34:28 +00:00
27e2a42e46 fix: typo in copy 2022-10-16 20:21:25 +00:00
41d8e30990 vaultwarden automated backups 2022-10-16 19:06:56 +00:00
6f67e31723 working vaultwarden
haven't tested websockets
2022-10-16 18:10:11 +00:00
7bca2775d1 don't start stop-minecraft timer on rebuild 2022-10-16 14:44:42 +00:00
89a95445e1 remove age and loadkey module 2022-10-16 14:25:47 +00:00
084e832039 wsl fixes 2022-10-16 14:21:38 +00:00
e1e27ca065 backup calibre data 2022-10-16 03:47:21 +00:00
6e26b64f43 backups requires secrets 2022-10-16 03:19:41 +00:00
0f112ea16b reencrypt secrets and fix nextcloud backups 2022-10-16 03:18:58 +00:00
69a54b99c8 new secrets management system 2022-10-16 01:32:39 +00:00
e2c351098b move cloudflare to separate file 2022-10-15 19:00:37 +00:00
5410afb45b switch to /var/lib for calibre-web 2022-10-15 15:29:21 +00:00
bc83c818db honeypot for banning port scanners 2022-10-15 12:16:05 +00:00
8cce61f4a8 change metrics server hostname 2022-10-14 13:08:13 +00:00
595eac9367 switch from netdata to grafana 2022-10-14 04:01:41 +00:00
a17a048d9d set credentials oneshots to stop after launch 2022-10-14 01:35:14 +00:00
c2d0037bab autostart and stop minecraft server 2022-10-14 01:34:35 +00:00
e2af159c26 lockdown caddy and ssh connections 2022-10-13 23:40:30 +00:00
01e71e5810 add minecraft server 2022-10-10 23:09:32 +00:00
c4c75cd587 switch to netdata cloud
fix performance issues with caddy mostly
2022-10-10 19:22:39 +00:00
a5e186ee87 netdata metrics with basic auth
seems to have performance problems with caddy
2022-10-10 18:11:08 +00:00
170f8c67de enable transmission web allowlist 2022-10-10 03:25:28 +00:00
b0aa82e7d0 refactor wireguard and add port forwarding 2022-10-10 03:13:16 +00:00
7aacfe7887 fix issues reaching transmission web 2022-10-09 20:41:04 +00:00
d8b5d74dcb transmission reaches internet through vpn 2022-10-09 18:32:43 +00:00
129e4bba4b wireguard working but not transmission 2022-10-09 14:12:31 +00:00
e309889b0b replace activationscripts with systemd 2022-10-09 03:51:25 +00:00
5872abcc33 move calibre perms out of activations 2022-10-08 15:57:52 +00:00
bfa9e8fc4e remember to require age for mail 2022-10-08 15:52:43 +00:00
8dba2ef88b litestream backups for nextcloud 2022-10-08 15:52:19 +00:00
e89db82e7f make whois core utility 2022-10-07 03:31:14 +00:00
4044721606 add vaultwarden, not activated 2022-10-07 00:44:06 +00:00
0637cc693b fix: patch calibre-web cloudflare login issues 2022-10-05 03:59:13 +00:00
a9ae0c8858 add activationscript for jellyfin directory 2022-10-04 22:59:28 +00:00
da01f3be9b add cloudflare IPs as nextcloud trusted proxies 2022-10-04 22:43:04 +00:00
a7117fe4e9 fix: max upload size for nextcloud 2022-10-04 12:29:29 +00:00
c2b570b2af don't use s3 as primary nextcloud storage 2022-10-04 03:06:55 +00:00
84ecbf9974 grant nextcloud access to jellyfin 2022-10-04 00:45:05 +00:00
f38f782b63 add helper statements for loadkeys app 2022-10-03 12:32:09 +00:00
31f3cfe77c fix firewall issues with oracle 2022-10-03 12:19:29 +00:00
a0089e28ae move mailpass to private section 2022-10-03 12:12:50 +00:00
92223a49cd separate age ssh key setup from nextcloud 2022-10-03 04:05:07 +00:00
2434376963 working nextcloud configuration 2022-10-02 20:54:26 +00:00
f196f546b8 add jellyfin, switch caddy to one listener 2022-10-02 17:40:10 +00:00
b4ba0706c0 move caddy config into separate file 2022-10-02 15:24:25 +00:00
90bc2ecd49 add iptables settings for oracle reboot 2022-10-02 15:09:54 +00:00
19de583433 setup caddy and calibre-web 2022-10-02 14:48:51 +00:00
8a97d9b2da calibre needs to use path it can read 2022-10-02 02:47:10 +00:00
015c393274 docs: deprecated nixFlakes package 2022-10-01 21:42:33 +00:00
db0645075f setup calibre server 2022-10-01 21:39:36 +00:00
034ff33e70 add more description for mkpasswd salt 2022-10-01 18:28:32 +00:00
cd53060f02 switch to ssh for dotfiles repo 2022-10-01 18:28:03 +00:00
f20b4ee31a add ssh host to starship 2022-10-01 18:24:06 +00:00
381e06519b add oracle hardware config 2022-10-01 16:29:16 +00:00
3ec1ef4394 add server bootloader 2022-10-01 16:24:44 +00:00
d303924f02 try adding oracle server config 2022-10-01 16:21:34 +00:00
485e8223cf Merge branch 'aws-nix-build' 2022-10-01 15:26:01 +00:00
657bec0929 browse active directory on macos 2022-09-30 11:09:58 -04:00
4e23d677e8 auto-formatting changes 2022-09-30 10:11:55 -04:00
5ce4ebf522 fix: hostname for macos 2022-09-28 15:33:49 -04:00
e6b7938218 update lockfile and fix some darwin configs 2022-09-27 21:30:27 -04:00
1addb7ec21 manage touchid sudo with nix-darwin 2022-09-25 14:47:04 +00:00
ba14638a8a navigate git hunks in neovim 2022-09-25 14:46:50 +00:00
ddd517e0dd update installer with gum, add more charm stuff 2022-09-25 04:19:46 +00:00
0ac3aec208 dynamic rebuild-nixos based on current hostname 2022-09-24 16:53:16 +00:00
ae90b1041d add charm packages, fix neovim tree height 2022-09-24 14:26:02 +00:00
9b0dcaba9f docs: update wsl instructions for fonts and term 2022-09-24 01:55:11 +00:00
0bf5fd5862 update docs for non-nix users 2022-09-23 14:35:14 -04:00
7a9f7dd760 add more general utilities 2022-09-21 16:58:04 -04:00
f834cc20f4 aws generator gh workflow and terraform upload 2022-09-21 03:49:04 +00:00
720a3cc409 additional options needed to build aws image 2022-09-20 12:50:04 +00:00
9e3345ff9b add sshd for aws generators 2022-09-20 11:50:45 +00:00
50a538c78e start generator work 2022-09-20 04:01:45 +00:00
209 changed files with 5644 additions and 1842 deletions

3
.gitignore vendored
View File

@ -4,3 +4,6 @@
**/.direnv/**
result
.luarc.json
private/**
!private/**.age
!private/**.sha512

View File

@ -1,6 +1,33 @@
This repository contains configuration files for my NixOS, macOS, and WSL
hosts.
They are organized and managed by [Nix](https://nixos.org), so some of the
configuration may be difficult to translate to a non-Nix system.
However, some of the configurations are easier to lift directly:
- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/config)
- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/shell/fish/functions)
- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/fish/default.nix)
- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix)
- [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon)
Try out my Neovim config:
```bash
nix run github:nmasur/dotfiles#neovim
```
Or build it as a package:
```bash
nix build github:nmasur/dotfiles#neovim
```
If you already have a Neovim configuration, you may need to move it out of
`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise, both
configs might conflict with each other.
---
# Installation
@ -14,7 +41,7 @@ installer disk:
```bash
lsblk # Choose the disk you want to wipe
nix-shell -p nixFlakes
nix-shell -p nixVersions.stable
nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop
```
@ -24,8 +51,8 @@ If you're already running NixOS, you can switch to this configuration with the
following command:
```bash
nix-shell -p nixFlakes
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop
nix-shell -p nixVersions.stable
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest
```
## Windows - From NixOS WSL
@ -35,10 +62,16 @@ WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to
the WSL configuration:
```
nix-shell -p nixFlakes
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl
nix-shell -p nixVersions.stable
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#flame
```
You should also download the
[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip)
font and install it on Windows. Install [Alacritty](https://alacritty.org/) and
move the `windows/alacritty.yml` file to
`C:\Users\<user>\AppData\Roaming\alacritty`.
## macOS
To get started on a bare macOS installation, first install Nix:
@ -57,25 +90,9 @@ nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
Then switch to the macOS configuration:
```bash
darwin-rebuild switch --flake github:nmasur/dotfiles#macbook
darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass
```
### Dealing with corporate MITM SSL certificates:
```bash
# Get the certificates
openssl s_client -showcerts -verify 5 -connect cache.nixos.org:443 < /dev/null
# Paste them in here
sudo nvim $NIX_SSL_CERT_FILE
```
### Dealing with Neovim issues:
Update Neovim Packer plugins: `:PackerSync`
Update TreeSitter languages: `:TSUpdateSync`
---
# Flake Templates

70
apps/default.nix Normal file
View File

@ -0,0 +1,70 @@
{ pkgs, ... }: rec {
default = {
type = "app";
program = builtins.toString (pkgs.writeShellScript "default" ''
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
echo ""
echo ""
${pkgs.gum}/bin/gum format --type=template -- \
' {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
' {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
' {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
' {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
' {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
' {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
' {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \
' {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}'
echo ""
echo ""
'');
};
# Format and install from nothing
installer = import ./installer.nix { inherit pkgs; };
# Display the readme for this repository
readme = import ./readme.nix { inherit pkgs; };
# Rebuild
rebuild = {
type = "app";
program = builtins.toString (pkgs.writeShellScript "rebuild" ''
echo ${pkgs.system}
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
if [ "$SYSTEM" == "darwin" ]; then
darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass
else
nixos-rebuild switch --flake github:nmasur/dotfiles
fi
'');
};
# Load the SSH key for this machine
loadkey = import ./loadkey.nix { inherit pkgs; };
# Encrypt secret for all machines
encrypt-secret = import ./encrypt-secret.nix { inherit pkgs; };
# Re-encrypt secrets for all machines
reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; };
# Connect machine metrics to Netdata Cloud
netdata = import ./netdata-cloud.nix { inherit pkgs; };
# Run neovim as an app
neovim = {
type = "app";
program = "${
(import ../modules/neovim/package {
inherit pkgs;
colors =
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
})
}/bin/nvim";
};
nvim = neovim;
}

19
apps/encrypt-secret.nix Normal file
View File

@ -0,0 +1,19 @@
{ pkgs, ... }: {
# nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age
type = "app";
program = builtins.toString (pkgs.writeShellScript "encrypt-secret" ''
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
read -p "Secret: " secret
printf "\nEncrypting...\n\n" 1>&2
tmpfile=$(mktemp)
echo "''${secret}" > ''${tmpfile}
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
builtins.toString ../public-keys
} $tmpfile
rm $tmpfile
'');
}

View File

@ -13,10 +13,12 @@
PARTITION_PREFIX=""
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
echo "Missing required parameter."
echo "Usage: installer -- <disk> <host>"
echo "Example: installer -- nvme0n1 desktop"
echo "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
--foreground "#fb4934" \
"Missing required parameter." \
"Usage: installer -- <disk> <host>" \
"Example: installer -- nvme0n1 desktop" \
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
echo "(exiting)"
exit 1
fi
@ -25,10 +27,14 @@
PARTITION_PREFIX="p"
esac
parted /dev/''${DISK} -- mklabel gpt
parted /dev/''${DISK} -- mkpart primary 512MiB 100%
parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
parted /dev/''${DISK} -- set 3 esp on
${pkgs.gum}/bin/gum confirm \
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \
--default=false
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
@ -36,7 +42,7 @@
mkdir --parents /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
'');
}

12
apps/loadkey.nix Normal file
View File

@ -0,0 +1,12 @@
{ pkgs, ... }: {
type = "app";
program = builtins.toString (pkgs.writeShellScript "loadkey" ''
printf "\nEnter the seed phrase for your SSH key...\n"
printf "\nThen press ^D when complete.\n\n"
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
printf "\n\nContinuing activation.\n\n"
'');
}

19
apps/netdata-cloud.nix Normal file
View File

@ -0,0 +1,19 @@
{ pkgs, ... }: {
type = "app";
program = builtins.toString (pkgs.writeShellScript "netdata-cloud" ''
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
mkdir --parents --mode 0750 /var/lib/netdata/cloud.d
printf "\nEnter the claim token for netdata cloud...\n\n"
read -p "Token: " token
echo "''${token}" > /var/lib/netdata/cloud.d/token
chown -R netdata:netdata /var/lib/netdata
${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen)
printf "\n\nNow restart netdata service.\n\n"
'');
}

View File

@ -3,7 +3,7 @@
type = "app";
program = builtins.toString (pkgs.writeShellScript "readme" ''
${pkgs.glow}/bin/glow ${builtins.toString ../README.md}
${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md}
'');
}

View File

@ -0,0 +1,27 @@
{ pkgs, ... }: {
# nix run github:nmasur/dotfiles#reencrypt-secrets ./private
type = "app";
program = builtins.toString (pkgs.writeShellScript "reencrypt-secrets" ''
if [ $# -eq 0 ]; then
echo "Must provide directory to reencrypt."
exit 1
fi
encrypted=$1
for encryptedfile in ''${1}/*; do
tmpfile=$(mktemp)
echo "Decrypting ''${encryptedfile}..."
${pkgs.age}/bin/age --decrypt \
--identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile
echo "Encrypting ''${encryptedfile}..."
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
builtins.toString ../public-keys
} $tmpfile > $encryptedfile
rm $tmpfile
done
echo "Finished."
'');
}

View File

@ -0,0 +1,45 @@
{
name = "gruvbox"; # Dark, Medium
author =
"Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
dark = {
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim-gruvbox.nix;
batTheme = "gruvbox-dark";
};
light = {
base00 = "#fbf1c7"; # ----
base01 = "#ebdbb2"; # ---
base02 = "#d5c4a1"; # --
base03 = "#bdae93"; # -
base04 = "#665c54"; # +
base05 = "#504945"; # ++
base06 = "#3c3836"; # +++
base07 = "#282828"; # ++++
base08 = "#9d0006"; # red
base09 = "#af3a03"; # orange
base0A = "#b57614"; # yellow
base0B = "#79740e"; # green
base0C = "#427b58"; # aqua/cyan
base0D = "#076678"; # blue
base0E = "#8f3f71"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim-gruvbox.nix;
batTheme = "gruvbox-light";
};
}

View File

@ -0,0 +1,12 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.vim-gruvbox8 ];
vim.g.gruvbox_italicize_strings = 0;
vim.o.background = "dark";
vimscript = ''
let g:gruvbox_italicize_strings = 0
colorscheme gruvbox8
'';
}

View File

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: {
# MacOS-specific settings for Alacritty
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.alacritty.settings = {
font.size = lib.mkForce 20.0;
shell.program = "${pkgs.fish}/bin/fish";

View File

@ -5,8 +5,9 @@
./fonts.nix
./hammerspoon.nix
./homebrew.nix
./kitty.nix
./networking.nix
./nixpkgs.nix
./ssl.nix
./system.nix
./tmux.nix
./user.nix

17
darwin/fonts.nix Normal file
View File

@ -0,0 +1,17 @@
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs;
[ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ];
programs.alacritty.settings = { font.normal.family = "VictorMono"; };
programs.kitty.font = {
package = (pkgs.nerdfonts.override { fonts = [ "VictorMono" ]; });
name = "VictorMono Nerd Font Mono";
};
};
}

32
darwin/hammerspoon.nix Normal file
View File

@ -0,0 +1,32 @@
{ config, pkgs, lib, ... }: {
# Hammerspoon - MacOS custom automation scripting
config = lib.mkIf pkgs.stdenv.isDarwin {
home-manager.users.${config.user} = {
xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua;
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source =
./hammerspoon/Spoons/ControlEscape.spoon;
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source =
./hammerspoon/Spoons/DismissAlerts.spoon;
xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source =
pkgs.substituteAll {
src = ./hammerspoon/Spoons/Launcher.spoon/init.lua;
firefox = "${pkgs.firefox-bin}/Applications/Firefox.app";
discord = "${pkgs.discord}/Applications/Discord.app";
kitty = "${pkgs.kitty}/Applications/kitty.app";
};
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source =
./hammerspoon/Spoons/MoveWindow.spoon;
};
homebrew.casks = [ "hammerspoon" ];
system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
'';
};
}

View File

@ -69,7 +69,7 @@ function obj:init()
-- If any other key is pressed, don't send escape
self.asModifier = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(_)
self.sendEscape = false
print("Don't sent escape")
-- print("Don't sent escape")
end)
-- If mouse is moving significantly, don't send escape

View File

@ -56,13 +56,13 @@ function obj:init()
-- Launcher shortcuts
self.launcher:bind("ctrl", "space", function() end)
self.launcher:bind("", "return", function()
self:switch("Alacritty.app")
self:switch("@kitty@")
end)
self.launcher:bind("", "C", function()
self:switch("Calendar.app")
end)
self.launcher:bind("", "D", function()
self:switch("Discord.app")
self:switch("@discord@")
end)
self.launcher:bind("", "E", function()
self:switch("Mail.app")
@ -71,7 +71,7 @@ function obj:init()
self:switch("Music.app")
end)
self.launcher:bind("", "F", function()
self:switch("Firefox.app")
self:switch("@firefox@")
end)
self.launcher:bind("", "H", function()
self:switch("Hammerspoon.app")

View File

@ -9,24 +9,25 @@ WORK_RIGHT_MONITOR = "DELL U2415 (1)"
LAPTOP_MONITOR = "Built-in Retina Display"
-- Used to find out the name of the monitor in Hammerspoon
function dump(o)
if type(o) == "table" then
local s = "{ "
for k, v in pairs(o) do
if type(k) ~= "number" then
k = '"' .. k .. '"'
end
s = s .. "[" .. k .. "] = " .. dump(v) .. ","
end
return s .. "} "
else
return tostring(o)
end
end
-- local function dump(o)
-- if type(o) == "table" then
-- local s = "{ "
-- for k, v in pairs(o) do
-- if type(k) ~= "number" then
-- k = '"' .. k .. '"'
-- end
-- s = s .. "[" .. k .. "] = " .. dump(v) .. ","
-- end
-- return s .. "} "
-- else
-- return tostring(o)
-- end
-- end
-- Turn on when looking for the monitor name
-- print(dump(hs.screen.allScreens()))
function concat(...)
local function concat(...)
local res = {}
for _, tab in ipairs({ ... }) do
for _, elem in ipairs(tab) do
@ -36,12 +37,12 @@ function concat(...)
return res
end
function worklayout()
local function worklayout()
hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "l", function()
local u = hs.geometry.unitrect
-- set the layout
local left = {
-- { "Alacritty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true },
{ "kitty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true },
}
local right = {
{ "Slack", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true },

56
darwin/homebrew.nix Normal file
View File

@ -0,0 +1,56 @@
{ config, pkgs, lib, ... }: {
# Homebrew - Mac-specific packages that aren't in Nix
config = lib.mkIf pkgs.stdenv.isDarwin {
# Requires Homebrew to be installed
system.activationScripts.preUserActivation.text = ''
if ! xcode-select --version 2>/dev/null; then
$DRY_RUN_CMD xcode-select --install
fi
if ! /usr/local/bin/brew --version 2>/dev/null; then
$DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
'';
homebrew = {
enable = true;
onActivation = {
autoUpdate = false; # Don't update during rebuild
cleanup = "zap"; # Uninstall all programs not declared
upgrade = true;
};
global = {
brewfile = true; # Run brew bundle from anywhere
lockfiles = false; # Don't save lockfile (since running from anywhere)
};
taps = [
"homebrew/cask" # Required for casks
"homebrew/cask-drivers" # Used for Logitech G-Hub
];
brews = [
"trash" # Delete files and folders to trash instead of rm
"openjdk" # Required by Apache Directory Studio
];
casks = [
"1password" # 1Password packaging on Nix is broken for macOS
"scroll-reverser" # Different scroll style for mouse vs. trackpad
"meetingbar" # Show meetings in menu bar
"gitify" # Git notifications in menu bar
"logitech-g-hub" # Mouse and keyboard management
"mimestream" # Gmail client
"obsidian" # Obsidian packaging on Nix is not available for macOS
"steam" # Not packaged for Nix
"apache-directory-studio" # Packaging on Nix is not available for macOS
];
};
home-manager.users.${config.user} = {
programs.fish.shellAbbrs.t = "trash";
};
};
}

18
darwin/kitty.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, lib, ... }: {
# MacOS-specific settings for Kitty
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.kitty = {
darwinLaunchOptions = [ "--start-as=fullscreen" ];
font.size = lib.mkForce 20;
settings = {
shell = "/run/current-system/sw/bin/fish";
macos_traditional_fullscreen = true;
macos_quit_when_last_window_closed = true;
disable_ligatures = "always";
macos_option_as_alt = true;
};
};
};
}

11
darwin/networking.nix Normal file
View File

@ -0,0 +1,11 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
networking = {
computerName = "${config.fullName}'\\''s Mac";
# Adjust if necessary
# hostName = "";
};
};
}

View File

@ -1,6 +1,6 @@
{ config, lib, ... }: {
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.fish = {
shellAbbrs = {
@ -14,7 +14,14 @@
set option "--option substitute false"
end
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#macbook"
commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#lookingglass"
commandline --function execute
'';
};
rebuild-home = lib.mkForce {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#lookingglass";
commandline --function execute
'';
};

186
darwin/system.nix Normal file
View File

@ -0,0 +1,186 @@
{ pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
services.nix-daemon.enable = true;
environment.shells = [ pkgs.fish ];
security.pam.enableSudoTouchIdAuth = true;
system = {
keyboard = {
remapCapsLockToControl = true;
enableKeyMapping = true; # Allows for skhd
};
defaults = {
NSGlobalDomain = {
# Set to dark mode
AppleInterfaceStyle = "Dark";
# Don't change from dark to light automatically
# AppleInterfaceSwitchesAutomatically = false;
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
AppleKeyboardUIMode = 3;
# Automatically show and hide the menu bar
_HIHideMenuBar = true;
# Expand save panel by default
NSNavPanelExpandedStateForSaveMode = true;
# Expand print panel by default
PMPrintingExpandedStateForPrint = true;
# Replace press-and-hold with key repeat
ApplePressAndHoldEnabled = false;
# Set a fast key repeat rate
KeyRepeat = 2;
# Shorten delay before key repeat begins
InitialKeyRepeat = 12;
# Save to local disk by default, not iCloud
NSDocumentSaveNewDocumentsToCloud = false;
# Disable autocorrect capitalization
NSAutomaticCapitalizationEnabled = false;
# Disable autocorrect smart dashes
NSAutomaticDashSubstitutionEnabled = false;
# Disable autocorrect adding periods
NSAutomaticPeriodSubstitutionEnabled = false;
# Disable autocorrect smart quotation marks
NSAutomaticQuoteSubstitutionEnabled = false;
# Disable autocorrect spellcheck
NSAutomaticSpellingCorrectionEnabled = false;
};
dock = {
# Automatically show and hide the dock
autohide = true;
# Add translucency in dock for hidden applications
showhidden = true;
# Enable spring loading on all dock items
enable-spring-load-actions-on-all-items = true;
# Highlight hover effect in dock stack grid view
mouse-over-hilite-stack = true;
mineffect = "genie";
orientation = "bottom";
show-recents = false;
tilesize = 44;
};
finder = {
# Default Finder window set to column view
FXPreferredViewStyle = "clmv";
# Finder search in current folder by default
FXDefaultSearchScope = "SCcf";
# Disable warning when changing file extension
FXEnableExtensionChangeWarning = false;
# Allow quitting of Finder application
QuitMenuItem = true;
};
# Disable "Are you sure you want to open" dialog
LaunchServices.LSQuarantine = false;
# Disable trackpad tap to click
trackpad.Clicking = false;
# universalaccess = {
# # Zoom in with Control + Scroll Wheel
# closeViewScrollWheelToggle = true;
# closeViewZoomFollowsFocus = true;
# };
# Where to save screenshots
screencapture.location = "~/Downloads";
};
# Settings that don't have an option in nix-darwin
activationScripts.postActivation.text = ''
echo "Disable disk image verification"
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
echo "Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disable the warning before emptying the Trash"
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Allow apps from anywhere"
SPCTL=$(spctl --status)
if ! [ "$SPCTL" = "assessments disabled" ]; then
sudo spctl --master-disable
fi
'';
# User-level settings
activationScripts.postUserActivation.text = ''
echo "Show the ~/Library folder"
chflags nohidden ~/Library
echo "Enable dock magnification"
defaults write com.apple.dock magnification -bool true
echo "Set dock magnification size"
defaults write com.apple.dock largesize -int 48
echo "Define dock icon function"
__dock_item() {
printf "%s%s%s%s%s" \
"<dict><key>tile-data</key><dict><key>file-data</key><dict>" \
"<key>_CFURLString</key><string>" \
"$1" \
"</string><key>_CFURLStringType</key><integer>0</integer>" \
"</dict></dict></dict>"
}
echo "Choose and order dock icons"
defaults write com.apple.dock persistent-apps -array \
"$(__dock_item /Applications/1Password.app)" \
"$(__dock_item /Applications/Slack.app)" \
"$(__dock_item /System/Applications/Calendar.app)" \
"$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \
"$(__dock_item /System/Applications/Messages.app)" \
"$(__dock_item /System/Applications/Mail.app)" \
"$(__dock_item /Applications/Mimestream.app)" \
"$(__dock_item /Applications/zoom.us.app)" \
"$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \
"$(__dock_item /Applications/Obsidian.app)" \
"$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \
"$(__dock_item /System/Applications/System\ Settings.app)"
'';
};
};
}

View File

@ -1,6 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer";
config.home-manager.users.${config.user} = lib.mkIf config.tmux.enable {
programs.tmux = {
enable = true;

21
darwin/user.nix Normal file
View File

@ -0,0 +1,21 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
users.users."${config.user}" = {
# macOS user
home = config.homePath;
shell = pkgs.fish; # Default shell
};
# Used for aerc
home-manager.users.${config.user} = {
home.sessionVariables = {
XDG_CONFIG_HOME = "${config.homePath}/.config";
};
};
};
}

53
darwin/utilities.nix Normal file
View File

@ -0,0 +1,53 @@
{ config, pkgs, lib, ... }:
let
# Quickly package shell scripts with their dependencies
# From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6
mkScript = { name, file, env ? [ ] }:
pkgs.writeScriptBin name ''
for i in ${lib.concatStringsSep " " env}; do
export PATH="$i/bin:$PATH"
done
exec ${pkgs.bash}/bin/bash ${file} $@
'';
in {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs; [
# visidata # CSV inspector
dos2unix # Convert Windows text files
inetutils # Includes telnet
youtube-dl # Convert web videos
pandoc # Convert text documents
mpd # TUI slideshows
awscli2
awslogs
google-cloud-sdk
ansible
vault
consul
noti # Create notifications programmatically
ipcalc # Make IP network calculations
(mkScript {
name = "ocr";
file = ../modules/shell/bash/scripts/ocr.sh;
env = [ tesseract ];
})
];
programs.fish.shellAbbrs = {
# Add noti for ghpr in Darwin
ghpr = lib.mkForce "gh pr create && sleep 3 && noti gh run watch";
grw = lib.mkForce "noti gh run watch";
# Shortcut to edit hosts file
hosts = "sudo nvim /etc/hosts";
};
};
}

419
flake.lock generated
View File

@ -1,5 +1,53 @@
{
"nodes": {
"Comment-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1674040818,
"narHash": "sha256-7UtZAE9tPlnpeHS2LLol/LGVOxptDXNKWXHNHvFBNk4=",
"owner": "numToStr",
"repo": "Comment.nvim",
"rev": "eab2c83a0207369900e92783f56990808082eac2",
"type": "github"
},
"original": {
"owner": "numToStr",
"repo": "Comment.nvim",
"type": "github"
}
},
"bufferline-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1676130961,
"narHash": "sha256-3LT45i0eSMfUV9EBrtdtzHxFKRATIhRy/faDd3lI3mA=",
"owner": "akinsho",
"repo": "bufferline.nvim",
"rev": "84b0822b2af478d0b4f7b0f9249ca218855331db",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "bufferline.nvim",
"type": "github"
}
},
"cmp-nvim-lsp-src": {
"flake": false,
"locked": {
"lastModified": 1675708067,
"narHash": "sha256-DxpcPTBlvVP88PDoTheLV2fC76EXDqS2UpM5mAfj/D4=",
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "0e6b2ed705ddcff9738ec4ea838141654f12eeef",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
@ -7,11 +55,11 @@
]
},
"locked": {
"lastModified": 1662478528,
"narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=",
"lastModified": 1673295039,
"narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a",
"rev": "87b9d090ad39b25b2400029c64825fc2a8868943",
"type": "github"
},
"original": {
@ -21,14 +69,32 @@
"type": "github"
}
},
"firefox-darwin": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1675471726,
"narHash": "sha256-526iHwidfdtZZ7aAU9od1/zbyfSFBEailBTet+Gvfqg=",
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"rev": "813d55a3e3b3c0423eb5d1fcb4bf82197c9f7796",
"type": "github"
},
"original": {
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
@ -38,6 +104,21 @@
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
@ -52,6 +133,21 @@
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -60,11 +156,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1663328500,
"narHash": "sha256-7n+J/exp8ky4dmk02y5a9R7CGmJvHpzrHMzfEkMtSWA=",
"lastModified": 1675935446,
"narHash": "sha256-WajulTn7QdwC7QuXRBavrANuIXE5z+08EdxdRw1qsNs=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "5427f3d1f0ea4357cd4af0bffee7248d640c6ffc",
"rev": "2dce7f1a55e785a22d61668516df62899278c9e4",
"type": "github"
},
"original": {
@ -74,13 +170,122 @@
"type": "github"
}
},
"nil": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1676110678,
"narHash": "sha256-hemg8rMKS2me2Wua9ZG/0aQ8fEOfytjyKB+WYcXfEKE=",
"owner": "oxalica",
"repo": "nil",
"rev": "ce2e0b5d60fe497134050796f7d12ffb6b50eb28",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "nil",
"type": "github"
}
},
"nix2vim": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1673891598,
"narHash": "sha256-EevceKxQtA+I0XVA8tBGKmYV1V1KbWc3gsswysMzeDk=",
"owner": "gytis-ivaskevicius",
"repo": "nix2vim",
"rev": "5b31eb81e2c6c74f9e8a4911660f3bf585d55158",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "nix2vim",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1636849918,
"narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1674666581,
"narHash": "sha256-KNI2s/xrL7WOYaPJAWKBtb7cCH3335rLfsL+B+ssuGY=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "6a5dc1d3d557ea7b5c19b15ff91955124d0400fa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1663357389,
"narHash": "sha256-oYA2nVRSi6yhCBqS5Vz465Hw+3BQOVFEhfbfy//3vTs=",
"lastModified": 1639237670,
"narHash": "sha256-RTdL4rEQcgaZGpvtDgkp3oK/V+1LM3I53n0ACPSroAQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "edfb969386ebe6c3cf8f878775a7975cd88f926d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1675309347,
"narHash": "sha256-D3CQ6HRDT2m3XJlrzb5jKq4vNFR5xFTEFKC7iSjlFpM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "da6a05816e7fa5226c3f61e285ef8d9dfc868f3c",
"rev": "006c3bd4dd2f5d1d2094047f307cbf9e2b73d9c5",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1676110339,
"narHash": "sha256-kOS/L8OOL2odpCOM11IevfHxcUeE0vnZUQ74EOiwXcs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e5530aba13caff5a4f41713f1265b754dc2abfd8",
"type": "github"
},
"original": {
@ -90,28 +295,45 @@
"type": "github"
}
},
"nixpkgs_2": {
"nixpkgs_4": {
"locked": {
"lastModified": 1660318005,
"narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=",
"lastModified": 1674868155,
"narHash": "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f",
"rev": "ce20e9ebe1903ea2ba1ab006ec63093020c761cb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"type": "indirect"
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"null-ls-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1676246878,
"narHash": "sha256-hAUEa2zNsYXQ+TsHYHBzcW67lCxhiD7x+uPbdOZwY8o=",
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"rev": "d4594231a06cecce73a78a256b0d7c7ab51f7dd5",
"type": "github"
},
"original": {
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1663440270,
"narHash": "sha256-RkBoLyxamsBqRn9lB9RbFSDg7KHiGgHBsrpffEVXWCQ=",
"lastModified": 1676251563,
"narHash": "sha256-itLKR2Haeh5wQ6dxkuZ8L5gwp3+CAggpN+w2e7cLQPg=",
"owner": "nix-community",
"repo": "nur",
"rev": "7511d58da488c67887745f40fd4846aa8c876d25",
"rev": "9a8b28a9d6611f6af9f7abb3e690fc755d6906fe",
"type": "github"
},
"original": {
@ -120,23 +342,158 @@
"type": "github"
}
},
"nvim-lspconfig-src": {
"flake": false,
"locked": {
"lastModified": 1676175675,
"narHash": "sha256-Wg3NatT4DRBMF6hCxK4C2DC+geFMpfFUFogPbqeMt6E=",
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "1712672e4da3003a0dd9f771d30389600b360f42",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "nvim-lspconfig",
"type": "github"
}
},
"nvim-tree-lua-src": {
"flake": false,
"locked": {
"lastModified": 1676244722,
"narHash": "sha256-xoSekdZhWr59qTOM0/ihYiuKiwHiKYb42Ep5JHn65UM=",
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"rev": "ba1778e061f25814bc5940be886a7f41d7d7736e",
"type": "github"
},
"original": {
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"type": "github"
}
},
"nvim-treesitter-src": {
"flake": false,
"locked": {
"lastModified": 1676240774,
"narHash": "sha256-eRSU/9ysSvTyYxBrp9Whg0eXgAOsCdmIHMlYZK7bjRg=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "7eb5f1a2e3949496f26c4084b521b30f2d08137a",
"type": "github"
},
"original": {
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"type": "github"
}
},
"root": {
"inputs": {
"Comment-nvim-src": "Comment-nvim-src",
"bufferline-nvim-src": "bufferline-nvim-src",
"cmp-nvim-lsp-src": "cmp-nvim-lsp-src",
"darwin": "darwin",
"firefox-darwin": "firefox-darwin",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nil": "nil",
"nix2vim": "nix2vim",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_3",
"null-ls-nvim-src": "null-ls-nvim-src",
"nur": "nur",
"nvim-lspconfig-src": "nvim-lspconfig-src",
"nvim-tree-lua-src": "nvim-tree-lua-src",
"nvim-treesitter-src": "nvim-treesitter-src",
"telescope-nvim-src": "telescope-nvim-src",
"telescope-project-nvim-src": "telescope-project-nvim-src",
"toggleterm-nvim-src": "toggleterm-nvim-src",
"wallpapers": "wallpapers",
"wsl": "wsl"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"nil",
"flake-utils"
],
"nixpkgs": [
"nil",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675391458,
"narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"telescope-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1675149856,
"narHash": "sha256-L4Kw94CUy6N7zcyy9INuR/O0fxQ7sp0IvGd/u7fHxMA=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "203bf5609137600d73e8ed82703d6b0e320a5f36",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"type": "github"
}
},
"telescope-project-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1671805267,
"narHash": "sha256-S4SOHzQ17ux5pcwwYFpVVLzjLeC4/EJ0IFPbrfzUJC8=",
"owner": "nvim-telescope",
"repo": "telescope-project.nvim",
"rev": "8e8ee37b7210761502cdf2c3a82b5ba8fb5b2972",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-project.nvim",
"type": "github"
}
},
"toggleterm-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1675358836,
"narHash": "sha256-9O7p/7tRStg51OFhMc88M5ewYquiYC9x9CV4s5veVP8=",
"owner": "akinsho",
"repo": "toggleterm.nvim",
"rev": "19aad0f41f47affbba1274f05e3c067e6d718e1e",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "toggleterm.nvim",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@ -164,15 +521,15 @@
"wsl": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1661772734,
"narHash": "sha256-DkvAaLDg9D6O0i2MzUknaf/U078K4KWAZaJQmNC/tL8=",
"lastModified": 1676126384,
"narHash": "sha256-3aAnN891Cb1pizewAgaHIo3W1WbAjXtoWuX8n3j8YoI=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "c1b0259313f661cf74051c916cf3bb4f061ce11f",
"rev": "a1c7e8bebac32cfac7aa8498bdfc60cbff13eb50",
"type": "github"
},
"original": {

137
flake.nix
View File

@ -26,15 +26,75 @@
# Community packages; used for Firefox extensions
nur.url = "github:nix-community/nur";
# Use official Firefox binary for macOS
firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin";
# Wallpapers
wallpapers = {
url = "gitlab:exorcist365/wallpapers";
flake = false;
};
# Used to generate NixOS images for other platforms
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
# Convert Nix to Neovim config
nix2vim = {
url = "github:gytis-ivaskevicius/nix2vim";
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix language server
nil.url = "github:oxalica/nil";
# Neovim plugins
nvim-lspconfig-src = {
url = "github:neovim/nvim-lspconfig";
flake = false;
};
cmp-nvim-lsp-src = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
null-ls-nvim-src = {
url = "github:jose-elias-alvarez/null-ls.nvim";
flake = false;
};
Comment-nvim-src = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
nvim-treesitter-src = {
url = "github:nvim-treesitter/nvim-treesitter";
flake = false;
};
telescope-nvim-src = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
telescope-project-nvim-src = {
url = "github:nvim-telescope/telescope-project.nvim";
flake = false;
};
toggleterm-nvim-src = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
bufferline-nvim-src = {
url = "github:akinsho/bufferline.nvim";
flake = false;
};
nvim-tree-lua-src = {
url = "github:kyazdani42/nvim-tree.lua";
flake = false;
};
};
outputs = { self, nixpkgs, darwin, wsl, home-manager, nur, wallpapers }:
outputs = { self, nixpkgs, ... }@inputs:
let
@ -44,10 +104,18 @@
fullName = "Noah Masur";
gitName = fullName;
gitEmail = "7386960+nmasur@users.noreply.github.com";
mailServer = "noahmasur.com";
dotfilesRepo = "https://github.com/nmasur/dotfiles";
mail.server = "noahmasur.com";
dotfilesRepo = "git@github.com:nmasur/dotfiles";
};
# Common overlays to always use
overlays = [
inputs.nur.overlay
inputs.nix2vim.overlay
(import ./overlays/neovim-plugins.nix inputs)
(import ./overlays/calibre-web.nix)
];
# System types to support.
supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
@ -55,36 +123,58 @@
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in {
in rec {
nixosConfigurations = {
desktop = import ./hosts/desktop {
inherit nixpkgs home-manager nur globals wallpapers;
};
wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; };
tempest = import ./hosts/tempest { inherit inputs globals overlays; };
hydra = import ./hosts/hydra { inherit inputs globals overlays; };
flame = import ./hosts/flame { inherit inputs globals overlays; };
swan = import ./hosts/swan { inherit inputs globals overlays; };
};
darwinConfigurations = {
macbook = import ./hosts/macbook {
inherit nixpkgs darwin home-manager nur globals;
};
lookingglass =
import ./hosts/lookingglass { inherit inputs globals overlays; };
};
# For quickly applying local settings with:
# home-manager switch --flake .#tempest
homeConfigurations = {
tempest =
nixosConfigurations.tempest.config.home-manager.users.${globals.user}.home;
lookingglass =
darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home;
};
# Package servers into images with a generator
packages = forAllSystems (system: {
aws = {
"${system}" =
import ./generators/aws { inherit inputs globals system overlays; };
};
staff = {
"${system}" = import ./generators/staff {
inherit inputs globals system overlays;
};
};
neovim = let pkgs = import nixpkgs { inherit system overlays; };
in import ./modules/neovim/package {
inherit pkgs;
colors =
import ./colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
};
});
apps = forAllSystems (system:
let pkgs = import nixpkgs { inherit system; };
in rec {
default = readme;
# Format and install from nothing
installer = import ./apps/installer.nix { inherit pkgs; };
# Display the readme for this repository
readme = import ./apps/readme.nix { inherit pkgs; };
});
let pkgs = import nixpkgs { inherit system overlays; };
in import ./apps { inherit pkgs; });
devShells = forAllSystems (system:
let pkgs = import nixpkgs { inherit system; };
let pkgs = import nixpkgs { inherit system overlays; };
in {
# Used to run commands and edit files in this repo
@ -101,6 +191,7 @@
vault
awscli2
google-cloud-sdk
ansible
kubectl
kubernetes-helm
kustomize

View File

@ -0,0 +1,32 @@
{ inputs, globals, ... }:
with inputs;
nixos-generators.nixosGenerate {
inherit system;
format = "amazon";
modules = [
home-manager.nixosModules.home-manager
{
user = globals.user;
fullName = globals.fullName;
dotfilesRepo = globals.dotfilesRepo;
gitName = globals.gitName;
gitEmail = globals.gitEmail;
networking.hostName = "sheep";
gui.enable = false;
colorscheme = (import ../modules/colorscheme/gruvbox);
passwordHash = null;
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# AWS settings require this
permitRootLogin = "prohibit-password";
}
../../hosts/common.nix
../../modules/nixos
../../modules/services/sshd.nix
] ++ [
# Required to fix diskSize errors during build
({ ... }: { amazonImage.sizeMB = 16 * 1024; })
];
}

80
generators/aws/main.tf Normal file
View File

@ -0,0 +1,80 @@
locals {
image_file = one(fileset(path.root, "result/nixos-amazon-image-*.vhd"))
}
# Upload to S3
resource "aws_s3_object" "image" {
bucket = "your_bucket_name"
key = basename(local.image_file)
source = local.image_file
etag = filemd5(local.image_file)
}
# Setup IAM access for the VM Importer
data "aws_iam_policy_document" "vmimport_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["vmie.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "vmimport" {
statement {
actions = [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
]
resources = [
"arn:aws:s3:::${aws_s3_object.image.bucket}",
"arn:aws:s3:::${aws_s3_object.image.bucket}/*",
]
}
statement {
actions = [
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*",
]
resources = ["*"]
}
}
resource "aws_iam_role" "vmimport" {
name = "vmimport"
assume_role_policy = data.aws_iam_policy_document.vmimport_trust_policy.json
inline_policy {
name = "vmimport"
policy = data.aws_iam_policy_document.vmimport.json
}
}
# Import to EBS
resource "aws_ebs_snapshot_import" "image" {
disk_container {
format = "VHD"
user_bucket {
s3_bucket = aws_s3_object.image.bucket
s3_key = aws_s3_object.image.key
}
}
role_name = aws_iam_role.vmimport.name
}
# Convert to AMI
resource "aws_ami" "image" {
description = "Created with NixOS."
name = replace(basename(local.image_file), "/\\.vhd$/", "")
virtualization_type = "hvm"
ebs_block_device {
device_name = "/dev/xvda"
snapshot_id = aws_ebs_snapshot_import.image.id
volume_size = 8
}
}

260
generators/aws/workflow.yml Normal file
View File

@ -0,0 +1,260 @@
name: 'Terraform'
env:
AWS_ACCOUNT_NUMBER: ''
AWS_PLAN_ROLE_NAME: github_actions_plan
AWS_APPLY_ROLE_NAME: github_actions_admin
# Always required. Used for authenticating to AWS, but can also act as your
# default region if you don't want to specify in the provider configuration.
AWS_REGION: us-east-1
# You must change these to fit your project.
TF_VAR_project: change-me
TF_VAR_label: change-me
TF_VAR_owner: Your Name Here
# If storing Terraform in a subdirectory, specify it here.
TERRAFORM_DIRECTORY: .
# Pinned versions of tools to use.
# Check for new releases:
# - https://github.com/hashicorp/terraform/releases
# - https://github.com/fugue/regula/releases
# - https://github.com/terraform-linters/tflint/releases
TERRAFORM_VERSION: 1.2.6
REGULA_VERSION: 2.9.0
TFLINT_VERSION: 0.39.1
# Terraform configuration options
TERRAFORM_PARALLELISM: 10
# These variables are passed to Terraform based on GitHub information.
TF_VAR_repo: ${{ github.repository }}
# This workflow is triggered in the following ways.
on:
# Any push or merge to these branches.
push:
branches:
- dev
- prod
# Any pull request targeting these branches (plan only).
pull_request:
branches:
- dev
- prod
# Any manual trigger on these branches.
workflow_dispatch:
branches:
- dev
- prod
# -------------------------------------------------------------------
# The rest of this workflow can operate without adjustments. Edit the
# below content at your own risk!
# -------------------------------------------------------------------
# Used to connect to AWS IAM
permissions:
id-token: write
contents: read
pull-requests: write
# Only run one workflow at a time for each Terraform state. This prevents
# lockfile conflicts, especially during PR vs push.
concurrency: terraform-${{ github.base_ref || github.ref }}
jobs:
terraform:
name: 'Terraform'
# Change this if you need to run your deployment on-prem.
runs-on: ubuntu-latest
steps:
# Downloads the current repo code to the runner.
- name: Checkout Repo Code
uses: actions/checkout@v2
# Install Nix
- name: Install Nix
uses: cachix/install-nix-action@v17
# Build the image
- name: Build Image
run: nix build .#aws
# Login to AWS
- name: AWS Assume Role
uses: aws-actions/configure-aws-credentials@v1.6.1
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
# Exports all GitHub Secrets as environment variables prefixed by
# "TF_VAR_", which exposes them to Terraform. The name of each GitHub
# Secret must match its Terraform variable name exactly.
- name: Export Secrets to Terraform Variables
env:
ALL_SECRETS: ${{ toJson(secrets) }}
run: |
echo "$ALL_SECRETS" \
| jq "to_entries | .[] | \"TF_VAR_\" + ( .key | ascii_downcase ) + \"=\" + .value" \
| tr -d \" >> $GITHUB_ENV
# Installs the Terraform binary and some other accessory functions.
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
# Checks whether Terraform is formatted properly. If this fails, you
# should install the pre-commit hook.
- name: Check Formatting
run: |
terraform fmt -no-color -check -diff -recursive
# Downloads a Terraform code lint test.
- uses: terraform-linters/setup-tflint@v1
name: Setup TFLint
with:
tflint_version: v${{ env.TFLINT_VERSION }}
# Sets up linting with this codebase.
- name: Init TFLint
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: tflint --init
# Lints the current code.
- name: Run TFLint
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
tflint -f compact
find ./modules/* -type d -maxdepth 0 | xargs -I __ tflint -f compact --disable-rule=terraform_required_providers --disable-rule=terraform_required_version __
# Connects to remote state backend and download providers.
- name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform init \
-backend-config="role_arn=${{ env.AWS_STATE_ROLE_ARN }}" \
-backend-config="region=us-east-1" \
-backend-config="workspace_key_prefix=accounts/${{ env.AWS_ACCOUNT_NUMBER }}/${{ github.repository }}" \
-backend-config="key=state.tfstate" \
-backend-config="dynamodb_table=global-tf-state-lock"
# Set the Terraform Workspace to the current branch name.
- name: Set Terraform Workspace
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
shell: bash
run: |
export WORKSPACE=${{ github.base_ref || github.ref_name }}
terraform workspace select ${WORKSPACE} || terraform workspace new $WORKSPACE
echo "TF_WORKSPACE=$(echo ${WORKSPACE} | sed 's/\//_/g')" >> $GITHUB_ENV
# Checks differences between current code and infrastructure state.
- name: Terraform Plan
id: plan
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform plan \
-input=false \
-no-color \
-out=tfplan \
-parallelism=${TERRAFORM_PARALLELISM} \
-var-file=variables-${TF_WORKSPACE}.tfvars
# Gets the results of the plan for pull requests.
- name: Terraform Show Plan
id: show
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: terraform show -no-color tfplan
# Adds the results of the plan to the pull request.
- name: Comment Plan
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
STDOUT: "```terraform\n${{ steps.show.outputs.stdout }}```"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style')
})
// 2. Prepare format of the comment
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
// 3. If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
# Downloads Regula and checks whether the plan meets compliance requirements.
- name: Regula Compliance Check
shell: bash
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
REGULA_URL="https://github.com/fugue/regula/releases/download/v${REGULA_VERSION}/regula_${REGULA_VERSION}_Linux_x86_64.tar.gz"
curl -sL "$REGULA_URL" -o regula.tar.gz
tar xzf regula.tar.gz
terraform show -json tfplan | ./regula run
# Deploys infrastructure or changes to infrastructure.
- name: Terraform Apply
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform apply \
-auto-approve \
-input=false \
-parallelism=${TERRAFORM_PARALLELISM} \
tfplan

View File

@ -0,0 +1,17 @@
# The Staff
# ISO configuration for my USB drive
{ inputs, globals, system, overlays, ... }:
with inputs;
nixos-generators.nixosGenerate {
inherit system;
format = "install-iso";
modules = [{
networking.hostName = "staff";
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"
];
}];
}

View File

@ -1,44 +0,0 @@
{ nixpkgs, home-manager, nur, globals, wallpapers, ... }:
# System configuration for my desktop
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
globals
home-manager.nixosModules.home-manager
{
networking.hostName = "desktop";
nixpkgs.overlays = [ nur.overlay ];
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
gaming.steam = true;
gaming.leagueoflegends = true;
gaming.legendary = true;
gui = {
enable = true;
compositor.enable = true;
wallpaper = "${wallpapers}/gruvbox/road.jpg";
gtk.theme = { name = "Adwaita-dark"; };
};
colorscheme = (import ../../modules/colorscheme/gruvbox);
passwordHash =
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
}
./hardware-configuration.nix
../common.nix
../../modules/hardware
../../modules/nixos
../../modules/graphical
../../modules/gaming
../../modules/applications
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/services/keybase.nix
../../modules/services/gnupg.nix
../../modules/services/mullvad.nix
../../modules/programming/nix.nix
../../modules/programming/haskell.nix
];
}

View File

@ -1,30 +0,0 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules =
[ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
swapDevices = [ ];
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
}

98
hosts/flame/default.nix Normal file
View File

@ -0,0 +1,98 @@
# The Flame
# System configuration for an Oracle free server
# How to install:
# https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/
{ inputs, globals, overlays, ... }:
with inputs;
nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = { };
modules = [
./hardware-configuration.nix
../../modules
../../nixos
(removeAttrs globals [ "mail.server" ])
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
server = true;
gui.enable = false;
theme = { colors = (import ../../colorscheme/gruvbox).dark; };
nixpkgs.overlays = overlays;
wsl.enable = false;
caddy.enable = true;
# FQDNs for various services
networking.hostName = "flame";
bookServer = "books.masu.rs";
streamServer = "stream.masu.rs";
nextcloudServer = "cloud.masu.rs";
transmissionServer = "download.masu.rs";
metricsServer = "metrics.masu.rs";
vaultwardenServer = "vault.masu.rs";
giteaServer = "git.masu.rs";
# Disable passwords, only use SSH key
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# Nextcloud backup config
backup.s3 = {
endpoint = "s3.us-west-002.backblazeb2.com";
bucket = "noahmasur-backup";
accessKeyId = "0026b0e73b2e2c80000000005";
};
# Grant access to Jellyfin directories from Nextcloud
users.users.nextcloud.extraGroups = [ "jellyfin" ];
# Wireguard config for Transmission
wireguard.enable = true;
networking.wireguard.interfaces.wg0 = {
# The local IPs for this machine within the Wireguard network
# Any inbound traffic bound for these IPs should be kept on localhost
ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ];
peers = [{
# Identity of Wireguard target peer (VPN)
publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY=";
# The public internet address of the target peer
endpoint = "86.106.143.132:51820";
# Which outgoing IP ranges should be sent through Wireguard
allowedIPs = [ "0.0.0.0/0" "::0/0" ];
# Send heartbeat signal within the network
persistentKeepalive = 25;
}];
};
# VPN port forwarding
services.transmission.settings.peer-port = 57599;
# Grant access to Transmission directories from Jellyfin
users.users.jellyfin.extraGroups = [ "transmission" ];
# Proxy traffic with Cloudflare
cloudflare.enable = true;
# Setup Minecraft server
gaming.minecraft-server.enable = true;
# Clone dotfiles
dotfiles.enable = true;
neovim.enable = true;
}
];
}

View File

@ -0,0 +1,34 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/e1b6bd50-306d-429a-9f45-78f57bc597c3";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/D5CA-237A";
fsType = "vfat";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eth0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
}

49
hosts/hydra/default.nix Normal file
View File

@ -0,0 +1,49 @@
# The Hydra
# System configuration for WSL
{ inputs, globals, overlays, ... }:
with inputs;
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
../../modules
../../nixos
globals
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
networking.hostName = "hydra";
nixpkgs.overlays = overlays;
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = false;
theme = {
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512;
wsl = {
enable = true;
wslConf.automount.root = "/mnt";
defaultUser = globals.user;
startMenuLaunchers = true;
nativeSystemd = true;
wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN
interop.includePath =
false; # Including Windows PATH will slow down Neovim command mode
};
neovim.enable = true;
mail.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
lua.enable = true;
}
];
}

View File

@ -0,0 +1,48 @@
# The Looking Glass
# System configuration for my work Macbook
{ inputs, globals, overlays, ... }:
with inputs;
darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = { };
modules = [
../../modules
../../darwin
(globals // {
user = "Noah.Masur";
gitName = "Noah-Masur_1701";
gitEmail = "Noah.Masur@take2games.com";
})
home-manager.darwinModules.home-manager
{
networking.hostName = "noah-masur-mac";
identityFile = "/Users/Noah.Masur/.ssh/id_ed25519";
gui.enable = true;
theme = {
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
mail.user = globals.user;
nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays;
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
neovim.enable = true;
mail.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
kitty.enable = true;
discord.enable = true;
firefox.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
terraform.enable = true;
python.enable = true;
lua.enable = true;
kubernetes.enable = true;
"1password".enable = true;
}
];
}

View File

@ -1,34 +0,0 @@
{ nixpkgs, darwin, home-manager, nur, globals, ... }:
# System configuration for my work MacBook
darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = { };
modules = [
(globals // {
user = "Noah.Masur";
gitName = "Noah-Masur_1701";
gitEmail = "Noah.Masur@take2games.com";
})
home-manager.darwinModules.home-manager
{
gui.enable = true;
colorscheme = (import ../../modules/colorscheme/gruvbox);
mailUser = globals.user;
nixpkgs.overlays = [ nur.overlay ];
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
}
../common.nix
../../modules/darwin
../../modules/applications/alacritty.nix
../../modules/applications/discord.nix
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/terraform.nix
../../modules/programming/python.nix
../../modules/programming/lua.nix
../../modules/programming/kubernetes.nix
];
}

View File

@ -1,20 +0,0 @@
{ nixpkgs, home-manager, globals, ... }:
# System configuration for a generic server
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
globals
home-manager.nixosModules.home-manager
{
networking.hostName = "sheep";
gui.enable = false;
colorscheme = (import ../../modules/colorscheme/gruvbox);
passwordHash =
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
}
../common.nix
../../modules/nixos
];
}

48
hosts/swan/default.nix Normal file
View File

@ -0,0 +1,48 @@
# The Swan
# System configuration for my home NAS server
{ inputs, globals, overlays, ... }:
with inputs;
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
./hardware-configuration.nix
../../modules
../../nixos
(removeAttrs globals [ "mail.server" ])
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
server = true;
gui.enable = false;
theme = { colors = (import ../../colorscheme/gruvbox).dark; };
nixpkgs.overlays = overlays;
wsl.enable = false;
caddy.enable = true;
networking.hostName = "swan";
# Disable passwords, only use SSH key
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# Clone dotfiles
dotfiles.enable = true;
neovim.enable = true;
boot.zfs.enabled = true;
boot.kernelPackages =
config.boot.zfs.package.latestCompatibleLinuxPackages;
boot.zfs.extraPools = [ "mypool" ];
services.zfs.autoScrub.enable = true;
services.zfs.autoScrub.interval = "daily";
services.nfs.server.enable = true;
}
];
}

62
hosts/tempest/default.nix Normal file
View File

@ -0,0 +1,62 @@
# The Tempest
# System configuration for my desktop
{ inputs, globals, overlays, ... }:
with inputs;
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
./hardware-configuration.nix
../../modules
../../nixos
globals
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
physical = true;
networking.hostName = "tempest";
nixpkgs.overlays = [ nur.overlay ] ++ overlays;
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = true;
theme = {
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
wallpaper = "${wallpapers}/gruvbox/road.jpg";
gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark";
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512;
wsl.enable = false;
publicKey = null;
neovim.enable = true;
media.enable = true;
firefox.enable = true;
kitty.enable = true;
_1password.enable = true;
discord.enable = true;
nautilus.enable = true;
obsidian.enable = true;
mail.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
keybase.enable = true;
# mullvad.enable = true;
nixlang.enable = true;
dotfiles.enable = true;
gaming = {
enable = true;
steam.enable = true;
legendary.enable = true;
lutris.enable = true;
leagueoflegends.enable = true;
};
}
];
}

View File

@ -0,0 +1,40 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules =
[ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ "amdgpu" ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
services.xserver.videoDrivers = [ "amdgpu" ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/f0313f58-971a-46e3-9191-909fe5eb7f7e";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/FB26-799C";
fsType = "vfat";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.amd.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -1,37 +0,0 @@
{ nixpkgs, wsl, home-manager, globals, ... }:
# System configuration for WSL
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
globals
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
networking.hostName = "wsl";
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
gui.enable = false;
colorscheme = (import ../../modules/colorscheme/gruvbox);
passwordHash =
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
wsl = {
enable = true;
automountPath = "/mnt";
defaultUser = globals.user;
startMenuLaunchers = true;
wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN
interop.includePath =
false; # Including Windows PATH will slow down Neovim command mode
};
}
../common.nix
../../modules/wsl
../../modules/nixos
../../modules/mail/himalaya.nix
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/lua.nix
];
}

View File

@ -1,10 +1,20 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
unfreePackages = [ "1password" "_1password-gui" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ _1password-gui ];
options = {
_1password = {
enable = lib.mkEnableOption {
description = "Enable 1Password.";
default = false;
};
};
};
config = lib.mkIf
(config.gui.enable && config._1password.enable && pkgs.stdenv.isLinux) {
unfreePackages = [ "1password" "_1password-gui" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ _1password-gui ];
};
};
}

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
alacritty = {
enable = lib.mkEnableOption {
description = "Enable Alacritty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.alacritty.enable) {
home-manager.users.${config.user} = {
xsession.windowManager.i3.config.terminal = "alacritty";
programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty";
@ -23,8 +32,8 @@
key_bindings = [
# Used for word completion in fish_user_key_bindings
{
key = "L";
mods = "Control|Shift";
key = "Return";
mods = "Shift";
chars = "\\x1F";
}
# Used for searching nixpkgs in fish_user_key_bindings
@ -34,8 +43,8 @@
chars = "\\x11F";
}
{
key = "K";
mods = "Control";
key = "H";
mods = "Control|Shift";
mode = "~Vi";
action = "ToggleViMode";
}
@ -54,32 +63,32 @@
];
colors = {
primary = {
background = config.colorscheme.base00;
foreground = config.colorscheme.base05;
background = config.theme.colors.base00;
foreground = config.theme.colors.base05;
};
cursor = {
text = "#1d2021";
cursor = config.colorscheme.base05;
cursor = config.theme.colors.base05;
};
normal = {
black = "#1d2021";
red = config.colorscheme.base08;
green = config.colorscheme.base0B;
yellow = config.colorscheme.base0A;
blue = config.colorscheme.base0D;
magenta = config.colorscheme.base0E;
cyan = config.colorscheme.base0C;
white = config.colorscheme.base05;
red = config.theme.colors.base08;
green = config.theme.colors.base0B;
yellow = config.theme.colors.base0A;
blue = config.theme.colors.base0D;
magenta = config.theme.colors.base0E;
cyan = config.theme.colors.base0C;
white = config.theme.colors.base05;
};
bright = {
black = config.colorscheme.base03;
red = config.colorscheme.base09;
green = config.colorscheme.base01;
yellow = config.colorscheme.base02;
blue = config.colorscheme.base04;
magenta = config.colorscheme.base06;
cyan = config.colorscheme.base0F;
white = config.colorscheme.base07;
black = config.theme.colors.base03;
red = config.theme.colors.base09;
green = config.theme.colors.base01;
yellow = config.theme.colors.base02;
blue = config.theme.colors.base04;
magenta = config.theme.colors.base06;
cyan = config.theme.colors.base0F;
white = config.theme.colors.base07;
};
};
draw_bold_text_with_bright_colors = false;

View File

@ -3,9 +3,9 @@
imports = [
./1password.nix
./alacritty.nix
./calibre.nix
./discord.nix
./firefox.nix
./kitty.nix
./media.nix
./obsidian.nix
./qbittorrent.nix

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
discord = {
enable = lib.mkEnableOption {
description = "Enable Discord.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.discord.enable) {
unfreePackages = [ "discord" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ discord ];

View File

@ -1,42 +1,67 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.gui.enable {
unfreePackages = [ "onepassword-password-manager" "okta-browser-plugin" ];
options = {
firefox = {
enable = lib.mkEnableOption {
description = "Enable Firefox.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.firefox.enable) {
unfreePackages = [
(lib.mkIf config._1password.enable "onepassword-password-manager")
"okta-browser-plugin"
];
home-manager.users.${config.user} = {
programs.firefox = {
enable = true;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
vimium
multi-account-containers
facebook-container
temporary-containers
onepassword-password-manager
okta-browser-plugin
sponsorblock
reddit-enhancement-suite
bypass-paywalls-clean
markdownload
darkreader
snowflake
don-t-fuck-with-paste
i-dont-care-about-cookies
];
profiles.Profile0 = {
package =
if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox;
profiles.default = {
id = 0;
name = "default";
isDefault = true;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
vimium
multi-account-containers
facebook-container
temporary-containers
(lib.mkIf config._1password.enable onepassword-password-manager)
okta-browser-plugin
sponsorblock
reddit-enhancement-suite
return-youtube-dislikes
markdownload
darkreader
snowflake
don-t-fuck-with-paste
i-dont-care-about-cookies
wappalyzer
];
settings = {
"app.update.auto" = false;
"browser.aboutConfig.showWarning" = false;
"browser.warnOnQuit" = false;
"browser.quitShortcut.disabled" =
if pkgs.stdenv.isLinux then true else false;
"browser.theme.dark-private-windows" = true;
"browser.toolbars.bookmarks.visibility" = "newtab";
"browser.toolbars.bookmarks.visibility" = false;
"browser.startup.page" = 3; # Restore previous session
"browser.newtabpage.enabled" = false; # Make new tabs blank
"trailhead.firstrun.didSeeAboutWelcome" =
true; # Disable welcome splash
"dom.forms.autocomplete.formautofill" = false; # Disable autofill
"extensions.formautofill.creditCards.enabled" =
false; # Disable credit cards
"dom.payments.defaults.saveAddress" = false; # Disable address save
"general.autoScroll" = true; # Drag middle-mouse to scroll
"services.sync.prefs.sync.general.autoScroll" =
false; # Prevent disabling autoscroll
@ -44,68 +69,86 @@
"toolkit.legacyUserProfileCustomizations.stylesheets" =
true; # Allow userChrome.css
"layout.css.color-mix.enabled" = true;
"ui.systemUsesDarkTheme" =
if config.theme.dark == true then 1 else 0;
};
userChrome = ''
:root {
--focus-outline-color: ${config.colorscheme.base04} !important;
--toolbar-color: ${config.colorscheme.base07} !important;
--focus-outline-color: ${config.theme.colors.base04} !important;
--toolbar-color: ${config.theme.colors.base07} !important;
--tab-min-height: 30px !important;
}
/* Background of tab bar */
.toolbar-items {
background-color: ${config.colorscheme.base00} !important;
background-color: ${config.theme.colors.base00} !important;
}
/* Extra tab bar sides on macOS */
.titlebar-spacer {
background-color: ${config.theme.colors.base00} !important;
}
.titlebar-buttonbox-container {
background-color: ${config.theme.colors.base00} !important;
}
#tabbrowser-tabs {
border-inline-start: 0 !important;
}
/* Private Browsing indicator on macOS */
#private-browsing-indicator-with-label {
background-color: ${config.theme.colors.base00} !important;
margin-inline: 0 !important;
padding-inline: 7px;
}
/* Tabs themselves */
.tabbrowser-tab .tab-stack {
border-radius: 5px 5px 0 0;
overflow: hidden;
background-color: ${config.colorscheme.base00};
color: ${config.colorscheme.base06} !important;
background-color: ${config.theme.colors.base00};
color: ${config.theme.colors.base06} !important;
}
.tab-content {
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent);
border-radius: 5px 5px 0 0;
background-color: ${config.colorscheme.base00};
color: ${config.colorscheme.base06} !important;
background-color: ${config.theme.colors.base00};
color: ${config.theme.colors.base06} !important;
}
.tab-content[selected=true] {
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent);
background-color: ${config.colorscheme.base01} !important;
color: ${config.colorscheme.base07} !important;
background-color: ${config.theme.colors.base01} !important;
color: ${config.theme.colors.base07} !important;
}
/* Below tab bar */
#nav-bar {
background: ${config.colorscheme.base01} !important;
background: ${config.theme.colors.base01} !important;
}
/* URL bar in nav bar */
#urlbar[focused=true] {
color: ${config.colorscheme.base07} !important;
background: ${config.colorscheme.base02} !important;
caret-color: ${config.colorscheme.base05} !important;
color: ${config.theme.colors.base07} !important;
background: ${config.theme.colors.base02} !important;
caret-color: ${config.theme.colors.base05} !important;
}
#urlbar:not([focused=true]) {
color: ${config.colorscheme.base04} !important;
background: ${config.colorscheme.base02} !important;
color: ${config.theme.colors.base04} !important;
background: ${config.theme.colors.base02} !important;
}
#urlbar ::-moz-selection {
color: ${config.colorscheme.base07} !important;
background: ${config.colorscheme.base02} !important;
color: ${config.theme.colors.base07} !important;
background: ${config.theme.colors.base02} !important;
}
#urlbar-input-container {
border: 1px solid ${config.colorscheme.base01} !important;
border: 1px solid ${config.theme.colors.base01} !important;
}
#urlbar-background {
background: ${config.colorscheme.base01} !important;
background: ${config.theme.colors.base01} !important;
}
/* Text in URL bar */
#urlbar-input, #urlbar-scheme, .searchbar-textbox {
color: ${config.colorscheme.base07} !important;
color: ${config.theme.colors.base07} !important;
}
'';
userContent = ''
@-moz-document url-prefix(about:blank) {
* {
background-color:${config.colorscheme.base01} !important;
background-color:${config.theme.colors.base01} !important;
}
}
'';

View File

@ -0,0 +1,88 @@
{ config, pkgs, lib, ... }: {
options = {
kitty = {
enable = lib.mkEnableOption {
description = "Enable Kitty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
home-manager.users.${config.user} = {
# xsession.windowManager.i3.config.terminal = "kitty";
# programs.rofi.terminal = "${pkgs.kitty}/bin/kitty";
programs.kitty = {
enable = true;
environment = { };
extraConfig = "";
font.size = 14;
keybindings = {
"shift+enter" = "send_text all \\x1F";
"super+f" = "toggle_fullscreen";
};
settings = {
# Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache)
background = config.theme.colors.base00;
foreground = config.theme.colors.base05;
selection_background = config.theme.colors.base05;
selection_foreground = config.theme.colors.base00;
url_color = config.theme.colors.base04;
cursor = config.theme.colors.base05;
active_border_color = config.theme.colors.base03;
inactive_border_color = config.theme.colors.base01;
active_tab_background = config.theme.colors.base00;
active_tab_foreground = config.theme.colors.base05;
inactive_tab_background = config.theme.colors.base01;
inactive_tab_foreground = config.theme.colors.base04;
tab_bar_background = config.theme.colors.base01;
# normal
color0 = config.theme.colors.base00;
color1 = config.theme.colors.base08;
color2 = config.theme.colors.base0B;
color3 = config.theme.colors.base0A;
color4 = config.theme.colors.base0D;
color5 = config.theme.colors.base0E;
color6 = config.theme.colors.base0C;
color7 = config.theme.colors.base05;
# bright
color8 = config.theme.colors.base03;
color9 = config.theme.colors.base08;
color10 = config.theme.colors.base0B;
color11 = config.theme.colors.base0A;
color12 = config.theme.colors.base0D;
color13 = config.theme.colors.base0E;
color14 = config.theme.colors.base0C;
color15 = config.theme.colors.base07;
# extended base16 colors
color16 = config.theme.colors.base09;
color17 = config.theme.colors.base0F;
color18 = config.theme.colors.base01;
color19 = config.theme.colors.base02;
color20 = config.theme.colors.base04;
color21 = config.theme.colors.base06;
# Scrollback
scrolling_lines = 10000;
scrollback_pager_history_size = 10; # MB
scrollback_pager = ''
${pkgs.neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
# Window
window_padding_width = 6;
tab_bar_edge = "top";
tab_bar_style = "slant";
# Audio
enable_audio_bell = false;
};
};
};
};
}

View File

@ -1,11 +1,30 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
home-manager.users.${config.user}.home.packages = with pkgs; [
mpv # Video viewer
sxiv # Image viewer
mupdf # PDF viewer
];
options = {
media = {
enable = lib.mkEnableOption {
description = "Enable media programs.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.media.enable) {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
mpv # Video viewer
sxiv # Image viewer
mupdf # PDF viewer
zathura # PDF viewer
];
# Set default for opening PDFs
xdg.mimeApps.defaultApplications."application/pdf" =
[ "zathura.desktop" ];
xdg.mimeApps.defaultApplications."image/*" = [ "sxiv.desktop" ];
};
};
}

View File

@ -1,12 +1,32 @@
{ config, pkgs, lib, ... }: {
options = {
nautilus = {
enable = lib.mkEnableOption {
description = "Enable Nautilus file manager.";
default = false;
};
};
};
# Install Nautilus file manager
config = lib.mkIf config.gui.enable {
config = lib.mkIf (config.gui.enable && config.nautilus.enable) {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
gnome.nautilus
gnome.sushi # Quick preview with spacebar
];
# Set default for opening directories
xdg.mimeApps.defaultApplications."inode/directory" =
[ "nautilus.desktop" ];
programs.fish.functions = {
qr = {
body =
"${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png";
};
};
};
};

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
obsidian = {
enable = lib.mkEnableOption {
description = "Enable Obsidian.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.obsidian.enable) {
unfreePackages = [ "obsidian" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ obsidian ];

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
qbittorrent = {
enable = lib.mkEnableOption {
description = "Enable qBittorrent.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.qbittorrent.enable) {
home-manager.users.${config.user} = {

View File

@ -1,22 +0,0 @@
{
name = "gruvbox"; # Dark, Medium
author =
"Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
neovimConfig = ./neovim.lua;
}

View File

@ -1,13 +0,0 @@
local M = {}
M.packer = function(use)
use({
"lifepillar/vim-gruvbox8",
config = function()
vim.g.gruvbox_italicize_strings = 0
vim.cmd("colorscheme gruvbox8")
end,
})
end
return M

View File

@ -1,14 +0,0 @@
{ config, pkgs, ... }: {
home-manager.users.${config.user} = {
home.packages = with pkgs;
[ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ];
programs.alacritty.settings = {
font.normal.family = "FiraCode Nerd Font Mono";
};
};
}

View File

@ -1,15 +0,0 @@
{ config, ... }: {
# Hammerspoon - MacOS custom automation scripting
home-manager.users.${config.user} = {
xdg.configFile.hammerspoon = { source = ./hammerspoon; };
};
homebrew.casks = [ "hammerspoon" ];
system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
'';
}

View File

@ -1,52 +0,0 @@
{ config, ... }: {
# Homebrew - Mac-specific packages that aren't in Nix
# Requires Homebrew to be installed
system.activationScripts.preUserActivation.text = ''
if ! xcode-select --version 2>/dev/null; then
$DRY_RUN_CMD xcode-select --install
fi
if ! /usr/local/bin/brew --version 2>/dev/null; then
$DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
'';
homebrew = {
enable = true;
onActivation = {
autoUpdate = false; # Don't update during rebuild
cleanup = "zap"; # Uninstall all programs not declared
upgrade = true;
};
global = {
brewfile = true; # Run brew bundle from anywhere
lockfiles = false; # Don't save lockfile (since running from anywhere)
};
taps = [
"homebrew/cask" # Required for casks
"homebrew/cask-drivers" # Used for Logitech G-Hub
];
brews = [
"trash" # Delete files and folders to trash instead of rm
];
casks = [
"firefox" # Firefox packaging on Nix is broken for MacOS
"1password" # 1Password packaging on Nix is broken for MacOS
"scroll-reverser" # Different scroll style for mouse vs. trackpad
"meetingbar" # Show meetings in menu bar
"gitify" # Git notifications in menu bar
"logitech-g-hub" # Mouse and keyboard management
"mimestream" # Gmail client
"obsidian" # Obsidian packaging on Nix is not available for MacOS
"steam" # Not packaged for Nix
];
};
home-manager.users.${config.user} = {
programs.fish.shellAbbrs.t = "trash";
};
}

View File

@ -1,8 +0,0 @@
{ ... }: {
networking = {
computerName = "MacBook"; # Host name
hostName = "MacBook";
};
}

View File

@ -1,11 +0,0 @@
{ config, pkgs, ... }: {
# security.pki.certificateFiles = [
# "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
# (builtins.toString ../work/nixos-org-certs.crt)
# ];
security.pki.certificates =
[ (builtins.readFile ../work/nixos-org-certs.crt) ];
}

View File

@ -1,183 +0,0 @@
{ ... }: {
services.nix-daemon.enable = true;
system = {
keyboard = {
remapCapsLockToControl = true;
enableKeyMapping = true; # Allows for skhd
};
defaults = {
NSGlobalDomain = {
# Set to dark mode
AppleInterfaceStyle = "Dark";
# Don't change from dark to light automatically
# AppleInterfaceSwitchesAutomatically = false;
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
AppleKeyboardUIMode = 3;
# Automatically show and hide the menu bar
_HIHideMenuBar = true;
# Expand save panel by default
NSNavPanelExpandedStateForSaveMode = true;
# Expand print panel by default
PMPrintingExpandedStateForPrint = true;
# Replace press-and-hold with key repeat
ApplePressAndHoldEnabled = false;
# Set a fast key repeat rate
KeyRepeat = 2;
# Shorten delay before key repeat begins
InitialKeyRepeat = 12;
# Save to local disk by default, not iCloud
NSDocumentSaveNewDocumentsToCloud = false;
# Disable autocorrect capitalization
NSAutomaticCapitalizationEnabled = false;
# Disable autocorrect smart dashes
NSAutomaticDashSubstitutionEnabled = false;
# Disable autocorrect adding periods
NSAutomaticPeriodSubstitutionEnabled = false;
# Disable autocorrect smart quotation marks
NSAutomaticQuoteSubstitutionEnabled = false;
# Disable autocorrect spellcheck
NSAutomaticSpellingCorrectionEnabled = false;
};
dock = {
# Automatically show and hide the dock
autohide = true;
# Add translucency in dock for hidden applications
showhidden = true;
# Enable spring loading on all dock items
enable-spring-load-actions-on-all-items = true;
# Highlight hover effect in dock stack grid view
mouse-over-hilite-stack = true;
mineffect = "genie";
orientation = "bottom";
show-recents = false;
tilesize = 44;
};
finder = {
# Default Finder window set to column view
FXPreferredViewStyle = "clmv";
# Finder search in current folder by default
FXDefaultSearchScope = "SCcf";
# Disable warning when changing file extension
FXEnableExtensionChangeWarning = false;
# Allow quitting of Finder application
QuitMenuItem = true;
};
# Disable "Are you sure you want to open" dialog
LaunchServices.LSQuarantine = false;
# Disable trackpad tap to click
trackpad.Clicking = false;
# universalaccess = {
# # Zoom in with Control + Scroll Wheel
# closeViewScrollWheelToggle = true;
# closeViewZoomFollowsFocus = true;
# };
# Where to save screenshots
screencapture.location = "~/Downloads";
};
# Settings that don't have an option in nix-darwin
activationScripts.postActivation.text = ''
echo "Disable disk image verification"
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
echo "Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disable the warning before emptying the Trash"
defaults write com.apple.finder WarnOnEmptyTrash -bool false
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Show the ~/Library folder"
chflags nohidden ~/Library
echo "Enable dock magnification"
defaults write com.apple.dock magnification -bool true
echo "Set dock magnification size"
defaults write com.apple.dock largesize -int 48
echo "Define dock icon function"
__dock_item() {
printf '%s%s%s%s%s' \
'<dict><key>tile-data</key><dict><key>file-data</key><dict>' \
'<key>_CFURLString</key><string>' \
"$1" \
'</string><key>_CFURLStringType</key><integer>0</integer>' \
'</dict></dict></dict>'
}
echo "Choose and order dock icons"
defaults write com.apple.dock persistent-apps -array \
"$(__dock_item /Applications/1Password.app)" \
"$(__dock_item /Applications/Slack.app)" \
"$(__dock_item /System/Applications/Calendar.app)" \
"$(__dock_item /Applications/Firefox.app)" \
"$(__dock_item /System/Applications/Messages.app)" \
"$(__dock_item /System/Applications/Mail.app)" \
"$(__dock_item /Applications/Mimestream.app)" \
"$(__dock_item /Applications/zoom.us.app)" \
"$(__dock_item /Applications/Obsidian.app)" \
"$(__dock_item /Applications/Alacritty.app)" \
"$(__dock_item /System/Applications/System\ Preferences.app)"
echo "Enable sudo Touch ID"
echo "# sudo: auth account password session" > /tmp/sudofile
echo "auth sufficient pam_smartcard.so" >> /tmp/sudofile
echo "auth sufficient pam_tid.so " >> /tmp/sudofile
echo "auth required pam_opendirectory.so" >> /tmp/sudofile
echo "account required pam_permit.so" >> /tmp/sudofile
echo "password required pam_deny.so" >> /tmp/sudofile
echo "session required pam_permit.so" >> /tmp/sudofile
sudo mv /tmp/sudofile /etc/pam.d/sudo
echo "Allow apps from anywhere"
SPCTL=$(spctl --status)
if ! [ "$SPCTL" = "assessments disabled" ]; then
sudo spctl --master-disable
fi
'';
};
}

View File

@ -1,8 +0,0 @@
{ config, pkgs, lib, ... }: {
users.users."${config.user}" = { # macOS user
home = config.homePath;
shell = pkgs.zsh; # Default shell
};
}

View File

@ -1,33 +0,0 @@
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
# visidata # CSV inspector
dos2unix # Convert Windows text files
inetutils # Includes telnet
youtube-dl # Convert web videos
pandoc # Convert text documents
mpd # TUI slideshows
awscli2
awslogs
kubectl
k9s
noti # Create notifications programmatically
ipcalc
(pkgs.writeScriptBin "ocr"
(builtins.readFile ../shell/bash/scripts/ocr.sh))
];
programs.fish.shellAbbrs = {
# Add noti for ghpr in Darwin
ghpr = lib.mkForce "gh pr create && sleep 3 && noti gh run watch";
grw = lib.mkForce "noti gh run watch";
# Shortcut to edit hosts file
hosts = "sudo nvim /etc/hosts";
};
};
}

View File

@ -1,11 +1,11 @@
{ config, lib, pkgs, ... }: {
imports =
[ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ];
[ ./applications ./mail ./neovim ./programming ./repositories ./shell ];
options = with lib; {
user = mkOption {
type = types.str;
options = {
user = lib.mkOption {
type = lib.types.str;
description = "Primary user of the system";
};
fullName = lib.mkOption {
@ -21,45 +21,67 @@
if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
};
};
identityFile = lib.mkOption {
type = lib.types.str;
description = "Path to existing private key file.";
default = "/etc/ssh/ssh_host_ed25519_key";
};
gui = {
enable = mkEnableOption {
description = "Enable graphics";
enable = lib.mkEnableOption {
description = "Enable graphics.";
default = false;
};
};
colorscheme = mkOption {
type = types.attrs;
description = "Base16 color scheme";
theme = {
colors = lib.mkOption {
type = lib.types.attrs;
description = "Base16 color scheme.";
default = (import ../colorscheme/gruvbox).dark;
};
dark = lib.mkOption {
type = lib.types.bool;
description = "Enable dark mode.";
default = true;
};
};
homePath = mkOption {
type = types.path;
# colorscheme = lib.mkOption {
# type = types.attrs;
# description = "Base16 color scheme";
# };
homePath = lib.mkOption {
type = lib.types.path;
description = "Path of user's home directory.";
default = builtins.toPath (if pkgs.stdenv.isDarwin then
"/Users/${config.user}"
else
"/home/${config.user}");
};
dotfilesPath = mkOption {
type = types.path;
dotfilesPath = lib.mkOption {
type = lib.types.path;
description = "Path of dotfiles repository.";
default = config.homePath + "/dev/personal/dotfiles";
};
dotfilesRepo = mkOption {
type = types.str;
dotfilesRepo = lib.mkOption {
type = lib.types.str;
description = "Link to dotfiles repository.";
};
unfreePackages = mkOption {
type = types.listOf types.str;
unfreePackages = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "List of unfree packages to allow.";
default = [ ];
};
};
config = let stateVersion = "22.11";
config = let stateVersion = "23.05";
in {
# Enable features in Nix commands
nix.extraOptions = "experimental-features = nix-command flakes";
nix.extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
# Basic common system packages for all devices
environment.systemPackages = with pkgs; [ git vim wget curl ];

View File

@ -1,11 +0,0 @@
{ config, ... }: {
imports = [ ./leagueoflegends.nix ./lutris.nix ./steam.nix ./legendary.nix ];
config = {
hardware.opengl = {
enable = true;
driSupport32Bit = true;
};
};
}

View File

@ -1,30 +0,0 @@
{ config, pkgs, lib, ... }: {
options.gaming.leagueoflegends = lib.mkEnableOption "League of Legends";
config = lib.mkIf config.gaming.leagueoflegends {
# League of Legends anti-cheat requirement
boot.kernel.sysctl = { "abi.vsyscall32" = 0; };
environment.systemPackages = with pkgs; [
# Lutris requirement to install the game
lutris
amdvlk
wineWowPackages.stable
# vulkan-tools
# Required according to https://lutris.net/games/league-of-legends/
openssl
gnome.zenity
# Don't remember if this is required
dconf
];
environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; };
};
}

View File

@ -1,55 +0,0 @@
{ lib, ... }: {
imports = [
./xorg.nix
./fonts.nix
./i3.nix
./polybar.nix
./picom.nix
# ./dmenu.nix
./rofi.nix
];
options = with lib; {
gui = {
compositor.enable = mkEnableOption {
description = "Enable transparency, blur, shadows";
default = false;
};
launcherCommand = mkOption {
type = types.str;
description = "Command to use for launching";
};
systemdSearch = mkOption {
type = types.str;
description = "Command to use for interacting with systemd";
};
altTabCommand = mkOption {
type = types.str;
description = "Command to use for choosing windows";
};
toggleBarCommand = lib.mkOption {
type = lib.types.str;
description = "Command to hide and show the status bar.";
};
gtk.theme = {
name = mkOption {
type = types.str;
description = "Theme name for GTK applications";
};
package = mkOption {
type = types.str;
description = "Theme package name for GTK applications";
default = "gnome-themes-extra";
};
};
wallpaper = mkOption {
type = types.path;
description = "Wallpaper background image file";
};
};
};
}

View File

@ -1,49 +0,0 @@
{ config, lib, ... }: {
config =
lib.mkIf (config.services.xserver.enable && config.gui.compositor.enable) {
home-manager.users.${config.user} = {
services.picom = {
enable = true;
settings = {
blur = false;
blurExclude = [ ];
inactiveDim = "0.05";
noDNDShadow = false;
noDockShadow = false;
# shadow-radius = 20
# '';
# shadow-radius = 20
# corner-radius = 10
# blur-size = 20
# rounded-corners-exclude = [
# "window_type = 'dock'",
# "class_g = 'i3-frame'"
# ]
# '';
};
fade = false;
experimentalBackends = true;
inactiveOpacity = 1.0;
menuOpacity = 1.0;
opacityRules = [
"0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows
];
shadow = false;
shadowExclude = [ ];
shadowOffsets = [ (-10) (-10) ];
shadowOpacity = 0.5;
vSync = true;
};
xsession.windowManager.i3.config.startup = [{
command = "systemctl --user restart picom";
always = true;
notification = false;
}];
};
};
}

View File

@ -1,14 +0,0 @@
{ ... }: {
imports = [
./audio.nix
./boot.nix
./keyboard.nix
./monitors.nix
./mouse.nix
./networking.nix
./sleep.nix
./wifi.nix
];
}

View File

@ -1,53 +0,0 @@
{ config, pkgs, lib, ... }: {
# Timezone required for Redshift schedule
imports = [ ../nixos/timezone.nix ];
config = lib.mkIf config.gui.enable {
environment.systemPackages = with pkgs;
[
ddcutil # Monitor brightness control
];
# Reduce blue light at night
services.redshift = {
enable = true;
brightness = {
day = "1.0";
night = "1.0";
};
};
# Detect monitors (brightness) for ddcutil
hardware.i2c.enable = true;
# Grant main user access to external monitors
users.users.${config.user}.extraGroups = [ "i2c" ];
services.xserver.displayManager = {
# Put the login screen on the left monitor
lightdm.greeters.gtk.extraConfig = ''
active-monitor=0
'';
# Set up screen position and rotation
setupCommands = ''
${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \
--mode 1920x1200 \
--pos 1920x0 \
--rotate left \
--output HDMI-0 \
--primary \
--mode 1920x1080 \
--pos 0x560 \
--rotate normal \
--output DVI-0 --off \
--output DVI-1 --off \
'';
};
};
}

View File

@ -1,21 +0,0 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
# Mouse customization
services.ratbagd.enable = true;
environment.systemPackages = with pkgs; [
libratbag # Mouse adjustments
piper # Mouse adjustments GUI
];
services.xserver.libinput.mouse = {
# Disable mouse acceleration
accelProfile = "flat";
accelSpeed = "1.15";
};
};
}

View File

@ -1,10 +0,0 @@
{ ... }: {
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.enp0s31f6.useDHCP = true;
networking.interfaces.wlp3s0.useDHCP = true;
}

View File

@ -1,8 +0,0 @@
{ ... }: {
# Prevent wake from keyboard
powerManagement.powerDownCommands = ''
for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done
'';
}

View File

@ -1,9 +0,0 @@
{ ... }: {
# Enables wireless support via wpa_supplicant.
networking.wireless.enable = true;
# Allows the user to control the WiFi settings.
networking.wireless.userControlled.enable = true;
}

189
modules/mail/aerc.nix Normal file
View File

@ -0,0 +1,189 @@
{ config, pkgs, lib, ... }: {
options.mail.aerc.enable = lib.mkEnableOption "Aerc email.";
config = lib.mkIf config.mail.aerc.enable {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
w3m # Render HTML
dante # Socksify for rendering HTML
];
programs.aerc = {
enable = true;
extraBinds = {
# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
global = {
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab <Enter>";
"<C-t>" = ":term<Enter>";
"?" = ":help keys<Enter>";
};
messages = {
q = ":quit<Enter>";
j = ":next <Enter>";
"<Down>" = ":next<Enter>";
"<C-d>" = ":next 50%<Enter>";
"<C-f>" = ":next 100%<Enter>";
"<PgDn>" = ":next 100%<Enter>";
k = ":prev <Enter>";
"<Up>" = ":prev<Enter>";
"<C-u>" = ":prev 50%<Enter>";
"<C-b>" = ":prev 100%<Enter>";
"<PgUp>" = ":prev 100%<Enter>";
g = ":select 0 <Enter>";
G = ":select -1<Enter>";
J = ":next-folder <Enter>";
K = ":prev-folder<Enter>";
H = ":collapse-folder<Enter>";
L = ":expand-folder<Enter>";
v = ":mark -t<Enter>";
V = ":mark -v<Enter>";
T = ":toggle-threads<Enter>";
"<Enter>" = ":view<Enter>";
d = ":prompt 'Really delete this message?' 'delete-message'<Enter>";
D = ":move Trash<Enter>";
A = ":archive flat<Enter>";
C = ":compose<Enter>";
rr = ":reply -a<Enter>";
rq = ":reply -aq<Enter>";
Rr = ":reply<Enter>";
Rq = ":reply -q<Enter>";
c = ":cf<space>";
"$" = ":term<space>";
"!" = ":term<space>";
"|" = ":pipe<space>";
"/" = ":search<space>";
"\\" = ":filter <space>";
n = ":next-result<Enter>";
N = ":prev-result<Enter>";
"<Esc>" = ":clear<Enter>";
};
"messages:folder=Drafts" = { "<Enter>" = ":recall<Enter>"; };
view = {
"/" = ":toggle-key-passthrough <Enter> /";
q = ":close<Enter>";
O = ":open<Enter>";
S = ":save<space>";
"|" = ":pipe<space>";
D = ":move Trash<Enter>";
A = ":archive flat<Enter>";
"<C-l>" = ":open-link <space>";
f = ":forward <Enter>";
rr = ":reply -a<Enter>";
rq = ":reply -aq<Enter>";
Rr = ":reply<Enter>";
Rq = ":reply -q<Enter>";
H = ":toggle-headers<Enter>";
"<C-k>" = ":prev-part<Enter>";
"<C-j>" = ":next-part<Enter>";
J = ":next <Enter>";
K = ":prev<Enter>";
};
"view::passthrough" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<Esc>" = ":toggle-key-passthrough<Enter>";
};
compose = {
# Keybindings used when the embedded terminal is not selected in the compose
# view
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<A-p>" = ":switch-account -p<Enter>";
"<A-n>" = ":switch-account -n<Enter>";
"<tab>" = ":next-field<Enter>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
"compose::editor" = {
# Keybindings used when the embedded terminal is selected in the compose view
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
"compose::review" = {
# Keybindings used when reviewing a message to be sent
y = ":send <Enter>";
n = ":abort<Enter>";
p = ":postpone<Enter>";
q = ":choose -o d discard abort -o p postpone postpone<Enter>";
e = ":edit<Enter>";
a = ":attach<space>";
d = ":detach<space>";
};
terminal = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
};
extraConfig = {
general.unsafe-accounts-conf = true;
viewer = { pager = "${pkgs.less}/bin/less -R"; };
filters = {
"text/plain" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"text/calendar" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/calendar";
"text/html" =
"${pkgs.aerc}/share/aerc/filters/html"; # Requires w3m, dante
# "text/html" =
# "${pkgs.aerc}/share/aerc/filters/html | ${pkgs.aerc}/share/aerc/filters/colorize";
# "text/*" =
# ''${pkgs.bat}/bin/bat -fP --file-name="$AERC_FILENAME "'';
"message/delivery-status" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"message/rfc822" =
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
"application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh";
"application/pdf" = "${pkgs.zathura}/bin/zathura -";
};
};
};
accounts.email.accounts.home.aerc = {
enable = true;
extraAccounts = {
check-mail = "5m";
check-mail-cmd = "${pkgs.isync}/bin/mbsync -a";
};
};
programs.fish.shellAbbrs = { ae = "aerc"; };
};
};
}

84
modules/mail/default.nix Normal file
View File

@ -0,0 +1,84 @@
{ config, pkgs, lib, ... }: {
imports = [ ./himalaya.nix ./aerc.nix ];
options = {
mail.enable = lib.mkEnableOption "Mail service.";
mail.user = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mail.server = lib.mkOption {
type = lib.types.str;
description = "Server name for the email address.";
};
};
config = lib.mkIf config.mail.enable {
home-manager.users.${config.user} = {
programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true;
frequency = "*:0/5";
};
accounts.email = {
maildirBasePath = "${config.homePath}/mail";
accounts = {
home = let address = "${config.mail.user}@${config.mail.server}";
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (user: "${user}@${config.mail.server}") [
"me"
"hey"
"admin"
];
alot = { };
flavor = "plain";
folders = { };
getmail = { };
imap = {
host = "imap.purelymail.com";
port = 993;
tls.enable = true;
};
imapnotify = {
enable = false;
boxes = [ ];
onNotify = "";
onNotifyPost = "";
};
maildir = { path = "main"; };
mbsync = {
enable = true;
create = "maildir";
expunge = "none";
remove = "none";
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
mu.enable = false;
notmuch.enable = false;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
builtins.toString ../../private/mailpass.age
}";
smtp = {
host = "smtp.purelymail.com";
port = 465;
tls.enable = true;
};
};
};
};
};
};
}

View File

@ -1,87 +1,19 @@
{ config, pkgs, lib, ... }: {
{ config, lib, ... }: {
options = {
mailUser = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mailServer = lib.mkOption {
type = lib.types.str;
description = "Server name for the email address.";
};
};
options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email.";
config = {
config = lib.mkIf config.mail.himalaya.enable {
home-manager.users.${config.user} = {
programs.himalaya = { enable = true; };
programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
accounts.email.accounts.home.himalaya = {
enable = true;
frequency = "*:0/5";
};
accounts.email = {
maildirBasePath = "${config.homePath}/mail";
accounts = {
home = let address = "${config.mailUser}@${config.mailServer}";
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (mailUser: "${mailUser}@${config.mailServer}") [
"me"
"hey"
"admin"
];
alot = { };
flavor = "plain";
folders = { };
getmail = { };
himalaya = {
enable = true;
settings = {
downloads-dir = config.userDirs.download;
smtp-insecure = true;
};
};
imap = {
host = "imap.purelymail.com";
port = 993;
tls.enable = true;
};
imapnotify = {
enable = false;
boxes = [ ];
onNotify = "";
onNotifyPost = "";
};
maildir = { path = "main"; };
mbsync = {
enable = true;
create = "maildir";
expunge = "none";
remove = "none";
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
mu.enable = false;
notmuch.enable = false;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.homePath}/.ssh/id_ed25519 ${
builtins.toString ./mailpass.age
}";
smtp = {
host = "smtp.purelymail.com";
port = 465;
tls.enable = true;
};
};
backend = "imap";
sender = "smtp";
settings = {
downloads-dir = config.userDirs.download;
smtp-insecure = true;
};
};

View File

@ -1,5 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 MgHaOw 8h/ESNjn0gknNXoHM34UobHzPgmRunoP97H+KHOuGQM
qowH+6TlCRECGCscRgKx6kswY+PZezYUD6E+x9e+5pM
--- kFj1JzRdh/D13Uq9aNTzMJIFysEE+kzzthjewOIR2+o
Ȳ<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD><EFBFBD>}rC<72>z<><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@ -0,0 +1,22 @@
{ pkgs, ... }: {
plugins = [
pkgs.vimPlugins.bufferline-nvim
pkgs.vimPlugins.vim-bbye # Better closing of buffers
];
setup.bufferline = {
options = {
diagnostics = "nvim_lsp";
always_show_bufferline = false;
separator_style = "slant";
offsets = [{ filetype = "NvimTree"; }];
};
};
lua = ''
-- Move buffers
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
-- Kill buffer
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
'';
}

View File

@ -0,0 +1,155 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.cmp-nvim-lsp
pkgs.vimPlugins.cmp-buffer
pkgs.vimPlugins.cmp-path
pkgs.vimPlugins.cmp-cmdline
pkgs.vimPlugins.cmp-nvim-lua
pkgs.vimPlugins.luasnip
pkgs.vimPlugins.cmp_luasnip
pkgs.vimPlugins.cmp-rg
pkgs.vimPlugins.friendly-snippets
];
use.cmp.setup = dsl.callWith {
# Disable in telescope buffers
enabled = dsl.rawLua ''
function()
if vim.bo.buftype == "prompt" then
return false
end
return true
end
'';
snippet.expand = dsl.rawLua ''
function(args)
require("luasnip").lsp_expand(args.body)
end
'';
mapping = {
"['<C-n>']" = dsl.rawLua
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
"['<C-p>']" = dsl.rawLua
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })";
"['<Down>']" = dsl.rawLua
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })";
"['<Up>']" = dsl.rawLua
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })";
"['<C-d>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)";
"['<C-f>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)";
"['<C-e>']" = dsl.rawLua "require('cmp').mapping.abort()";
"['<CR>']" = dsl.rawLua
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
"['<C-r>']" = dsl.rawLua
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
"['<Esc>']" = dsl.rawLua ''
function(_)
cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
})
vim.cmd("stopinsert") --- Abort and leave insert mode
end
'';
"['<C-l>']" = dsl.rawLua ''
cmp.mapping(function(_)
if require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
end
end, { "i", "s" })
'';
};
sources = [
{ name = "nvim_lua"; }
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{ name = "path"; }
{
name = "buffer";
keyword_length = 3;
max_item_count = 10;
}
{
name = "rg";
keyword_length = 6;
max_item_count = 10;
option = { additional_arguments = "--ignore-case"; };
}
];
formatting = {
fields = [ "kind" "abbr" "menu" ];
format = dsl.rawLua ''
function(entry, vim_item)
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
rg = "[Grep]",
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
})[entry.source.name]
return vim_item
end
'';
};
experimental = {
native_menu = false; # Use cmp menu instead of Vim menu
ghost_text = true; # Show preview auto-completion
};
};
lua = ''
-- Use buffer source for `/`
require('cmp').setup.cmdline("/", {
sources = {
{ name = "buffer", keyword_length = 5 },
},
})
-- Use cmdline & path source for ':'
require('cmp').setup.cmdline(":", {
sources = require('cmp').config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
'';
}

View File

@ -0,0 +1,35 @@
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " "
vim.g.maplocalleader = " "
local gitsigns = require("gitsigns")
vim.keymap.set("n", "<Leader>gB", gitsigns.blame_line)
vim.keymap.set("n", "<Leader>gp", gitsigns.preview_hunk)
vim.keymap.set("v", "<Leader>gp", gitsigns.preview_hunk)
vim.keymap.set("n", "<Leader>gd", gitsigns.diffthis)
vim.keymap.set("v", "<Leader>gd", gitsigns.diffthis)
vim.keymap.set("n", "<Leader>rgf", gitsigns.reset_buffer)
vim.keymap.set("v", "<Leader>hs", gitsigns.stage_hunk)
vim.keymap.set("n", "<Leader>hr", gitsigns.reset_hunk)
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
-- Navigation
vim.keymap.set("n", "]g", function()
if vim.wo.diff then
return "]g"
end
vim.schedule(function()
gitsigns.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
vim.keymap.set("n", "[g", function()
if vim.wo.diff then
return "[g"
end
vim.schedule(function()
gitsigns.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })

View File

@ -0,0 +1,5 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.gitsigns-nvim ];
setup.gitsigns = { };
lua = builtins.readFile ./gitsigns.lua;
}

View File

@ -0,0 +1,10 @@
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
-- vim.keymap.set("n", "gr", telescope.lsp_references)
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<Leader>de", vim.diagnostic.open_float)
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)

View File

@ -0,0 +1,66 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.nvim-lspconfig
pkgs.vimPlugins.lsp-colors-nvim
pkgs.vimPlugins.null-ls-nvim
];
use.lspconfig.sumneko_lua.setup = dsl.callWith {
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ];
};
use.lspconfig.nil_ls.setup = dsl.callWith {
cmd = [ "${pkgs.nil}/bin/nil" ];
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
};
use.lspconfig.pyright.setup = dsl.callWith {
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
};
use.lspconfig.terraformls.setup =
dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; };
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ];
lua = ''
${builtins.readFile ./lsp.lua}
require("null-ls").setup({
sources = {
require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }),
require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }),
require("null-ls").builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }),
require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }),
require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }),
require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }),
require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }),
require("null-ls").builtins.formatting.shfmt.with({
command = "${pkgs.shfmt}/bin/shfmt",
extra_args = { "-i", "4", "-ci" },
}),
require("null-ls").builtins.formatting.terraform_fmt.with({
command = "${pkgs.terraform}/bin/terraform",
extra_filetypes = { "hcl" },
}),
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
})
'';
}

View File

@ -0,0 +1,70 @@
{ pkgs, dsl, lib, ... }: {
plugins = [
pkgs.vimPlugins.vim-surround # Keybinds for surround characters
pkgs.vimPlugins.vim-eunuch # File manipulation commands
pkgs.vimPlugins.vim-fugitive # Git commands
pkgs.vimPlugins.vim-repeat # Better repeat using .
pkgs.vimPlugins.comment-nvim # Smart comment commands
pkgs.vimPlugins.impatient-nvim # Faster load times
pkgs.vimPlugins.glow-nvim # Markdown preview popup
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
];
setup.Comment = { };
setup.colorizer = { };
vim.o = {
termguicolors = true; # Set to truecolor
hidden = true; # Don't unload buffers when leaving them
list = true; # Reveal whitespace with dashes
expandtab = true; # Tabs into spaces
shiftwidth = 4; # Amount to shift with > key
softtabstop = 4; # Amount to shift with <TAB> key
ignorecase = true; # Ignore case when searching
smartcase = true; # Check case when using capitals in search
infercase = true; # Don't match cases when completing suggestions
incsearch = true; # Search while typing
visualbell = true; # No sounds
scrolljump = 1; # Number of lines to scroll
scrolloff = 3; # Margin of lines to see while scrolling
splitright = true; # Vertical splits on the right side
splitbelow = true; # Horizontal splits on the bottom side
pastetoggle = "<F3>"; # Use F3 to enter raw paste mode
clipboard = "unnamedplus"; # Uses system clipboard for yanking
updatetime = 300; # Faster diagnostics
mouse = "nv"; # Mouse interaction / scrolling
inccommand = "split"; # Live preview search and replace
};
vim.wo = {
number = true; # Show line numbers
relativenumber = true; # Relative numbers instead of absolute
};
# Better backup, swap and undo storage
vim.o.backup = true; # Easier to recover and more secure
vim.bo.swapfile = false; # Instead of swaps, create backups
vim.bo.undofile = true; # Keeps undos after quit
vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"'';
# Required for nvim-cmp completion
vim.opt.completeopt = [ "menu" "menuone" "noselect" ];
lua = lib.mkBefore ''
require("impatient")
${builtins.readFile ../lua/keybinds.lua};
${builtins.readFile ../lua/settings.lua};
'';
vimscript = ''
" Remember last position when reopening file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" LaTeX options
au FileType tex inoremap ;bf \textbf{}<Esc>i
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
" Flash highlight when yanking
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
'';
}

View File

@ -0,0 +1,9 @@
{ pkgs, ... }: {
plugins = [ pkgs.vimPlugins.lualine-nvim ];
setup.lualine = {
options = {
theme = "gruvbox";
icons_enabled = true;
};
};
}

View File

@ -0,0 +1,52 @@
{ pkgs, ... }: {
plugins = [
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins:
with pkgs.tree-sitter-grammars; [
tree-sitter-hcl
tree-sitter-python
tree-sitter-lua
tree-sitter-nix
tree-sitter-fish
tree-sitter-toml
tree-sitter-yaml
tree-sitter-json
]))
pkgs.vimPlugins.vim-matchup # Better % jumping in languages
pkgs.vimPlugins.nginx-vim
pkgs.vimPlugins.vim-helm
pkgs.vimPlugins.vim-puppet
];
setup."nvim-treesitter.configs" = {
highlight = { enable = true; };
indent = { enable = true; };
textobjects = {
select = {
enable = true;
lookahead = true; # Jump forward automatically
keymaps = {
"['af']" = "@function.outer";
"['if']" = "@function.inner";
"['ac']" = "@class.outer";
"['ic']" = "@class.inner";
"['al']" = "@loop.outer";
"['il']" = "@loop.inner";
"['aa']" = "@call.outer";
"['ia']" = "@call.inner";
"['ar']" = "@parameter.outer";
"['ir']" = "@parameter.inner";
"['aC']" = "@comment.outer";
"['iC']" = "@comment.outer";
"['a/']" = "@comment.outer";
"['i/']" = "@comment.outer";
"['a;']" = "@statement.outer";
"['i;']" = "@statement.outer";
};
};
};
};
}

View File

@ -0,0 +1,69 @@
local telescope = require("telescope.builtin")
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
vim.keymap.set("n", "<Leader>b", telescope.buffers)
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
vim.keymap.set("n", "<Leader>cc", telescope.commands)
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
vim.keymap.set("n", "<Leader>N", function()
local opts = {
prompt_title = "Search Notes",
cwd = "$NOTES_PATH",
}
telescope.live_grep(opts)
end)
vim.keymap.set("n", "<Leader>fN", function()
local opts = {
prompt_title = "Find Notes",
cwd = "$NOTES_PATH",
}
telescope.find_files(opts)
end)
vim.keymap.set("n", "<Leader>cr", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 15,
},
},
})
telescope.command_history(opts)
end)
-- Zoxide
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
-- Project
require("telescope").load_extension("project")
vim.keymap.set("n", "<C-p>", function()
local opts = require("telescope.themes").get_ivy({
layout_config = {
bottom_pane = {
height = 10,
},
},
})
require("telescope").extensions.project.project(opts)
end)
-- File browser
require("telescope").load_extension("file_browser")
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
vim.keymap.set("n", "<Leader>fD", function()
local opts = {
prompt_title = "Find Downloads",
cwd = "~/downloads",
}
require("telescope").extensions.file_browser.file_browser(opts)
end)

View File

@ -0,0 +1,34 @@
{ pkgs, dsl, ... }: {
plugins = [
pkgs.vimPlugins.telescope-nvim
pkgs.vimPlugins.telescope-project-nvim
pkgs.vimPlugins.telescope-fzy-native-nvim
pkgs.vimPlugins.telescope-file-browser-nvim
pkgs.vimPlugins.telescope-zoxide
];
setup.telescope = {
defaults = {
mappings = {
i = {
"['<esc>']" = dsl.rawLua "require('telescope.actions').close";
"['<C-h>']" = "which_key";
};
};
};
pickers = {
find_files = { theme = "ivy"; };
oldfiles = { theme = "ivy"; };
buffers = { theme = "dropdown"; };
};
extensions = {
fzy_native = { };
zoxide = { };
project = { base_dirs = [ "~/dev" ]; };
};
};
lua = builtins.readFile ./telescope.lua;
}

View File

@ -0,0 +1,40 @@
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
-- Only set these keymaps for toggleterm
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "term://*toggleterm#*",
callback = function()
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
end,
})
local terminal = require("toggleterm.terminal").Terminal
local basicterminal = terminal:new()
function TERM_TOGGLE()
basicterminal:toggle()
end
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
function NIXPKGS_TOGGLE()
nixpkgs:toggle()
end
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
function GITWATCH_TOGGLE()
gitwatch:toggle()
end
local k9s = terminal:new({ cmd = "k9s" })
function K9S_TOGGLE()
k9s:toggle()
end
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)

Some files were not shown because too many files have changed in this diff Show More