This repository contains my machine configurations in Infrastructure as Code style. This is possible thanks to combination of NixOS modules, home-manager, and chezmoi.
This repo is a Nix Flake that you can import and use yourself but I don't recommend doing that. You should take it as an inspiration for your infrastructure instead.
Please note that this is a Work In Progress, so stuffs may change without further notice and this README can get outdated. My goal is to have everything as reproducible as possible.
For NixOS machines, everything is managed by NixOS modules and home-manager.
As for non NixOS machines, I use combination of home-manager and chezmoi.
I use chezmoi mainly to configure the system using chezmoi scripts while home-manager to configure applications in the userspace.
- Flake Parts to manage
flakesoutputs. - home-manager to manage my home directory.
- sops-nix is used to encrypt/decrypt my secrets safely.
- Disko to declaratively manage disks.
- NUR for packages not available in the official NixOS repository.
- nixvim to create reproducible Neovim package.
The structure of this repository is highly opinionated. I shamelessly took the pieces I believe is the best from people and modified it.
- ./flake.nix is the entrypoint for
nixos-rebuildandhome-managercommands. - ./flake.lock is the lock file for this flake, updated daily by budimanjojo-bot powered by Renovate.
- ./flakeLib.nix is where I put helper functions used in
flake.nixfile, this is where the magic happens. - ./lib is where I put helper functions used in NixOS and
home-managermodules. - ./packages is where I put my own packages, updated daily by budimanjojo-bot powered by nvfetcher.
- ./overlays contains overlays for packages used in NixOS and
home-managermodules. - ./shell.nix accessible via
nix developto have tools needed available in current shell. - ./system contains my own NixOS modules and per machine system configurations.
- ./home contains my own
home-managermodules and per user configurations. - ./chezmoi contains files used by
chezmoi.
- Clone this repository in a directory inside the machine.
- Edit
./flake.nixfile and add the new machine specs insideoutputs.flake.nixosConfigurationsschema. - Create
./system/hosts/<hostname>/default.nixfor the new machine and configure it. - Create
./home/budiman/hosts/<hostname>.nixfor the new machine and configure it. - Run
git add .thensudo nixos-rebuild switch --flake .#<hostname>and I'm done.
- Install Nix and enable Flake.
- Edit
./flake.nixfile and add the new machine specs insideoutputs.flake.homeConfigurationsschema. - Create
./home/budiman/hosts/<hostname>.nixfor the new machine and configure it. - Run
git add .thennix run nixpkgs.home-manager -c home-manager switch --flake .#budiman@<hostname>and I'm done.
My neovim setup is packaged with nixvim and exposed at legacyPackages.neovim from this flake.
You can run it directly if you have nix installed and flakes enabled with: nix run github:budimanjojo/nix-config#neovim.
Fish is enabled using the home-manager module.
On my non NixOS machines, fish is patched to work without system intervention and I have a chezmoi script that will switch the default shell for the user to ~/.nix-profile/bin/fish.
These are the plugins I'm using:
Starship requires powerline fonts to work.
I suggest Nerd-fonts.
The font in the screenshot above is using UbuntuMono Nerd Font Regular.
Unifont is also for some glyphs to work.
On non NixOS machines, home-manager will install these fonts automatically.
I use Super key for Sway/i3.
hjkl keys are mapped to left, down, up, right arrow keys.
S means Super key, [0-9] means number key 0 to 9.
| Keypress | Description |
|---|---|
S+t |
Open terminal app |
S+w |
Open browser |
S+f |
Open file manager |
S+grave |
Open rofi apps menu |
S+Esc |
Open rofi apps menu |
S+F4 |
Close window |
S+k |
Change focus to window above |
S+j |
Change focus to window below |
S+h |
Change focus to left side window |
S+l |
Change focus to right side window |
S+Shift+k |
Move focused window up |
S+Shift+j |
Move focused window down |
S+Shift+h |
Move focused window left |
S+Shift+l |
Move focused window right |
S+Ctrl+h |
Split opened windows horizontally |
S+Ctrl+v |
Split opened windows vertically |
S+Ctrl+q |
Toggle opened windows split |
S+Tab |
Go to next workspace |
S+Shift+Tab |
Go to previous workspace |
S+Ctrl+t |
Toggle window border on/off |
S+Ctrl+g |
Toggle gaps on/off |
S+Ctrl+f |
Toggle fullscreen mode on/off |
S+Ctrl+s |
Change container layout to stacking |
S+Ctrl+w |
Change container layout to tabbed |
S+Ctrl+e |
Toggle split layout to horizontal/vertical |
S+Shift+Space |
Toggle window floating on/off |
S+Space |
Swap focus between tiling/floating window |
S+Shift+p |
Move current focused window to scratchpad |
S+p |
Show/hide scratchpad window |
S+[0-9] |
Go to workspace #[0-9] |
S+Shift+[0-9] |
Move focused window to workspace #[0-9] |
S+Shift+r |
Go to resize container mode |
S+Shift+g |
Go to resize gaps mode |
S+Ctrl+Del |
Go to logout mode |
Printscreen |
Go to screenshot mode |
S+Shift+c |
Reload configuration |
S+Shift+e |
Exit |
The prefix key is Space.
You can override this using your custom .vimrc.local file.
<Leader> means you need to press prefix key first.
If they are not in the table, that means it's using the default Vim keybindings.
| Mode | Keypress | Description |
|---|---|---|
Normal |
<Leader>w |
Save file |
Normal |
<Leader>x |
Save file and quit |
Normal |
<Leader>qq |
Quit |
Normal |
<Leader>qa |
Force quit without saving |
Normal |
<Leader>wq |
Save file and quit |
Normal |
Y |
Yank from cursor to end of file |
Normal |
Control+k |
Move to the split window above |
Normal |
Control+j |
Move to the split window below |
Normal |
Control+h |
Move to the left split window |
Normal |
Control+l |
Move to the right split window |
Normal |
<Leader>s |
Open new horizontal split window |
Normal |
<Leader>v |
Open new vertical split window |
Insert |
Control+k |
Move cursor Up |
Insert |
Control+j |
Move cursor Down |
Insert |
Control+h |
Move cursor Left |
Insert |
Control+l |
Move cursor Right |
Normal |
<Leader>tn |
Open new tab |
Normal |
<Leader>td |
Close tab |
Normal |
<Leader>th |
Go to previous tab |
Normal |
<Leader>tl |
Go to next tab |
Normal |
<Leader>te |
Open new tab with current buffer's path |
Normal |
<Leader>hh |
Jump back to older cursor position |
Normal |
<Leader>ll |
Jump forward to newer cursor position |
Normal/Visual |
Tab |
Indent current line or selection |
Normal/Visual |
Shift+Tab |
De-indent current line or selection |
Normal |
<Leader>lr |
Restart LSP client |
Normal |
<Leader>fz |
Open Picker |
Normal |
<Leader>ff |
Open Picker to find files |
Normal |
<Leader>fg |
Open Picker to live grep |
Normal |
<Leader>fc |
Open Picker to see git log |
Normal |
<Leader>fb |
Open Picker to see opened buffers |
Normal |
<Leader>fh |
Open Picker to find help |
Normal |
<Leader>fk |
Open Picker to see keymappings |
Normal |
<Leader>fe |
Open Picker to find lsp diagnostics |
Normal |
<Leader>xx |
Toggle Trouble |
Normal |
<Leader>xr |
Toggle Trouble to find lsp references |
Normal |
Control+f |
Toggle oil.nvim file manager |
Normal/Term |
Control+t |
Toggle floating terminal |
Normal |
<Leader>pp |
Format buffer with null-ls |
Visual |
<Leader>pp |
Range format buffer with null-ls |
Normal |
rn |
Do LSP buffer rename |
Normal |
gd |
Do LSP buffer get definition |
Normal |
gD |
Do LSP buffer get declaration |
Normal |
gh |
Do LSP buffer get hover |
Normal |
gr |
Do LSP buffer get references |
Normal |
gi |
Do LSP buffer get implementation |
I override the default keybindings for Tmux to be more reasonable.
Prefix key is Alt+a for local session and Alt+z for nested session.
<prefix> means you need to press prefix key first, <repeat> means you don't need to press prefix key again after triggering it (I use unconventional way instead of -r flag so it will stay forever unless I press Esc key), <copy-mode> means you must be in copy-mode first.
The table below lists all the keybindings set.
| Keypress | Description |
|---|---|
<prefix><repeat>h |
Move selection to left pane |
<prefix><repeat>j |
Move selection to pane below |
<prefix><repeat>k |
Move selection to pane above |
<prefix><repeat>l |
Move selection to right pane |
<prefix><repeat>H |
Resize current pane to the left by 2 columns |
<prefix><repeat>J |
Resize current pane downwards by 2 lines |
<prefix><repeat>K |
Resize current pane upwards by 2 lines |
<prefix><repeat>L |
Resize current pane to the right by 2 columns |
<prefix><repeat>Alt+n |
Move selection to next window |
<prefix><repeat>Alt+p |
Move selection to previous window |
<prefix><repeat>> |
Swap to next pane |
<prefix><repeat>< |
Swap to previous pane |
<prefix>Alt+s |
Split window horizontally with current pane path |
<prefix>Alt+v |
Split window vertically with current pane path |
<prefix>c |
Open a new window with current pane path |
<prefix>Esc |
Exit prefix key table |
<prefix>Space |
Exit prefix key table |
<prefix>a |
Enter copy mode |
<prefix>: |
Enter tmux command prompt |
<prefix>x |
Close current pane |
<prefix>X |
Close current window |
<copy-mode>b |
Move cursor to word beginning |
<copy-mode>e |
Move cursor to word ending |
<copy-mode>Home |
Move cursor to start of line |
<copy-mode>0 |
Move cursor to start of line |
<copy-mode>End |
Move cursor to end of line |
<copy-mode>$ |
Move cursor to end of line |
<copy-mode>PageUp |
Move cursor one page up |
<copy-mode>PageDn |
Move cursor one page down |
<copy-mode>v |
Begin selection |
<copy-mode>Space |
Begin selection |
<copy-mode>V |
Select a line |
<copy-mode>Alt+v |
Toggle box selection |
<copy-mode>y |
Copy selection to clipboard |
<copy-mode>Y |
Copy from cursor to end of line to clipboard |
<copy-mode>Esc |
Exit copy mode |
<copy-mode>q |
Exit copy mode |
I'm migrating my tmux to Zellij.
I mimicked my tmux configuration to work in zellij but not everything works the same.
Prefix key is Alt+a, I use the "switch to normal mode" in zellij to achieve this.
<normal> means you need to be in normal mode, <pane> means pane mode, and so on.
The table below lists all the keybindings set.
| Keypress | Description |
|---|---|
<locked>Alt+a |
Swith to normal mode (act like prefix key in tmux) |
<normal>Alt+s |
Create new horizontal split window and back to locked mode |
<normal>Alt+v |
Create new vertical split window and back to locked mode |
<normal>r |
Switch to renametab mode |
<normal>h |
Move selection to left pane |
<normal>j |
Move selection to pane below |
<normal>k |
Move selection to pane above |
<normal>l |
Move selection to right pane |
<normal>> |
Move pane around |
<normal>H |
Resize current pane upwards |
<normal>J |
Resize current pane downwards |
<normal>H |
Resize current pane to the left |
<normal>L |
Resize current pane to the right |
<normal>Alt+n |
Go to next window |
<normal>Alt+p |
Go to previous window |
<normal>c |
Open new tab and back to locked mode |
<normal>x |
Close current pane and back to locked mode |
<normal>a |
Open pane with $EDITOR and back to locked mode |
<normal>Esc/' '/"\n" |
Switch back to locked mode |
<renametab>Alt+a |
Switch to normal mode |
<renametab>"\n" |
Switch to locked mode |
<renametab>Esc |
Confirm tab name and back to locked mode |
I wrote most of the codes by myself, but there are a lot of stuffs inspired by these repositories.
- MatthiasBenaets/nixos-config for the awesome YouTube video introducing NixOS to me.
- viperML/dotfiles for answering stupid questions on Discord.
- bjw-s/nix-config for being inspiration for my repo structure.
- truxnell/nix-config for being inspiration for my flakeLib functions.




