Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/appaquet/dotfiles

My NixOS + nix-darwin + home manager dotfiles
https://github.com/appaquet/dotfiles

Last synced: 13 days ago
JSON representation

My NixOS + nix-darwin + home manager dotfiles

Awesome Lists containing this project

README

        

# Nixified dotfiles

## Initial setup on NixOS

1. Setup NixOS using the installer.

1. Once installed, edit `/etc/nixos/configuration.nix` and rebuild:
* Enable sshd
* Enable flakes: `nix.settings.experimental-features = [ "flakes" ];`

1. SSH to the machine.

1. Clone this repo recursively (need to setup ssh keys, use a nix-shell with git and neovim).

1. Setup a GitHub personal access token in `~/.config/nix/nix.conf` (see [doc](https://nix.dev/manual/nix/2.18/command-ref/conf-file#conf-access-tokens))

```conf
access-tokens = github.com:
```

1. Setup home-manager & activate it.

1. Copy `/etc/nixos/*.nix` to this repo to compare & adapt.

1. Rebuild nixos & switch using this flake.

1. Enable vscode server patcher (see )
1. Enable service: `systemctl --user enable --now auto-fix-vscode-server.service` (it's safe to ignore warning)
1. To prevent GC: `ln -sfT /run/current-system/etc/systemd/user/auto-fix-vscode-server.service ~/.config/systemd/user/auto-fix-vscode-server.service`

## Initial setup on MacOS

1. Download nix installer & run it with multi-user mode enabled: `curl -L https://nixos.org/nix/install | sh -s -- --daemon`

1. Enable flakes: `mkdir -p ~/.config/nix/ && echo 'experimental-features = nix-command flakes fetch-closure' > ~/.config/nix/nix.conf`

1. Clone this repo recursively.

1. Setup home-manager & activate it.

1. Install [HomeBrew](https://brew.sh/).

1. Setup nix-darwin & activate it.

## Initial setup on Non-NixOS Linux

1. Download nix installer & run it with multi-user mode enabled: `curl -L https://nixos.org/nix/install | sh -s -- --daemon`

1. Enable flakes: `mkdir -p ~/.config/nix/ && echo 'experimental-features = nix-command flakes fetch-closure' > ~/.config/nix/nix.conf`

1. On Linux, configure nix by adding to `/etc/nix/nix.conf`.
No need to do it on Darwin since we already do it nix-darwin (see [configuration.nix](./darwin/mbpapp/configuration.nix))

```conf
keep-outputs = true
keep-derivations = true
auto-optimise-store = true

# allow use of cached builds, require fast internet
builders-use-substitutes = true

experimental-features = nix-command flakes fetch-closure
```

1. Build `./x home build` and activate `./x home switch`

1. Activate shell by adding `/home/appaquet/.nix-profile/bin/fish` to `/etc/shells`
and running `chsh -s /home/appaquet/.nix-profile/bin/fish`

## Troubleshooting

1. It seems that when switching to newer fish, the paths weren't properly set.
On top of that, it may be shadowed by a global fish path too.
Reset fish paths with:

```bash
set -ge fish_user_paths
set -Ua fish_user_paths /nix/var/nix/profiles/default/bin
set -Ua fish_user_paths /home/appaquet/.nix-profile/bin
set -Ua fish_user_paths /home/appaquet/.local/utils/
```

## Cheat sheets

## Nix

* Run a uninstalled package: `nix run nixpkgs#cowsay hello world`
* Run a uninstalled package, with fuzzy finding: `nix run nixpkgs#(fzf-nix)`, or `nr`
* Start a shell with a package: `nix shell nixpkgs#ripgrep`
* Start a shell with a package, with fuzzy finding: `nix shell nixpkgs#(fzf-nix)`, or `ns`

### Fish

* Foreign env is used to source `~/.profile`. Any local variables can be set there.
* Paths: fish uses `fish_user_paths` to define paths and can be persisted when using "universal variables" (set with `-U`).
* To add a path: `fish_add_path /some/new/path` or `set -Ua fish_user_paths /some/new/path`
* To list current paths: `echo $fish_user_paths | tr " " "\n" | nl`
* To remove a path: `set --erase fish_user_paths[NUMBER AS LISTED STARTING AT 1]`

* Shortcuts
* See for all shortcuts
* With no input `` or `` to jump to previous directory in history
* With input `` or `` to between words
* With input `w` to delete previous word
* With input `e` or `v` to open input in editor (doesn't work on MacOS)
* `n`: fzf nix packages
* `g`: fzf ripgrep
* `f`: fzf fd (find file)
* `p`: fzf processes
* `l`: fzf git log
* `s`: fzf git status

### Neovim

#### Mapping

* General
* `` is configured to `\` (backslash)
* ` 1 through 9` to switch between opened buffers
* `]` to switch to next buffer
* `[` to switch to previous buffer
* `s` to save current buffer
* `x` to save and then execute current buffer (as long as it's chmod +x)
* `z` to execute current visual selection in a shell
* `r` to save current buffer and then execute `rsync.sh` in working dir
* `w` to close the current buffer by trying not to messup the layout

* `o` to close all buffers except the current one
* `q` to quit vim
* `` to switch between tab and spaces
* `e` to toggle file etree
* `p` fuzzy finding file
* `l` fuzzy finding buffers and history
* `f` riggrep search
* `o` go back to previous cursor
* `i` go forward to next cursor
* `m` to toggle mouse support (useful to allow select + copy)
* `y` to yank to clipboard using [bin/pbcopy](bin/pbcopy) util
* `p` to paste from clipboard using [bin/pbpaste](bin/pbpaste) util

* Code / LSP
* `gD` goto declaration
* `gd` goto definition
* `gi` goto implementation
* `K` hover info
* `rn` rename symbol
* `cc` comment
* `cu` uncomment

* Nvim tree
* In tree
* `g?` to show help
* `]` to CD into directory
* `-` go up one directory
* `v` Open in vertical split
* `x` Open in horizontal split
* `I` Toggle hidden files
* `r` Rename file
* `d` Delete file
* `a` Add file or directory if it ends with `/`
* `c`, `x`, `v` to copy, cut, paste files
* `f` to find file, `F` to clear
* `q` to close tree
* `E` to expand all, `W` to collapse
* `e` to toggle file tree

* Commands
* `E `: open a new buffer for a new file in current buffer's directory
* `Delete`: delete current buffer's file

### tmux

* Shortcuts
* See for all shortcuts
* `b e` to toggle synchronized panes
* `b m` to toggle mouse support (useful to allow select + copy)
* `b l` to navigate to next window
* `b h` to navigate to prev window
* `b Tab` to navigate to last window
* `b ` to navigate to last window
* `b ` to resize pane
* `b r` to reload config
* `b ` to get into copy mode
* `v` for selection
* `ctrl-v` to switch between between block and line selection
* `y` to yank
* `H` and `L` start line / end line
* `b q` to show pane ids, then `:swap-pane -s X -t Y` to swap

* Plugins (via integrated .tmux.conf's tpm)
* [tmux-resurrect](https://github.com/tmux-plugins/tmux-resurrect)
* `b s` to save current layout
* `b r` to ressurect last saved layout

## Resources

*
*
*