Skip to content

wochap/nix-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal NixOS configuration

NixOS and home-manager config files are merged.

DWL

Installaion

Install NixOS

  1. Follow the manual and install NixOS with any desktop environment and reboot.

  2. Update the generated nixos configuration in /etc/nixos/configuration.nix.

    The new configuration must have: user configuration, flakes enabled, cachix (optional), git, git-crypt, internet setup, firewall disabled

    Check the configuration.nix example

Install host config

Reboot into NixOS, login with the user you created

  1. Connect to internet

    # The following commands will work if you enabled `networking.networkmanager.enable = true;`
    $ nmtui
    $ ping google.com
    

    If ping google.com doesn't work, try updating your DNS

    $ vim /etc/resolv.conf
    # add `nameserver 8.8.8.8` to `/etc/resolv.conf`
    
  2. 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-info
    

    On the current/new machine, update nix.settings.substituters config, add http://192.168.x.x:8080, then restart

  3. Clone this repository into /home/<username>/.config/nix-config

    $ git clone https://github.com/wochap/nix-config.git ~/.config/nix-config
    
  4. Rebuild nixos with the host's specific config, for example, heres's a rebuild for my gdesktop

    WARNING: First nixos-rebuild with 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-specialisation
    

    Reboot 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 the home-manager-<username>.service.

  5. Set password for new user <username> if you haven't

    # for example
    $ passwd gean
    

Post install

  1. Install ssh keys

    Copy .ssh backup 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/

  2. Unlock secrets folder

    Copy git-crypt-key backup

    $ cd /home/<username>/.config/nix-config
    $ git-crypt unlock /path/to/git-crypt-key
    
  3. Install gpg keys

    $ gpg --import private.key
    
  4. Enable autologin (optional)

    $ sudo touch /etc/security/autologin.conf
  5. Setup Syncthing (http://localhost:8384)

  6. Setup desktop wallpaper (optional)

    $ swww img ~/Pictures/backgrounds/<IMAGE_NAME>
    
  7. Setup Neovim configuration

  8. Setup qt look and feel Open Qt5 Settings and update theme and icons

    • icon theme: Tela-catppuccin_mocha-dark
    • color scheme: Catppuccin-Mocha-Mauve
    • style: Lightly
    • change font size to 10
  9. Setup betterdiscord (optional)

    $ betterdiscordctl install
    

    enable theme from discord > betterdiscordctl settings

  10. Enable WebRTC PipeWire support in chrome (wayland only)

    Go to chrome://flags/ and enable WebRTC PipeWire support

  11. Sync vscode, firefox, chrome (optional)

  12. Setup mail

    Generate App passwords in Google Account settings Copy App password (16 digits) to secrets/mail/

  13. Setup calendar

    A browser should open automatically asking for google credentials, otherwise run:

    $ vdirsyncer discover
    $ touch ~/.config/remind/remind.rem
  14. Waydroid (optional)

  15. Flatpak (optional)

  16. 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

  • Chrome like apps with blank screen or vanishing text on scroll

    Clear GPUCache, in ~/.config/google-chrome/ShaderCache

    source: electron/electron#40366 source: https://discussion.fedoraproject.org/t/chromium-based-browsers-display-garbled-web-pages-after-mesa-is-updated/83438

  • Slow zsh startup

    # print all zsh scripts that are being loaded
    $ exec -l zsh --sourcetrace
    
  • Fix Virtual Machine Manager network default is not active error

    $ sudo virsh net-start default
    $ sudo virsh net-autostart default
    
  • Fix bootloader

  • Read and write NTFS partitions

    disable fast startup in windows

  • Search a package version in nixpkgs

  • 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
    
  • Bluetooth sound glitches

  • Clear /nix/store

    $ nix-collect-garbage -d
    $ sudo nix-collect-garbage -d
    
  • Delete nixos system profile

    # delete everything on
    $ /nix/var/nix/profiles/system-profiles/*
    
    # Clear store and rebuild
    
  • Check packages size

    $ 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

    E8E4 is 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

To learn

Rice resources

Others