Initial NixOS config

This commit is contained in:
2025-11-19 08:42:21 +01:00
commit 61adc10c49
14 changed files with 1645 additions and 0 deletions

21
.gitignore vendored Normal file
View File

@@ -0,0 +1,21 @@
# Hardware configuration is machine-specific
# Uncomment if you don't want to track it
# hardware-configuration.nix
# Flake lock file - comment out if you want reproducible builds
# flake.lock
# Result symlinks from nix build
result
result-*
# Editor files
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store
# Temporary files
*.tmp

151
KEYBINDINGS.md Normal file
View File

@@ -0,0 +1,151 @@
# Hyprland Keybindings Cheat Sheet
## Modifier Key
**SUPER** = Windows/Command Key
---
## 🚀 Launch Applications
| Keybinding | Action |
|------------|--------|
| `SUPER + Return` | Open Terminal (Kitty) |
| `SUPER + D` | Application Launcher (Wofi) |
| `SUPER + E` | File Manager (Thunar) |
---
## 🪟 Window Management
| Keybinding | Action |
|------------|--------|
| `SUPER + Q` | Close Window |
| `SUPER + V` | Toggle Floating |
| `SUPER + F` | Toggle Fullscreen |
| `SUPER + P` | Toggle Pseudo-tiling |
| `SUPER + J` | Toggle Split Direction |
| `SUPER + M` | Exit Hyprland |
---
## 🧭 Navigation
| Keybinding | Action |
|------------|--------|
| `SUPER + ↑` | Focus Up |
| `SUPER + ↓` | Focus Down |
| `SUPER + ←` | Focus Left |
| `SUPER + →` | Focus Right |
---
## 🔢 Workspaces
### Switch Workspace
| Keybinding | Action |
|------------|--------|
| `SUPER + 1` | Workspace 1 |
| `SUPER + 2` | Workspace 2 |
| `SUPER + 3` | Workspace 3 |
| `SUPER + 4` | Workspace 4 |
| `SUPER + 5` | Workspace 5 |
| `SUPER + 6` | Workspace 6 |
| `SUPER + 7` | Workspace 7 |
| `SUPER + 8` | Workspace 8 |
| `SUPER + 9` | Workspace 9 |
| `SUPER + 0` | Workspace 10 |
### Move Window to Workspace
| Keybinding | Action |
|------------|--------|
| `SUPER + SHIFT + 1` | Move to Workspace 1 |
| `SUPER + SHIFT + 2` | Move to Workspace 2 |
| ... | ... |
| `SUPER + SHIFT + 0` | Move to Workspace 10 |
### Scroll Workspaces
| Keybinding | Action |
|------------|--------|
| `SUPER + Mouse Wheel Up` | Next Workspace |
| `SUPER + Mouse Wheel Down` | Previous Workspace |
---
## 🖱️ Mouse Actions
| Keybinding | Action |
|------------|--------|
| `SUPER + Left Click + Drag` | Move Window |
| `SUPER + Right Click + Drag` | Resize Window |
---
## 📸 Screenshots
| Keybinding | Action |
|------------|--------|
| `SUPER + SHIFT + S` | Screenshot (to clipboard) |
| `Print` | Screenshot (save to ~/Pictures) |
---
## 🔊 Media Controls
| Keybinding | Action |
|------------|--------|
| `Volume Up Key` | Increase Volume |
| `Volume Down Key` | Decrease Volume |
| `Mute Key` | Toggle Mute |
| `Mic Mute Key` | Toggle Microphone Mute |
---
## 🔆 Brightness
| Keybinding | Action |
|------------|--------|
| `Brightness Up Key` | Increase Brightness |
| `Brightness Down Key` | Decrease Brightness |
---
## 💡 Tips
1. **First Time?** Press `SUPER + Return` to open a terminal
2. **Find Apps?** Press `SUPER + D` to search for applications
3. **Need Help?** Most settings are in `~/.config/nixos/home/hyprland.nix`
4. **Customize?** Edit the config and run `update` in terminal
5. **Stuck?** Press `SUPER + M` to exit Hyprland
---
## 🛠️ Useful Commands
```bash
# Reload Hyprland config (from terminal)
hyprctl reload
# Check Hyprland info
hyprctl version
# List all windows
hyprctl clients
# View logs
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 1)/hyprland.log
```
---
## 🎨 Customization
To change keybindings, edit: `~/.config/nixos/home/hyprland.nix`
Then rebuild:
```bash
update # or: sudo nixos-rebuild switch --flake ~/.config/nixos#HOSTNAME
```
---
**Pro Tip:** Print this cheat sheet or keep it handy while you learn Hyprland! 📄

234
PROJECT_OVERVIEW.md Normal file
View File

