Skip to content
mantas6Public

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

3,500 Commits

Folders and files

Repository files navigation

dots

Personal dotfiles managing configuration for NixOS Linux and macOS.

Setup

Clone the repo and link

git clone https://github.com/mantas6/dots.git "$HOME/.dots"
cd "$HOME/.dots"
./bin/stw

If stow fails, remove conflicting files (preferably to trash) and run again. Pay close attention to the output to make sure that the links that it creates make sense.

Create NixOS ISO

nix build .#nixosConfigurations.iso.config.system.build.isoImage

The ISO image is placed in result/iso/.

Install NixOS

Normal setup:

nix run nixpkgs#nixos-anywhere -- \
    --flake ".#__host__" \
    --generate-hardware-config nixos-generate-config nix/hosts/__host__/_hardware.nix \
    --target-host "root@__host__"

Encrypted setup:

nix run nixpkgs#nixos-anywhere -- \
    --flake ".#__host__" \
    --disk-encryption-keys /tmp/secret.key <(pass "hosts/__host__") \
    --generate-hardware-config nixos-generate-config nix/hosts/__host__/_hardware.nix \
    --target-host "root@__host__"

Deploy NixOS on the network

nixos-rebuild switch --flake .#__host__ --target-host __host__ --ask-sudo-password

Rescue

Upgrade outdated dotfiles

Run when need to migrate old version of dotfiles structure

cd "$HOME/.dots"
./bin/stw -D
git pull
./bin/stw

Reinstall bootloader for NixOS

sudo nixos-rebuild --install-bootloader switch --flake .

Reset Neovim state

trash "$HOME/.local/share/nvim" "$HOME/.local/state/nvim" "$HOME/.cache/nvim"

macOS

Setup

To initialize new environment run:

git clone https://github.com/mantas6/dots.git "$HOME/.dots"
cd "$HOME/.dots"
./bin/rebuild-macos-env brew

Restart the shell and run stow:

cd "$HOME/.dots"
./bin/stw

Run the script again to continue setup:

rebuild-macos-env init

Brew

Update all packages:

brew bundle upgrade --global

Clean up removed packages:

brew bundle cleanup --global

Misc

Formatting

Format all Nix files:

nix fmt .

Format all Lua files:

find . -name '*.lua' -exec stylua {} +

Format all shell scripts:

shfmt -w $(shfmt -f .)

Stress testing

Run stress test on the CPU:

nix run nixpkgs#stress-ng -- -c0

Monitor temperatures:

nix run nixpkgs#s-tui

Secrets management

Edit/create a secret:

agenix -e nix/_lib/secrets/__name__.age

After saving update the secrets.nix

Rekey secrets

agenix --rekey

Get host key

ssh-keyscan __host__

Battery charge thresholds

On laptops with hardware-battery TLP keeps the battery between 40% and 60% to prolong its life.

Charge to 100% once (the configured thresholds return on reboot or with sudo tlp setcharge):

sudo tlp fullcharge

Restore the configured thresholds immediately:

sudo tlp setcharge

Check the current thresholds:

sudo tlp-stat -b

Troubleshooting auto-upgrade

Check that automatic system upgrades run successfully.

Force an automatic system upgrade:

systemctl start nixos-upgrade

Check the upgrade log:

systemctl status nixos-upgrade.service

Or, to see the full log:

journalctl -u nixos-upgrade.service

To see the status of the upgrade timer:

systemctl status nixos-upgrade.timer

Chatterbox TTS

Hosts with containers-chatterbox (currently lm) serve Chatterbox Turbo text-to-speech on port 8004 with an OpenAI-compatible API. The container starts on the first connection and stops after 15 minutes without traffic, so the first request after idle takes a while (tens of seconds, several minutes on the very first run while the model downloads). Use a generous client timeout.

Generate speech with the default female voice:

curl -X POST http://lm:8004/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"chatterbox-turbo","input":"Hello from lm. [chuckle]","voice":"Emily.wav","response_format":"mp3"}' \
  -o out.mp3

Turbo supports tags like [laugh], [chuckle], [sigh] and [cough] in the text. response_format can be wav, mp3 or opus.

List available voices:

curl http://lm:8004/v1/audio/voices

To clone a voice, put a wav clip longer than 5 seconds into /var/lib/chatterbox/reference_audio/ on the host and pass its file name as voice.

The web UI is at http://lm:8004/.

Check the state of the service and watch it start:

systemctl status chatterbox-proxy.socket docker-chatterbox
journalctl -fu docker-chatterbox

Stop it manually before the idle timeout:

sudo systemctl stop chatterbox-proxy docker-chatterbox

File drop

Hosts with services-rustypaste (currently l4) run rustypaste at http://pb/ on the LAN. There is no auth; uploads get a random name, are not listed anywhere and are deleted after 24 hours. The page at http://pb/ takes drag and drop.

Upload from a shell; the response body is the URL of the file:

curl -F file=@example.txt http://pb

Expire sooner, or serve a file only once:

curl -F file=@example.txt -H 'expire: 1h' http://pb
curl -F oneshot=@example.txt http://pb

Files live in /var/lib/rustypaste on the host, with the expiry timestamp appended to the file name.

Useful commands

Trigger Enter key press on another tmux window:

tmux send-keys -t ":llm" C-m

Serve the current directory over HTTP with caddy:

nix run nixpkgs#caddy -- file-server --listen :8080 --browse

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Used by

Contributors

Languages