Code Monkey home page Code Monkey logo

nix-config's Introduction

❄️ Ryan4Yin's Nix Config ❄️

Stargazers

This repository is home to the nix code that builds my systems:

  1. NixOS Desktops: NixOS with home-manager, i3, hyprland, agenix, etc.
  2. macOS Desktops: nix-darwin with home-manager, zsh, kitty, etc. Share the same home-manager configuration with NixOS Desktops.
  3. NixOS Servers: virtual machines running on Proxmox, with various services, such as homepage, prometheus, grafana, etc.

See ./hosts for details of each host.

Why NixOS & Flakes?

Nix allows for easy-to-manage, collaborative, reproducible deployments. This means that once something is setup and configured once, it works (almost) forever. If someone else shares their configuration, anyone else can just use it (if you really understand what you're copying/refering now).

As for Flakes, refer to Introduction to Flakes - NixOS & Nix Flakes Book

Want to know NixOS & Flaks in detail? Looking for a beginner-friendly tutorial or best practices? You don't have to go through the pain I've experienced again! Check out my NixOS & Nix Flakes Book - 🛠️ ❤️ An unofficial & opinionated 📖 for beginners!

If you're using macOS, check out ryan4yin/nix-darwin-kickstarter for a quick start.

Components

NixOS(Wayland) NixOS(Xorg)
Window Manager Hyprland i3
Terminal Emulator Zellij + Kitty Zellij + Kitty
Bar Waybar polybar
Application Launcher anyrun rofi
Notification Daemon Mako Dunst
Display Manager GDM GDM
Color Scheme Catppuccin Catppuccin
network management tool NetworkManager NetworkManager
Input method framework Fcitx5 Fcitx5
System resource monitor Btop Btop
File Manager Yazi + thunar Yazi + thunar
Shell Nushell + Starship Nushell + Starship
Music Player mpd, ncmpcpp, mpc, Netease-cloud-music-gtk Netease-cloud-music-gtk
Media Player mpv mpv
Text Editor Neovim + DoomEmacs Neovim + DoomEmacs
Fonts Nerd fonts Nerd fonts
Image Viewer imv imv
Screenshot Software flameshot + grim flameshot
Screen Recording OBS OBS
Filesystem & Encryption tmpfs on /, Btrfs subvolumes on a LUKS crypted partition for persistent, unlock via passphrase tmpfs on /, Btrfs subvolumes on a LUKS crypted partition for persistent, unlock via passphrase
Secure Boot lanzaboote lanzaboote

Wallpapers: https://github.com/ryan4yin/wallpapers

Hyprland + AstroNvim + DoomEmacs

I3 + AstroNvim

Neovim

See ./home/base/desktop/editors/neovim/ for details.

Emacs

See ./home/base/desktop/editors/emacs/ for details.

Secrets Management

See ./secrets for details.

How to Deploy this Flake?

🔴 IMPORTANT: You should NOT deploy this flake directly on your machine:exclamation: It will not succeed. this flake contains my hardware configuration(such as hardware-configuration.nix, cifs-mount.nix, Nvidia Support, etc.) which is not suitable for your hardware, and my private secrets repository ryan4yin/nix-secrets that only I have access to. You may use this repo as a reference to build your own configuration.

For NixOS:

To deploy this flake from NixOS's official ISO image(purest installation method), please refer to ./nixos-installer/

Need to restart the machine when switching between wayland and xorg.

# deploy one of the configuration based on the hostname
sudo nixos-rebuild switch --flake .#ai_i3
# sudo nixos-rebuild switch --flake .#ai_hyprland

# deploy via `just`(a command runner with similar syntax to make) & Justfile
just i3    # deploy my pc with i3 window manager
# just hypr  # deploy my pc with hyprland compositor

# or we can deploy with details
just i3 debug
# just hypr-debug

For macOS:

# If you are deploying for the first time,
# 1. install nix & homebrew manually.
# 2. prepare the deployment environment with essential packages available
nix-shell -p just nushell
# 3. comment home-manager's code in lib/macosSystem.nix to speed up the first deplyment.
# 4. comment out the proxy settings in scripts/darwin_set_proxy.py if the proxy is not ready yet.

# 4. deploy harmonica's configuration(macOS Intel)
just ha

# deploy fern's configuration(Apple Silicon)
just fe

# deploy with details
just ha debug
# just fe debug

What y'all will need when Nix drives you to drink. (copy from hlissner's dotfiles, it really matches my feelings when I first started using NixOS...)

How to create & managage VM from this flake?

use aquamarine as an example, we can create a virtual machine with the following command:

# 1. generate a proxmox vma image file
nom build .#aquamarine  # `nom`(nix-output-monitor) can be replaced by the standard command `nix`

# 2. upload the genereated image to proxmox server's backup directory `/var/lib/vz/dump`
#    please replace the vma file name with the one you generated in step 1.
rsync -avz --progress --copy-links result root@um560:/var/lib/vz/dump/vzdump-qemu-aquamarine.vma.zst

# 3. the image we uploaded will be listed in proxmox web ui's this page: [storage 'local'] -> [backups], we can restore a vm from it via the web ui now.

Once the virtual machine aquamarine is created, we can deploy updates to it with the following commands:

# 1. add the ssh key to ssh-agent
ssh-add /etc/agenix/ssh-key-romantic

# 2. deploy the configuration to all the remote host with tag `@dist-build`
# using the ssh key we added in step 1
colmena apply --on '@dist-build' --show-trace

If you're not familiar with remote deployment, please read this tutorial first: Remote Deployment - NixOS & Flakes Book

References

Other dotfiles that inspired me:

nix-config's People

Contributors

ryan4yin avatar dataeraserc avatar we-do-it-lu avatar balssh avatar dependabot[bot] avatar sxyazi avatar zhpjy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.