@@ -0,0 +1,234 @@
# NixOS + Hyprland Configuration - Project Overview
## 🎯 What This Is
This is a complete, production-ready NixOS configuration featuring Hyprland as a Wayland compositor. Everything is declared in code, making your entire operating system reproducible from a fresh install with a single command.
## 📦 What You're Getting
### Core System
- **NixOS** with Flakes enabled for reproducible builds
- **Hyprland** - Modern Wayland compositor with beautiful animations
- **Home Manager** - Declarative user environment management
- **Full Wayland Support** with XWayland fallback
### Desktop Environment
- **Waybar** - Highly customizable status bar
- **Wofi** - Application launcher
- **Dunst** - Notification daemon
- **Hyprpaper** - Wallpaper manager
- **SWWW** - Alternative animated wallpaper daemon
### Tools & Applications
- **Kitty & Alacritty** - Modern GPU-accelerated terminals
- **ZSH** with Oh-My-Zsh - Enhanced shell experience
- **Firefox** - Web browser
- **VSCode** - Code editor
- **Thunar** - File manager
- **Modern CLI tools** - ripgrep, fd, bat, eza, fzf, etc.
### System Features
- PipeWire audio system
- NetworkManager for networking
- Bluetooth support
- Printing support (CUPS)
- SSH server
- Graphics drivers setup
## 📁 File Structure Explained
```
nixos-config/
├── flake.nix # Main entry point - defines all inputs and outputs
├── configuration.nix # System-wide settings (bootloader, networking, users)
├── hardware-configuration.nix # Auto-generated hardware-specific settings
├── modules/
│ ├── system.nix # System packages and essential services
│ └── hyprland.nix # Hyprland system-level configuration
├── home/
│ ├── home.nix # User packages and general home-manager config
│ ├── hyprland.nix # Hyprland user settings, keybindings, appearance
│ └── waybar.nix # Status bar configuration and styling
├── bootstrap.sh # Automated setup script for fresh installs
├── README.md # Comprehensive documentation
├── SETUP.md # Quick setup guide
└── KEYBINDINGS.md # Keyboard shortcuts reference
```
## 🚀 Quick Start Workflow
### 1. Push to Your Git Server
```bash
cd nixos-config
git init
git add .
git commit -m "Initial NixOS configuration"
git remote add origin https://git.cribdev.com/YOUR-USERNAME/nixos-config.git
git push -u origin main
```
### 2. Fresh Install (On New Machine)
```bash
# One command to rule them all
nix-shell -p git --run "bash <(curl -s https://git.cribdev.com/raw/YOUR-USERNAME/nixos-config/main/bootstrap.sh)"
```
### 3. What the Bootstrap Does
1. Installs git temporarily
2. Clones your configuration
3. Copies hardware-configuration.nix
4. Prompts for hostname and username
5. Updates configuration files
6. Optionally builds the system immediately
### 4. Result
After reboot, you have a fully configured system with Hyprland!
## 🔧 Customization Points
### Before First Push
1. **Edit `flake.nix`:**
- Change hostname from "myhost"
- Change username from "yourusername"
2. **Edit `configuration.nix`:**
- Set your timezone (currently Europe/Oslo)
- Adjust locale settings
- Configure your user account
3. **Edit `home/home.nix`:**
- Set git username and email
- Add/remove packages you want
4. **Edit `home/hyprland.nix`:**
- Customize keybindings
- Adjust colors and appearance
- Configure monitor settings
5. **Edit `bootstrap.sh`:**
- Update the GIT_REPO variable with your actual git URL
### After Installation
You can always modify the configuration and rebuild:
```bash
cd ~/.config/nixos
# Make your changes
sudo nixos-rebuild switch --flake .#HOSTNAME
```
Or use the convenient alias after first build:
```bash
update
```
## 🎨 Ricing Capabilities
This configuration includes extensive customization options:
### Visual Customization
- **Window Decorations**: Rounded corners, borders, shadows
- **Animations**: Smooth transitions and effects
- **Colors**: Fully customizable color schemes
- **Transparency**: Blur effects and opacity settings
- **Status Bar**: Custom Waybar themes
### Included Ricing Tools
- Hyprpaper (wallpapers)
- SWWW (animated wallpapers)
- Waybar (customizable bar)
- Dunst (notification styling)
- Wofi (launcher themes)
- GTK/Qt theme support
### Where to Customize
- **Colors**: `home/hyprland.nix` (general section)
- **Waybar Style**: `home/waybar.nix` (style section)
- **Animations**: `home/hyprland.nix` (animations section)
- **Terminal**: `home/home.nix` (kitty settings)
## 🔑 Key Features
### Declarative
Everything is code. No hidden state. Reproducible across machines.
### Atomic Updates
Changes are atomic - either they work completely or rollback automatically.
### Rollback Capability
Every build creates a generation. Easy to rollback if something breaks.
### Reproducible
Same configuration = same system, regardless of when/where you build.
### Version Controlled
Your entire OS is in git. Fork it, branch it, merge configurations.
## 📚 Next Steps
1. **Personalize** the configuration files
2. **Push** to your git server
3. **Install** NixOS on target machine
4. **Run** bootstrap script
5. **Enjoy** your custom system!
## 🐛 Troubleshooting
### Common Issues
**Hyprland won't start**
- Check logs: `journalctl -xe`
- Verify GPU drivers in `hardware-configuration.nix`
**Monitor configuration wrong**
- Edit `home/hyprland.nix` monitor settings
- Use `hyprctl monitors` to see detected monitors
**Packages not found**
- Update flake: `nix flake update`
- Rebuild: `sudo nixos-rebuild switch --flake .#HOSTNAME`
**Need different keyboard layout**
- Edit `home/hyprland.nix` input section
- Change `kb_layout` value
## 🎓 Learning Resources
- [NixOS Manual](https://nixos.org/manual/nixos/stable/)
- [Hyprland Wiki](https://wiki.hyprland.org/)
- [Home Manager Docs](https://nix-community.github.io/home-manager/)
- [NixOS Search](https://search.nixos.org/) - Find packages
## 🌟 Why This Approach?
**Traditional Linux Setup:**
- Install OS
- Install packages one by one
- Configure everything manually
- Hope you documented it
- Pray when setting up a new machine
**This NixOS Setup:**
- Install NixOS (minimal)
- Run one command
- Get coffee ☕
- Everything configured automatically
- Reproducible on any machine
## 💡 Pro Tips
1. **Always commit changes** before rebuilding
2. **Test on a VM first** for major changes
3. **Keep hardware-configuration.nix** separate per machine
4. **Use branches** for experimental configurations
5. **Document** your customizations in comments
---
**You now have a fully declarative, reproducible, version-controlled operating system! 🎉**
Any questions or issues? Check the README.md for detailed information.

244
README.md Normal file
View File

@@ -0,0 +1,244 @@
# NixOS Configuration with Hyprland
A fully declarative NixOS configuration featuring Hyprland as the Wayland compositor with extensive ricing capabilities.
## Features
- **Hyprland**: Modern Wayland compositor with beautiful animations
- **Home Manager**: User-level package and dotfile management
- **Flakes**: Reproducible, declarative configuration
- **Full Wayland Support**: Native Wayland applications and XWayland compatibility
- **Ricing Tools**: Waybar, Hyprpaper, Dunst, and more for customization
- **Development Ready**: Includes essential development tools
## Quick Start (Fresh Install)
On a fresh NixOS installation, run:
```bash
nix-shell -p git --run "bash <(curl -s https://git.cribdev.com/raw/your-username/nixos-config/main/bootstrap.sh)"
```
Or manually:
```bash
# Install git
nix-shell -p git
# Clone this repository
git clone https://git.cribdev.com/your-username/nixos-config ~/.config/nixos
# Copy hardware configuration
sudo cp /etc/nixos/hardware-configuration.nix ~/.config/nixos/
# Edit configuration files (see below)
cd ~/.config/nixos
# Build and apply
sudo nixos-rebuild switch --flake .#myhost
```
## Configuration Structure
```
nixos-config/
├── flake.nix # Main flake configuration
├── configuration.nix # System-level configuration
├── hardware-configuration.nix # Auto-generated hardware config
├── bootstrap.sh # Bootstrap script for fresh installs
├── modules/
│ ├── system.nix # System packages and services
│ └── hyprland.nix # Hyprland-specific configuration
└── home/
├── home.nix # Home Manager user configuration
├── hyprland.nix # Hyprland user settings and keybindings
└── waybar.nix # Waybar status bar configuration
```
## Before First Build
Edit these files with your information:
### 1. `flake.nix`
- Replace `myhost` with your hostname
- Replace `yourusername` with your username
### 2. `configuration.nix`
- Set your `networking.hostName`
- Set your `time.timeZone`
- Adjust locale settings if needed
- Update username in `users.users.yourusername`
### 3. `home/home.nix`
- Update `home.username` and `home.homeDirectory`
- Configure Git with your name and email
- Adjust package list to your needs
### 4. `home/hyprland.nix`
- Configure monitor settings
- Customize keybindings
- Adjust animations and appearance
## Included Software
### System Tools
- NetworkManager for networking
- PipeWire for audio
- Bluetooth support
- SSH server
- CUPS for printing
### Desktop Environment
- Hyprland (Wayland compositor)
- Waybar (status bar)
- Wofi (application launcher)
- Dunst (notifications)
- Hyprpaper/SWWW (wallpapers)
### Terminal & Shell
- Kitty & Alacritty terminals
- Zsh with Oh-My-Zsh
- Modern CLI tools (eza, bat, ripgrep, fd, fzf)
### Applications
- Firefox browser
- VSCode editor
- Thunar file manager
- MPV media player
- And more...
## Hyprland Keybindings
Default modifier key: `SUPER` (Windows key)
### Basic
- `SUPER + Return` - Launch terminal (Kitty)
- `SUPER + D` - Launch application launcher (Wofi)
- `SUPER + Q` - Close active window
- `SUPER + M` - Exit Hyprland
- `SUPER + E` - Open file manager (Thunar)
- `SUPER + V` - Toggle floating mode
- `SUPER + F` - Toggle fullscreen
### Window Management
- `SUPER + Arrow Keys` - Move focus
- `SUPER + 1-9` - Switch to workspace
- `SUPER + SHIFT + 1-9` - Move window to workspace
- `SUPER + Mouse Left` - Move window
- `SUPER + Mouse Right` - Resize window
### Screenshots
- `SUPER + SHIFT + S` - Screenshot selection to clipboard
- `Print` - Screenshot selection to ~/Pictures
### Media Keys
- Volume up/down/mute
- Brightness up/down
- All media keys supported
## Customization
### Themes and Appearance
The configuration uses the Catppuccin color scheme by default. To customize:
1. **Waybar**: Edit `home/waybar.nix` - Change colors in the `style` section
2. **Hyprland**: Edit `home/hyprland.nix` - Modify colors in `general` and `decoration` sections
3. **Terminal**: Edit `home/home.nix` - Change Kitty theme and appearance
### Wallpapers
Place your wallpapers in `~/wallpapers/`. The default wallpaper should be `~/wallpapers/default.jpg`.
To change wallpapers on the fly:
```bash
hyprctl hyprpaper wallpaper "monitor,~/wallpapers/your-wallpaper.jpg"
```
### Additional Packages
To add more packages:
**System-wide**: Edit `modules/system.nix` and add to `environment.systemPackages`
**User-level**: Edit `home/home.nix` and add to `home.packages`
## Updating the System
```bash
# Update flake inputs
nix flake update
# Rebuild with new configuration
sudo nixos-rebuild switch --flake ~/.config/nixos#myhost
# Or use the alias (after first build)
update
```
## Maintenance
### Garbage Collection
```bash
# Remove old generations older than 7 days
sudo nix-collect-garbage --delete-older-than 7d
# Clean home-manager generations
home-manager expire-generations -7d
```
### Rollback
```bash
# List generations
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
# Rollback to previous generation
sudo nixos-rebuild switch --rollback
```
## Troubleshooting
### Black screen after login
- Check if Hyprland is starting: `journalctl -xe`
- Verify graphics drivers are installed
- Check `hardware-configuration.nix` for GPU settings
### Waybar not appearing
- Restart Waybar: `killall waybar && waybar &`
- Check logs: `journalctl --user -u waybar`
### No audio
- Check PipeWire status: `systemctl --user status pipewire`
- Verify audio device: `wpctl status`
### Monitor configuration
Edit `home/hyprland.nix` and adjust the `monitor` setting:
```nix
monitor = "DP-1,1920x1080@144,0x0,1";
```
## Useful Commands
```bash
# Check Hyprland version
hyprctl version
# List all windows
hyprctl clients
# Reload Hyprland config
hyprctl reload
# View Hyprland logs
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 1)/hyprland.log
```
## Resources
- [NixOS Manual](https://nixos.org/manual/nixos/stable/)
- [Home Manager Manual](https://nix-community.github.io/home-manager/)
- [Hyprland Wiki](https://wiki.hyprland.org/)
- [NixOS Wiki](https://nixos.wiki/)
## License
Feel free to use and modify this configuration for your own needs.

149
SETUP.md Normal file
View File

@@ -0,0 +1,149 @@
# Quick Setup Guide
## Initial Setup on Fresh NixOS Installation
### Method 1: One-Line Bootstrap (Recommended)
```bash
nix-shell -p git --run "bash <(curl -s https://git.cribdev.com/raw/YOUR-USERNAME/nixos-config/main/bootstrap.sh)"
```
Replace `YOUR-USERNAME` with your actual git username.
### Method 2: Manual Setup
1. **Install git temporarily:**
```bash
nix-shell -p git
```
2. **Clone your configuration:**
```bash
git clone https://git.cribdev.com/YOUR-USERNAME/nixos-config ~/.config/nixos
cd ~/.config/nixos
```
3. **Copy hardware configuration:**
```bash
sudo cp /etc/nixos/hardware-configuration.nix ~/.config/nixos/
```
4. **Edit configuration files:**
- Open `flake.nix` and replace:
- `myhost` with your hostname
- `yourusername` with your username
- Open `configuration.nix` and set:
- `networking.hostName`
- `time.timeZone`
- User account details
- Open `home/home.nix` and set:
- Git username and email
- Any other personal preferences
5. **Build and apply:**
```bash
sudo nixos-rebuild switch --flake ~/.config/nixos#YOURHOSTNAME
```
6. **Reboot:**
```bash
reboot
```
## Post-Installation
### Add a Wallpaper
```bash
mkdir -p ~/wallpapers
# Copy your wallpaper to ~/wallpapers/default.jpg
```
### Test Hyprland
After reboot, you should be greeted with a login manager. Log in and Hyprland should start automatically.
### Useful First Commands
```bash
# Open terminal: SUPER + Return
# Open app launcher: SUPER + D
# Open file manager: SUPER + E
```
## Pushing to Your Git Server
### First Time Setup
1. **Initialize git (if not already done):**
```bash
cd ~/.config/nixos
git init
git add .
git commit -m "Initial NixOS configuration"
```
2. **Add your remote:**
```bash
git remote add origin https://git.cribdev.com/YOUR-USERNAME/nixos-config.git
```
3. **Push to your server:**
```bash
git push -u origin main
```
### Updating Your Configuration
After making changes:
```bash
cd ~/.config/nixos
git add .
git commit -m "Description of changes"
git push
```
## Troubleshooting
### "Hardware configuration not found"
Generate it with:
```bash
sudo nixos-generate-config --show-hardware-config > ~/.config/nixos/hardware-configuration.nix
```
### "Flake inputs need to be updated"
```bash
cd ~/.config/nixos
nix flake update
sudo nixos-rebuild switch --flake .#YOURHOSTNAME
```
### Hyprland doesn't start
Check logs:
```bash
journalctl -xe
cat /tmp/hypr/*/hyprland.log
```
## What You Get
✅ Full Wayland desktop with Hyprland
✅ Beautiful animations and effects
✅ Waybar status bar
✅ Wofi application launcher
✅ Dunst notifications
✅ Screenshot tools (grim + slurp)
✅ Modern terminal (Kitty)
✅ Essential CLI tools
✅ Development environment ready
✅ Fully reproducible system
## Next Steps
- Customize Waybar appearance in `home/waybar.nix`
- Adjust Hyprland settings in `home/hyprland.nix`
- Add more packages in `home/home.nix` or `modules/system.nix`
- Set up your wallpapers
- Configure your applications
Enjoy your new NixOS + Hyprland setup! 🎉

99
bootstrap.sh Normal file
View File

@@ -0,0 +1,99 @@
#!/usr/bin/env bash
# Bootstrap script for NixOS with Hyprland configuration
# Run this on a fresh NixOS install to pull and apply your configuration
set -e
echo "================================================"
echo "NixOS Hyprland Configuration Bootstrap"
echo "================================================"
echo ""
# Configuration variables
GIT_REPO="https://git.cribdev.com/crib/nixos-config.git"
CONFIG_DIR="$HOME/.config/nixos"
HOSTNAME=$(hostname)
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}Step 1: Installing Git (if not already installed)${NC}"
if ! command -v git &> /dev/null; then
nix-shell -p git --run "echo 'Git temporarily available'"
fi
echo ""
echo -e "${YELLOW}Step 2: Cloning configuration from ${GIT_REPO}${NC}"
if [ -d "$CONFIG_DIR" ]; then
echo -e "${RED}Configuration directory already exists at $CONFIG_DIR${NC}"
read -p "Do you want to remove it and clone fresh? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$CONFIG_DIR"
else
echo "Aborting..."
exit 1
fi
fi
mkdir -p "$HOME/.config"
git clone "$GIT_REPO" "$CONFIG_DIR"
echo ""
echo -e "${YELLOW}Step 3: Copying hardware configuration${NC}"
if [ -f /etc/nixos/hardware-configuration.nix ]; then
cp /etc/nixos/hardware-configuration.nix "$CONFIG_DIR/hardware-configuration.nix"
echo -e "${GREEN}Hardware configuration copied${NC}"
else
echo -e "${RED}Warning: /etc/nixos/hardware-configuration.nix not found!${NC}"
echo "You'll need to generate it with: nixos-generate-config"
fi
echo ""
echo -e "${YELLOW}Step 4: Updating hostname in configuration${NC}"
echo "Current hostname: $HOSTNAME"
read -p "Press enter to use this hostname, or type a new one: " NEW_HOSTNAME
if [ ! -z "$NEW_HOSTNAME" ]; then
HOSTNAME="$NEW_HOSTNAME"
fi
# Update hostname in flake.nix and configuration.nix
sed -i "s/myhost/$HOSTNAME/g" "$CONFIG_DIR/flake.nix"
sed -i "s/myhost/$HOSTNAME/g" "$CONFIG_DIR/configuration.nix"
echo ""
echo -e "${YELLOW}Step 5: Update username${NC}"
read -p "Enter your username: " USERNAME
sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/flake.nix"
sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/configuration.nix"
sed -i "s/yourusername/$USERNAME/g" "$CONFIG_DIR/home/home.nix"
echo ""
echo -e "${YELLOW}Step 6: Creating wallpapers directory${NC}"
mkdir -p "$HOME/wallpapers"
echo "Place your wallpaper at ~/wallpapers/default.jpg"
echo ""
echo -e "${GREEN}Configuration ready!${NC}"
echo ""
echo "Next steps:"
echo "1. Review the configuration files in $CONFIG_DIR"
echo "2. Edit configuration.nix to set your timezone and locale"
echo "3. Edit home/home.nix to configure your git name/email"
echo "4. Run: sudo nixos-rebuild switch --flake $CONFIG_DIR#$HOSTNAME"
echo ""
echo -e "${YELLOW}Would you like to build now? (y/N):${NC}"
read -p "" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Building NixOS configuration..."
sudo nixos-rebuild switch --flake "$CONFIG_DIR#$HOSTNAME"
echo ""
echo -e "${GREEN}Build complete! Please reboot your system.${NC}"
else
echo "You can build later with:"
echo "sudo nixos-rebuild switch --flake $CONFIG_DIR#$HOSTNAME"
fi

51
configuration.nix Normal file
View File

@@ -0,0 +1,51 @@
{ config, pkgs, inputs, ... }:
{
imports = [
./hardware-configuration.nix
./modules/system.nix
./modules/hyprland.nix
];
# Bootloader
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Networking
networking.hostName = "myhost"; # Change this to your hostname
networking.networkmanager.enable = true;
# Time zone
time.timeZone = "Europe/Oslo"; # Adjust to your timezone
# Locale
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "nb_NO.UTF-8";
LC_IDENTIFICATION = "nb_NO.UTF-8";
LC_MEASUREMENT = "nb_NO.UTF-8";
LC_MONETARY = "nb_NO.UTF-8";
LC_NAME = "nb_NO.UTF-8";
LC_NUMERIC = "nb_NO.UTF-8";
LC_PAPER = "nb_NO.UTF-8";
LC_TELEPHONE = "nb_NO.UTF-8";
LC_TIME = "nb_NO.UTF-8";
};
# Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# User account
users.users.crib = {
isNormalUser = true;
description = "Your Name";
extraGroups = [ "networkmanager" "wheel" "video" "audio" ];
shell = pkgs.zsh;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# System version
system.stateVersion = "24.05"; # Don't change this
}

35
flake.nix Normal file
View File

@@ -0,0 +1,35 @@
{
description = "NixOS Configuration with Hyprland";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
};
outputs = { self, nixpkgs, home-manager, hyprland, ... }@inputs: {
nixosConfigurations = {
# Replace 'myhost' with your hostname
cribnix = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.crib = import ./home/home.nix;
home-manager.extraSpecialArgs = { inherit inputs; };
}
];
};
};
};
}

View File

@@ -0,0 +1,41 @@
# This is a template hardware configuration file
# On a fresh install, this will be replaced by the actual hardware configuration
# generated by nixos-generate-config or copied from /etc/nixos/hardware-configuration.nix
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
# This is a placeholder - it will be replaced during bootstrap
# Your actual hardware configuration will be generated based on your system
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
swapDevices = [ ];
# Enable GPU support (uncomment what matches your hardware)
# hardware.opengl.extraPackages = with pkgs; [
# intel-media-driver # For Intel GPUs
# vaapiIntel # For Intel GPUs
# vaapiVdpau # For AMD/NVIDIA
# ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

83
home/home.nix Normal file
View File

@@ -0,0 +1,83 @@
{ config, pkgs, inputs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should manage
home.username = "yourusername";
home.homeDirectory = "/home/yourusername";
# Packages to install for this user
home.packages = with pkgs; [
# Browsers
firefox
# Communication
discord
# Media
mpv
# Text editors
vscode
# Terminal tools
neofetch
# Additional ricing tools
cava # Audio visualizer
cmatrix # Matrix effect
pipes # Animated pipes
];
# Import Hyprland home config
imports = [
./hyprland.nix
./waybar.nix
];
# Git configuration
programs.git = {
enable = true;
userName = "crib";
userEmail = "haugseth.martin@gmail.com";
};
# ZSH configuration
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
ll = "eza -la";
ls = "eza";
cat = "bat";
vim = "nvim";
update = "sudo nixos-rebuild switch --flake ~/.config/nixos#myhost";
};
oh-my-zsh = {
enable = true;
theme = "robbyrussell";
plugins = [ "git" "sudo" "docker" "kubectl" ];
};
};
# Kitty terminal configuration
programs.kitty = {
enable = true;
theme = "Tokyo Night";
font.name = "JetBrainsMono Nerd Font";
font.size = 12;
settings = {
background_opacity = "0.9";
confirm_os_window_close = 0;
};
};
# This value determines the Home Manager release
home.stateVersion = "24.05";
# Let Home Manager install and manage itself
programs.home-manager.enable = true;
}

194
home/hyprland.nix Normal file
View File

@@ -0,0 +1,194 @@
{ config, pkgs, ... }:
{
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
settings = {
# Monitor configuration
monitor = ",preferred,auto,1";
# Startup applications
exec-once = [
"waybar"
"dunst"
"hyprpaper"
"nm-applet --indicator"
"blueman-applet"
];
# Environment variables
env = [
"XCURSOR_SIZE,24"
"QT_QPA_PLATFORMTHEME,qt5ct"
];
# Input configuration
input = {
kb_layout = "us";
follow_mouse = 1;
touchpad = {
natural_scroll = true;
};
sensitivity = 0;
};
# General settings
general = {
gaps_in = 5;
gaps_out = 10;
border_size = 2;
"col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg";
"col.inactive_border" = "rgba(595959aa)";
layout = "dwindle";
allow_tearing = false;
};
# Decoration
decoration = {
rounding = 10;
blur = {
enabled = true;
size = 3;
passes = 1;
vibrancy = 0.1696;
};
drop_shadow = true;
shadow_range = 4;
shadow_render_power = 3;
"col.shadow" = "rgba(1a1a1aee)";
};
# Animations
animations = {
enabled = true;
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 7, myBezier"
"windowsOut, 1, 7, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 6, default"
];
};
# Layout
dwindle = {
pseudotile = true;
preserve_split = true;
};
master = {
new_status = "master";
};
# Gestures
gestures = {
workspace_swipe = true;
};
# Misc
misc = {
force_default_wallpaper = 0;
disable_hyprland_logo = true;
};
# Window rules
windowrulev2 = [
"suppressevent maximize, class:.*"
"float, class:^(pavucontrol)$"
"float, class:^(blueman-manager)$"
];
# Keybindings
"$mainMod" = "SUPER";
bind = [
# Program launches
"$mainMod, Return, exec, kitty"
"$mainMod, Q, killactive,"
"$mainMod, M, exit,"
"$mainMod, E, exec, thunar"
"$mainMod, V, togglefloating,"
"$mainMod, D, exec, wofi --show drun"
"$mainMod, P, pseudo,"
"$mainMod, J, togglesplit,"
"$mainMod, F, fullscreen,"
# Screenshot
"$mainMod SHIFT, S, exec, grim -g \"$(slurp)\" - | wl-copy"
", Print, exec, grim -g \"$(slurp)\" ~/Pictures/screenshot_$(date +%Y%m%d_%H%M%S).png"
# Move focus
"$mainMod, left, movefocus, l"
"$mainMod, right, movefocus, r"
"$mainMod, up, movefocus, u"
"$mainMod, down, movefocus, d"
# Switch workspaces
"$mainMod, 1, workspace, 1"
"$mainMod, 2, workspace, 2"
"$mainMod, 3, workspace, 3"
"$mainMod, 4, workspace, 4"
"$mainMod, 5, workspace, 5"
"$mainMod, 6, workspace, 6"
"$mainMod, 7, workspace, 7"
"$mainMod, 8, workspace, 8"
"$mainMod, 9, workspace, 9"
"$mainMod, 0, workspace, 10"
# Move active window to workspace
"$mainMod SHIFT, 1, movetoworkspace, 1"
"$mainMod SHIFT, 2, movetoworkspace, 2"
"$mainMod SHIFT, 3, movetoworkspace, 3"
"$mainMod SHIFT, 4, movetoworkspace, 4"
"$mainMod SHIFT, 5, movetoworkspace, 5"
"$mainMod SHIFT, 6, movetoworkspace, 6"
"$mainMod SHIFT, 7, movetoworkspace, 7"
"$mainMod SHIFT, 8, movetoworkspace, 8"
"$mainMod SHIFT, 9, movetoworkspace, 9"
"$mainMod SHIFT, 0, movetoworkspace, 10"
# Scroll through workspaces
"$mainMod, mouse_down, workspace, e+1"
"$mainMod, mouse_up, workspace, e-1"
];
# Mouse bindings
bindm = [
"$mainMod, mouse:272, movewindow"
"$mainMod, mouse:273, resizewindow"
];
# Volume and brightness keys
bindel = [
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
", XF86MonBrightnessUp, exec, brightnessctl s 10%+"
", XF86MonBrightnessDown, exec, brightnessctl s 10%-"
];
};
};
# Hyprpaper configuration
services.hyprpaper = {
enable = true;
settings = {
preload = [ "~/wallpapers/default.jpg" ];
wallpaper = [ ",~/wallpapers/default.jpg" ];
splash = false;
};
};
}

