nix-config
nix-config copied to clipboard
Personal NixOS configuration
Personal NixOS configuration
NixOS and home-manager config files are merged.
DWL

Installaion
Install NixOS
-
Follow the manual and install NixOS with any desktop environment and reboot.
-
Update the generated nixos configuration in
/etc/nixos/configuration.nix.The new configuration must have: user configuration,
flakesenabled,cachix(optional),git,git-crypt, internet setup,firewalldisabledCheck the configuration.nix example
Install host config
Reboot into NixOS, login with the user you created
-
Connect to internet
# The following commands will work if you enabled `networking.networkmanager.enable = true;` $ nmtui $ ping google.comIf
ping google.comdoesn't work, try updating your DNS$ vim /etc/resolv.conf # add `nameserver 8.8.8.8` to `/etc/resolv.conf` -
Use local cachix, if you have 2 machines using the same nix config/channels (optional)
# Run on another machine, with nixos installed $ nix-serve -p 8080 # On current/new machine, test $ curl http://192.168.x.x:8080/nix-cache-infoOn the current/new machine, update
nix.settings.substitutersconfig, addhttp://192.168.x.x:8080, then restart -
Clone this repository into
/home/<username>/.config/nix-config$ git clone https://github.com/wochap/nix-config.git ~/.config/nix-config -
Rebuild nixos with the host's specific config, for example, heres's a rebuild for my
gdesktopWARNING: First
nixos-rebuildwith device config can take several hours, maybe you want to disable some modules# Go to nix-config folder $ cd /home/<username>/.config/nix-config $ nixos-rebuild boot --flake .#gdesktop # or if you want to switch to a specialisation # $ nixos-rebuild switch --flake .#gdesktop --specialisation hyprland-specialisationReboot so changes take effect
NOTE: If you encounter an error related to
home-manager, it is likely due to a file collision, and you will need to remove a file. You can identify which files are in conflict with the following command:systemctl status home-manager-<username>.service. After resolving all the collisions, you can restart thehome-manager-<username>.service. -
Set password for new user
<username>if you haven't# for example $ passwd gean
Post install
-
Install ssh keys
Copy
.sshbackup folder to/home/<username>/.ssh$ chmod 600 ~/.ssh/* $ ssh-add <PATH_TO_PRIVATE_KEY>https://www.freecodecamp.org/news/how-to-manage-multiple-ssh-keys/
-
Unlock secrets folder
Copy
git-crypt-keybackup$ cd /home/<username>/.config/nix-config $ git-crypt unlock /path/to/git-crypt-key -
Install gpg keys
$ gpg --import private.key -
Enable autologin (optional)
$ sudo touch /etc/security/autologin.conf -
Setup Syncthing (http://localhost:8384)
-
Setup desktop wallpaper (optional)
$ swww img ~/Pictures/backgrounds/<IMAGE_NAME> -
Setup Neovim configuration
-
Setup qt look and feel Open
Qt5 Settingsand update theme and icons- icon theme: Tela-catppuccin_mocha-dark
- color scheme: Catppuccin-Mocha-Mauve
- style: Lightly
- change font size to 10
-
Setup betterdiscord (optional)
$ betterdiscordctl installenable theme from discord > betterdiscordctl settings
-
Enable WebRTC PipeWire support in chrome (wayland only)
Go to chrome://flags/ and enable
WebRTC PipeWire support -
Sync
vscode,firefox,chrome(optional) -
Setup mail
Generate App passwords in Google Account settings Copy App password (16 digits) to secrets/mail/<EMAIL>
-
Setup calendar
A browser should open automatically asking for google credentials, otherwise run:
$ vdirsyncer discover $ touch ~/.config/remind/remind.rem -
Waydroid (optional)
-
Flatpak (optional)
-
Setup steam (optional)
Run steam, login, setup proton.
Upgrating NixOS
Update inputs on flake.nix, then:
$ cd /home/<username>/.config/nix-config
$ nix flake update --recreate-lock-file
$ sudo nixos-rebuild boot --flake .#gdesktop
Development Workflow
-
Setup a project with nix-direnv
$ nix flake new -t github:nix-community/nix-direnv ./ $ direnv allow # update flake.nix
Troubleshooting
-
Slow zsh startup
# print all zsh scripts that are being loaded $ exec -l zsh --sourcetrace -
Fix Virtual Machine Manager
network default is not activeerror$ sudo virsh net-start default $ sudo virsh net-autostart default -
Fix bootloader
-
Read and write NTFS partitions
disable fast startup in windows
-
Generate Nix fetcher calls from repository URLs
$ nurl https://github.com/nix-community/patsh v0.2.0 2>/dev/null -
Inspect systemctl services
$ systemctl cat --user swayidle.service -
Reload .desktop files
$ nix shell nixpkgs#desktop-file-utils -c update-desktop-database -v ~/.local/share/applications -
No wifi device at startup
$ nmcli r wifi on -
Sync Bluetooth for dualboot Linux and Windows
# on windows, turn off `fast startup`` # mount your disk with windows, then: $ sudo bt-dualboot --sync-all --backup -
No bluetooth device at startup
$ sudo rfkill unblock bluetooth -
Clear /nix/store
$ nix-collect-garbage -d $ sudo nix-collect-garbage -d -
# delete everything on $ /nix/var/nix/profiles/system-profiles/* # Clear store and rebuild -
$ nix path-info -rSh /run/current-system | sort -nk2 -
Firefox doesnt load some websites
Enable DNS over HTTPS
-
Wifi keeps connecting and disconnecting
Disable ipv6 connection.
-
Copy installed icons unicode
E8E4is the unicode.$ echo -ne "\uE8E4" | xclip -selection clipboard $ echo -ne "\ue92a" | wl-copy -
Transform svg icons to png
$ for file in *.svg; do inkscape $file -o ${file%svg}png -h 128; done#!/usr/bin/env bash symlinks=$(find ./ -lname "*.svg"); for file in $symlinks; do linkpath=$(readlink $file); newlinkcontent=${linkpath/svg/png}; newlinkpath=${file/svg/png}; ln -sf $newlinkcontent $newlinkpath; done -
Get key terminal code
$ kitten show_key -m kitty $ kitty +kitten show_key $ showkey -a -
Get key actual name
$ xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }' -
Cannot add google account in gnome > online accounts
In gmail settings, enable IMAP
-
Create udev rule
# monitor uevent $ udevadm monitor --property # print devices ids (vendor, product, etc) $ lsusb # get env values $ udevadm info -q all -n /dev/input/eventX # get attr values $ udevadm info -n /dev/input/eventX --attribute-walk
Resources
Inspiration
- https://github.com/phenax/nixos-dotfiles
- https://gitlab.com/dwt1/dotfiles
- https://github.com/JorelAli/nixos
- https://github.com/nrdxp/nixflk/tree/template
- https://github.com/kampka/nix-packages
- https://github.com/sgraf812/.nixpkgs
- https://www.reddit.com/r/NixOS/comments/k7e9sg/newbie_desktop_nixos_setup_for_developer/
To learn
- https://www.secjuice.com/wayland-vs-xorg/
- https://discourse.nixos.org/t/how-to-set-the-xdg-mime-default/3560
- https://awesomeopensource.com/projects/nixos
Rice resources
- https://bennymeg.github.io/ngx-fluent-ui/
- https://fontawesome.com/cheatsheet
- https://fontdrop.info/
- https://coderwall.com/p/dedqca/argb-colors-in-android
- https://github.com/zodd18/Horizon
- https://www.iconfinder.com/search/?q=F028
- https://www.online-toolz.com/tools/text-unicode-entities-convertor.php
- https://www.reddit.com/r/firefox/comments/786dr7/how_do_i_identify_firefox_ui_elements/
Others
- Learn nix
- https://nixos.wiki/wiki/Home_Manager
- https://superuser.com/questions/603528/how-to-get-the-current-monitor-resolution-or-monitor-name-lvds-vga1-etc
- https://nixos.org/manual/nix/stable/#use-as-a-interpreter