175
home/waybar.nix Normal file
View File

@@ -0,0 +1,175 @@
{ config, pkgs, ... }:
{
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 30;
modules-left = [ "hyprland/workspaces" "hyprland/window" ];
modules-center = [ "clock" ];
modules-right = [ "pulseaudio" "network" "cpu" "memory" "battery" "tray" ];
"hyprland/workspaces" = {
format = "{icon}";
on-click = "activate";
format-icons = {
"1" = "󰲠";
"2" = "󰲢";
"3" = "󰲤";
"4" = "󰲦";
"5" = "󰲨";
"6" = "󰲪";
"7" = "󰲬";
"8" = "󰲮";
"9" = "󰲰";
"10" = "󰿬";
};
};
"hyprland/window" = {
format = "{}";
separate-outputs = true;
};
clock = {
format = "󰃰 {:%H:%M}";
format-alt = "󰃰 {:%A, %B %d, %Y (%R)}";
tooltip-format = "<tt><small>{calendar}</small></tt>";
calendar = {
mode = "year";
mode-mon-col = 3;
weeks-pos = "right";
on-scroll = 1;
format = {
months = "<span color='#ffead3'><b>{}</b></span>";
days = "<span color='#ecc6d9'><b>{}</b></span>";
weeks = "<span color='#99ffdd'><b>W{}</b></span>";
weekdays = "<span color='#ffcc66'><b>{}</b></span>";
today = "<span color='#ff6699'><b><u>{}</u></b></span>";
};
};
};
pulseaudio = {
format = "{icon} {volume}%";
format-muted = "󰝟 Muted";
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
portable = "";
car = "";
default = [ "" "" "" ];
};
on-click = "pavucontrol";
};
network = {
format-wifi = " {essid}";
format-ethernet = "󰈀 Wired";
format-disconnected = "󰤭 Disconnected";
tooltip-format = "{ifname} via {gwaddr}";
tooltip-format-wifi = "{essid} ({signalStrength}%)";
on-click = "nm-connection-editor";
};
cpu = {
format = " {usage}%";
tooltip = false;
};
memory = {
format = " {}%";
tooltip-format = "RAM: {used:0.1f}G / {total:0.1f}G";
};
battery = {
states = {
warning = 30;
critical = 15;
};
format = "{icon} {capacity}%";
format-charging = "󰂄 {capacity}%";
format-plugged = " {capacity}%";
format-icons = [ "󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ];
};
tray = {
icon-size = 18;
spacing = 10;
};
};
};
style = ''
* {
border: none;
border-radius: 0;
font-family: "JetBrainsMono Nerd Font";
font-size: 13px;
min-height: 0;
}
window#waybar {
background: rgba(30, 30, 46, 0.9);
color: #cdd6f4;
}
#workspaces button {
padding: 0 10px;
color: #cdd6f4;
background: transparent;
border-bottom: 3px solid transparent;
}
#workspaces button.active {
color: #89b4fa;
border-bottom: 3px solid #89b4fa;
}
#workspaces button:hover {
background: rgba(137, 180, 250, 0.2);
}
#window {
margin: 0 10px;
color: #cdd6f4;
}
#clock,
#battery,
#cpu,
#memory,
#network,
#pulseaudio,
#tray {
padding: 0 10px;
margin: 0 2px;
background: rgba(49, 50, 68, 0.8);
border-radius: 5px;
}
#battery.charging {
color: #a6e3a1;
}
#battery.warning:not(.charging) {
color: #f9e2af;
}
#battery.critical:not(.charging) {
color: #f38ba8;
}
#pulseaudio.muted {
color: #f38ba8;
}
'';
};
}

79
modules/hyprland.nix Normal file
View File

@@ -0,0 +1,79 @@
{ config, pkgs, inputs, ... }:
{
# Import Hyprland module
imports = [ inputs.hyprland.nixosModules.default ];
# Enable Hyprland
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
# Hyprland-related packages
environment.systemPackages = with pkgs; [
# Core Hyprland tools
hyprpaper # Wallpaper utility
hyprpicker # Color picker
hypridle # Idle daemon
hyprlock # Screen locker
# Wayland essentials
waybar # Status bar
wofi # Application launcher
dunst # Notification daemon
swww # Wallpaper daemon (alternative to hyprpaper)
# Screenshot and recording
grim # Screenshot tool
slurp # Region selector
wl-clipboard # Clipboard utilities
# File manager
thunar
# Image viewer
imv
# PDF viewer
zathura
# Audio control
pavucontrol
# Network management
networkmanagerapplet
# Brightness control
brightnessctl
# Additional tools for ricing
jq # JSON processor (for scripts)
socat # Socket tools
wlogout # Logout menu
nwg-look # GTK theme config
qt5ct # Qt5 config
qt6ct # Qt6 config
];
# Enable XDG Desktop Portal for Hyprland
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-hyprland
xdg-desktop-portal-gtk
];
};
# Security - for screen locking
security.pam.services.hyprlock = {};
# Fonts for better UI
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
font-awesome
(nerdfonts.override { fonts = [ "JetBrainsMono" "FiraCode" "DroidSansMono" ]; })
];
}

89
modules/system.nix Normal file
View File

@@ -0,0 +1,89 @@
{ config, pkgs, ... }:
{
# Essential system packages
environment.systemPackages = with pkgs; [
# System utilities
wget
curl
git
vim
neovim
htop
btop
killall
unzip
zip
p7zip
# Network tools
networkmanagerapplet
# File managers
ranger
lf
# Terminal
kitty
alacritty
# Shell
zsh
oh-my-zsh
# Development
gcc
gnumake
cmake
# Misc utilities
ripgrep
fd
fzf
bat
eza
tldr
tree
];
# Enable sound
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
# Enable CUPS for printing
services.printing.enable = true;
# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
# Enable Bluetooth
hardware.bluetooth.enable = true;
services.blueman.enable = true;
# Enable SSH
services.openssh.enable = true;
# Enable ZSH
programs.zsh.enable = true;
# Enable dconf (required for some applications)
programs.dconf.enable = true;
# XDG portals for Wayland
xdg.portal = {
enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
}