diff --git a/README.md b/README.md index d2fbd7f2..59db0125 100644 --- a/README.md +++ b/README.md @@ -1,176 +1,68 @@ -###### *
// design by t2
* -
-[![NixOS Unstable](https://img.shields.io/badge/NixOS-unstable-blue.svg?style=flat-square&logo=NixOS&logoColor=white)](https://nixos.org) -[![Release](https://img.shields.io/github/v/release/richen604/hydenix?style=flat-square)](https://github.com/richen604/hydenix/releases) -[![Last Commit](https://img.shields.io/github/last-commit/richen604/hydenix/main?style=flat-square)](https://github.com/richen604/hydenix/commits/main) - -[![Nix Flake Check](https://github.com/richen604/hydenix/actions/workflows/flake-check.yml/badge.svg?style=flat-square)](https://github.com/richen604/hydenix/actions/workflows/flake-check.yml) +[![NixOS Unstable](https://img.shields.io/badge/NixOS-unstable-ebbcba.svg?style=flat-square&logo=NixOS&logoColor=white)](https://nixos.org) +[![Release](https://img.shields.io/github/v/release/richen604/hydenix?style=flat-square&color=c79bf0)](https://github.com/richen604/hydenix/releases) +[![Last Commit](https://img.shields.io/github/last-commit/richen604/hydenix/main?style=flat-square&color=ebbcba)](https://github.com/richen604/hydenix/commits/main) +[![Nix Flake Check](https://img.shields.io/github/actions/workflow/status/richen604/hydenix/flake-check.yml?style=flat-square&color=c79bf0&label=flake%20check)](https://github.com/richen604/hydenix/actions/workflows/flake-check.yml)
- -Dynamic JSON Badge - -
- - - -
- - ![hyde_banner](https://raw.githubusercontent.com/prasanthrangan/hyprdots/main/Source/assets/hyde_banner.png) - +
-
 Installation 
  -
 Upgrading 
  -
 Issues 
  -
 FAQ 
  -
 Contributing 
  -
 Youtube 
  -
 Discord 
+ -


+ - +
-
NixOS
+NixOS -# Hydenix +# hydenix -Hydenix is a Nix & home-manager configuration for [HyDE](https://github.com/HyDE-Project/HyDE). -The nix ecosystem brings a reproducable environment to the HyDE experience; allowing for build-time configuration options, easy updates, and more. +a nixos and home-manager configuration for [HyDE](https://github.com/HyDE-Project/HyDE) -Features: +**features / why nixos? :** -- `hydenix` and `hydenix.hm` (home-manager) options for easy configuration -- Themes are fetched at build-time, for faster setup +- declarative `hydenix` and `hydenix.hm` configuration options +- leveraged module system, easily extend disable or override any module +- close feature parity with [HyDE](https://github.com/HyDE-Project/HyDE) +- every community [hyde-gallery theme](https://github.com/HyDE-Project/hyde-gallery) +- reproducible environments with easy rollbacks +- version control for your desktop -Why Nix?: +## requirements -- Reproducible environment -- Easy to manage packages, dependencies, and configurations -- changes in configuration can be rolled back easily -- home-manager for managing dotfiles +- minimal install of nixos, follow instructions on [nixos iso](https://nixos.org/download/#nixos-iso) > [!IMPORTANT] -> Experience in functional programming is recommended. -> If you are new to Nix, please refer to the [Nix Resources](docs/faq.md#how-do-i-learn-more-about-nix). -> Feel free to ask questions in discussions or discord. - ---- - -## Requirements - -- minimal install of NixOS, follow instructions on [NixOS ISO](https://nixos.org/download/#nixos-iso) -- experimental features enabled: - - ```bash - # Add to /etc/nixos/configuration.nix - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # then rebuild your system - sudo nixos-rebuild switch - ``` - -- git (`nix-shell -p git`) +> functional programming experience recommended.
+> new to nix? see [nix resources](./template/docs/faq.md#how-do-i-learn-more-about-nix) or ask in discussions/discord. ---- +## documentation -## Documentation +- [installation](./template/docs/installation.md) +- [upgrading](./template/docs/upgrading.md) +- [module options](./template/docs/options.md) +- [faq](./template/docs/faq.md) +- [troubleshooting & issues](./template/docs/troubleshooting.md) +- [contributing](./template/docs/contributing.md) +- [community configs](./template/docs/community.md) +- [todo - sneak peak of whats coming soon](./TODO.md) -- [Installation Options](#installation-options) -- [FAQ](./docs/faq.md) -- [Troubleshooting & Issues](./docs/troubleshooting.md) -- [Contributing](./docs/contributing.md) +## hydenix vm -## Installation Options - ---- - -> [!CAUTION] -> Templated flake is designed for a minimal install of NixOS. - -### 1. Template the Hydenix Flake - -1. in a new directory, `nix flake init -t github:richen604/hydenix` -2. edit `configuration.nix` with your preferences for hydenix - - options needing to be changed are marked with `! EDIT` - - (optional) in your template flake folder, review both `./configuration.nix` and `./modules/hm/default.nix` for more options -3. run `sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix` -4. `git init && git add .` (flakes have to be managed via git) -5. run any of the packages in your new `flake.nix` - - for rebuild, use `sudo nixos-rebuild switch --flake .` -6. DON'T FORGET: change your password for all users with `passwd` from initialPassword set in `configuration.nix` - -NOTE: After launching hydenix, you can run `hyde-shell reload` to generate cache for remaining themes if you want. - -### 2. Trying Out Hydenix with a VM - -If your system supports it, the NixOS VM is a great way to try out hydenix without installing it. -If you encounter issues running the VM, refer to the [virtio guide](docs/faq.md#how-do-i-run-hyprland-in-a-vm) +if your system supports it, the nixos vm is a great way to try out hydenix without installing it. +if you encounter issues running the vm, refer to the [virtio guide](./template/docs/faq.md#how-do-i-run-hyprland-in-a-vm) ```bash # run the flake remotely nix run github:richen604/hydenix ``` -> **note:** any changes require the vm to be rebuilt. run `rm hydenix.qcow2` to remove the old one. - -## Upgrading - -Hydenix can be upgraded, downgraded, or version locked easy. -in your template flake folder, update hydenix to main using - -```bash -nix flake update hydenix -``` - -or define a specific version in your `flake.nix` template - -```nix -inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - hydenix = { - # Available inputs: - # Main: github:richen604/hydenix - # Dev: github:richen604/hydenix/dev - # Commit: github:richen604/hydenix/ - # Version: github:richen604/hydenix/v1.0.0 - url = "github:richen604/hydenix"; - }; - }; -``` - -run `nix flake update hydenix` again to load the update, then rebuild your system to apply the changes - -## When to Upgrade - -```mermaid -graph TD - A[v2.3.1] --> B[MAJOR] - A --> C[MINOR] - A --> D[PATCH] - B --> E[Breaking Changes
Review Release Notes for API Changes] - C --> F[New Features
Safe to Update] - D --> G[Bug Fixes
Safe to Update] - - style A fill:#c79bf0,stroke:#ebbcba,stroke-width:2px,color:#000 - style B fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style C fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style D fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style E fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style F fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style G fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 -``` - -- **Always review [release notes](https://github.com/richen604/hydenix/releases) for major updates (API changes)** -- Update to minor versions for new features -- Keep up with patches for stability - \ No newline at end of file +> [!NOTE] +> any changes require the vm to be rebuilt. run `rm hydenix.qcow2` to remove the old one. + diff --git a/TODO.md b/TODO.md index daeb9cfd..52c3215c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,108 +1,55 @@ -# todo / roadmap - -## now / notes - -- [ ] finish demo-vm for video - -## next api update - -- [ ] hydenix nixOsModules to nixosModules - -## priority - -- [ ] refactor hydevm to arch compatible then bump to repo - -- [ ] docs: better documented first edits - - [ ] add steps for what to edit first - - [ ] add more detailed driver - -- [ ] feat: demo-vm - - [ ] video - - [ ] - -- [ ] feat: spicetify theme support? flatpak? - -- [ ] chore: review bug template - -- [ ] feat: hyprland via home-manager only - - support plugins - - use hyprland flake package - - nixGL -- [ ] binary cache -- [ ] feat: experimental module exports #117 - -## unorganized - -- [ ] BREAKING:make hydenix more extensible without losing the ability to upgrade hyde - - [ ] hyde CORE modules - - map a module hierachy, propose a revised api - - modules that are required for hyde must have assertions. - -## iso builder - -- [ ] feat: iso builder should give a copy of the iso to the user on install -- [ ] feat: iso builder automated install should have more clear options, not just configuration.nix -- [ ] feat: iso builder should tell user exact steps of auto installer, reflect that in the readme -- [ ] fix: iso builder should prompt to edit hostname in flake.nix -- [ ] refactor: expand iso installer sections to be more clear and concise -- [ ] feat: iso installer section option to clone your own personal flake from github and use that instead of the hyde template -- [ ] feat: Completed iso builder - -## config.toml integration - -- [ ] feat: hyde config.toml module and options in hyde.nix -- [ ] feat: other program configuration should determine hyde config.toml options -- [ ] feat: extend hyde config.toml options for more nix integration - -## hyprland.conf - -- [ ] feat: more options in hyprland.nix -- [ ] feat: other program configuration should determine hyprland.conf options eg - -## hypridle - -- [ ] feat: hypridle module and options - -## hyprlock - -- [ ] feat: better hyprlock options - -## uncategorized - -- [ ] feat: cleanupOnDisable activation script and option - -## CI - -- [ ] ci: fix iso builder release flake check - -## Future Enhancements - -- [ ] Ecosystem - - [ ] feat: Create sddm-hyprland - - [ ] feat: Integrate hydepanel from rubin - - [ ] feat: Add telegram theme support - - [ ] feat: Add zed theme support - - [ ] feat: Add obsidian theme support - - [ ] feat: Add terminal-emulators support -- [ ] feat: full nixos config & full home-manager config -- [ ] feat: Set NIX-PATH to template flake location - -## Non-NixOS - - for non-nixos packages -specific scripts for each non-nixos distro options, ideally one script for all packages using pm -nixGL wrapping for all programs, well documented in the configuration as users will need to edit it. combine with any driver setup - -## Hyde repo - -- [ ] theme makers should be able to precache walls before patching - - [ ] requires arch vm (w/ commit hash param and snapshot functionality) - - [ ] hyde-theme-starter to implement /lib with swwwallcache and wallbash - - whatever generates dcols and wallcaches - - [ ] hyde repo themepatcher implement reading for .cache in theme to cp cache and skip - - [ ] validation - - [ ] themepatcher should still generate on missing cache per wall - - [ ] PR's for all themes to bring cache - - [ ] hydenix implementation (just home.file mutable) - - [ ] FUTURE: wallbash should be a seperate lib +# todo + +## now + +- docs: restyled docs, moved docs to template/docs +- docs: options.md use hydenix.hm.theme as an example instead of hydenix.hm.hyprland + +## next + +- feat: hyprland flake packages rather than nixpkgs +- feat: new themes to build +- feat: move hyprlock to hyprland module, swaylock should just be swaylock module + - assertion to not have both enabled +- feat: update hyde +- feat: update.sh for themes, map name to hash (check daily), passThru update.sh caller github action + - +- feat: vscode-nix-ide part of editors, enabled by default +- feat: hyde config.toml options +- feat: extending more options for feature parity with hyde + - fastfetch + - hyprlock + - rofi + - waybar + +## 5.0.0 + +- refactor: removed hydenix.lib to standardize outputs, hydenix nixOsModules to nixosModules +- fix: nix-index should be a module in hydenix only, its declared twice +- fix: rename nix-index home-manager module whatever new name +- feat: user now owns their nixosSystem, depreciated hydenix-nixpkgs.lib.nixosSystem +- feat: hydenix follows its own nixpkgs, no userPkgs overlays, template hydenix follows nixpkgs by default + - update docs to reflect this + +## backlog + +- finish demo-vm for video +- feat: assertions for common requirements +- chore: review bug template to make it more clear (easier with scripts?) + +## future + +- binary cache when i build it + +## notes + +- using nixos-anywhere to install hydenix: + - must be part of the template flake or a new template flake, as it will be used for the user configuration + - document disko configuration clearly, the issue is ive never used disko + - most likely will need its own video installation guide +- cleanupOnDisable activation script and option +- nh by default? +- docs: documentation generation? +- refactor: revise module hierarchy to be more clear and concise? +- feat: spicetify theme support? flatpak? diff --git a/docs/faq.md b/docs/faq.md deleted file mode 100644 index efbae35d..00000000 --- a/docs/faq.md +++ /dev/null @@ -1,610 +0,0 @@ -# FAQ - -## General FAQ - -- [FAQ](#faq) - - [General FAQ](#general-faq) - - [Why should I use NixOS?](#why-should-i-use-nixos) - - [How do I learn more about Nix?](#how-do-i-learn-more-about-nix) - - [Hydenix FAQ](#hydenix-faq) - - [How do I upgrade Hydenix?](#how-do-i-upgrade-hydenix) - - [When should I upgrade?](#when-should-i-upgrade) - - [How do I fix (Nix error / system error / bug / etc)?](#how-do-i-fix-nix-error--system-error--bug--etc) - - [Common errors](#common-errors) - - [`error: hash mismatch in fixed-output derivation`](#error-hash-mismatch-in-fixed-output-derivation) - - [`Existing file '...' is in the way of '...'`](#existing-file--is-in-the-way-of-) - - [What are the module options?](#what-are-the-module-options) - - [What if I want to customize hydenix?](#what-if-i-want-to-customize-hydenix) - - [What are some example configurations?](#what-are-some-example-configurations) - - [How do I persist changes on reboot/rebuild/etc?](#how-do-i-persist-changes-on-rebootrebuildetc) - - [How do I add a new theme?](#how-do-i-add-a-new-theme) - - [What is mutable.nix?](#what-is-mutablenix) - - [Why do themes still show after I remove them from `hydenix.hm.theme.themes`?](#why-do-themes-still-show-after-i-remove-them-from-hydenixhmthemethemes) - - [Requesting features](#requesting-features) - - [Other FAQ](#other-faq) - - [How do I run Hyprland in a VM?](#how-do-i-run-hyprland-in-a-vm) - -### Why should I use NixOS? - -NixOS offers several key advantages: - -1. **Reproducible setups**: Roll back to working states instantly if something breaks. -2. **Configuration as code**: Version control your entire OS setup. -3. **No dependency hell**: Packages are isolated, allowing multiple versions side by side. -4. **Declarative approach**: Describe the desired end state rather than steps to achieve it. -5. **Risk-free experimentation**: Test configurations without permanent consequences. -6. **Developer-friendly**: Create isolated environments with precise dependencies. - -There's a learning curve, but the benefits are worth it. - -
- - Back to Top - -
- -### How do I learn more about Nix? - -> [!TIP] -> Nix is a powerful package manager and configuration system that can be overwhelming at first. Here are some resources to help you get started: - -General Resources - -- [Nix Packages](https://search.nixos.org/packages) -- [Nix Options](https://search.nixos.org/options) -- [Home Manager Options](https://home-manager-options.extranix.com/?query=&release=master) -- [NixOS Wiki](https://nixos.wiki) -- [Nixpkgs Discussions](https://discourse.nixos.org) -- [Nixpkgs Issues](https://github.com/NixOS/nixpkgs/issues) - -
- - Back to Top - -
- -## Hydenix FAQ - -### How do I upgrade Hydenix? - -Hydenix can be upgraded, downgraded, or version locked easy. -in your template flake folder, update hydenix to main using - -```bash -nix flake update hydenix -``` - -or define a specific version in your `flake.nix` template - -```nix -inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - hydenix = { - # Available inputs: - # Main: github:richen604/hydenix - # Dev: github:richen604/hydenix/dev - # Commit: github:richen604/hydenix/ - # Version: github:richen604/hydenix/v1.0.0 - url = "github:richen604/hydenix"; - }; - }; -``` - -run `nix flake update hydenix` again to load the update, then rebuild your system to apply the changes - -### When should I upgrade? - -```mermaid -graph TD - A[v2.3.1] --> B[MAJOR] - A --> C[MINOR] - A --> D[PATCH] - B --> E[Breaking Changes
Review Release Notes for API Changes] - C --> F[New Features
Safe to Update] - D --> G[Bug Fixes
Safe to Update] - - style A fill:#c79bf0,stroke:#ebbcba,stroke-width:2px,color:#000 - style B fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style C fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style D fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style E fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style F fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style G fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 -``` - -- **Always review [release notes](https://github.com/richen604/hydenix/releases) for major updates (API changes)** -- Keep up with patches for stability -- Update to minor versions for new features - -### How do I fix (Nix error / system error / bug / etc)? - -Please see the [troubleshooting](./troubleshooting.md) guide for more information on how to diagnose and fix issues. -Or create an issue in the [Hydenix GitHub repository](https://github.com/richen604/hydenix/issues). - -### Common errors - -#### `error: hash mismatch in fixed-output derivation` - -This error occurs when Nix expects a specific hash for a downloaded file, but the actual file has a different hash due to upstream changes. - -These usually happen with themes as they are updated frequently. - -Example: - -```bash -error: hash mismatch in fixed-output derivation '/nix/store/2s2n054di1wg8d3sw50wqhs10yg8svj0-Code-Garden.drv': - specified: sha256-ZAmxhz7MK24htAcPdnNMZF/K7Cw7vru80xZn+7yJgXQ= - got: sha256-HHC15pPHJ+ylQ56yYysEoKjKYUAoye2WHmt4Q2vyffk= -``` - -**Solution: Override the package in configuration.nix** - -If I haven't updated this in the repo yet, add this overlay to your existing overlays in `configuration.nix` to fix the error: - -```nix -overlays = [ - inputs.hydenix.lib.overlays - # Fix hash mismatch errors for Catppuccin Mocha - (final: prev: { - # Replace 'hydenix.themes."Catppuccin Mocha"' with the actual failing package, for theme names check https://github.com/richen604/hydenix/blob/main/hydenix/sources/themes/default.nix - hydenix.themes."Catppuccin Mocha" = prev.hydenix.themes."Catppuccin Mocha".overrideAttrs (oldAttrs: { - src = prev.fetchFromGitHub { - # Use the hash from error message under "got:" - sha256 = "HHC15pPHJ+ylQ56yYysEoKjKYUAoye2WHmt4Q2vyffk="; - }; - }); - }) - (final: prev: { - userPkgs = import inputs.nixpkgs { - config.allowUnfree = true; - }; - }) -]; -``` - -#### `Existing file '...' is in the way of '...'` - -This error occurs when home-manager tries to manage a file that already exists and wasn't created by home-manager. - -Example: - -```bash -Existing file '/home/user/.config/kitty/kitty.conf' is in the way of '/nix/store/...-home-manager-files/.config/kitty/kitty.conf' -``` - -**Solution 1: Remove existing files (recommended)** - -Remove the conflicting files and let home-manager recreate them: - -```bash -# Remove the specific file -rm ~/.config/kitty/kitty.conf - -# Or remove entire config directory if needed (careful not to delete important files) -rm -rf ~/.config/kitty/ -``` - -**Solution 2: Backup existing files** - -If you want to preserve your existing configuration: - -```bash -# Create backup -mv ~/.config/kitty/kitty.conf ~/.config/kitty/kitty.conf.backup - -# Then rebuild to let home-manager create the new file -sudo nixos-rebuild switch -``` - -**Solution 3: Force home-manager to backup automatically** - -Add this to your `configuration.nix` to automatically backup conflicting files: - -```nix -{ - home-manager.backupFileExtension = "backup"; -} -``` - -This will automatically rename existing files with a `.backup` extension when home-manager encounters conflicts, allowing the rebuild to proceed without manual intervention only once. - -> [!WARNING] -> if there is a conflict again, home-manager will error for you to manually resolve it. I don't include this by default as automating backups may not be ideal for users and it does not really solve the issue with managing backups - -### What are the module options? - -Below will be the default options for hydenix. the only required options are `hydenix.enable` and `hydenix.hm.enable`. - -NixOS hydenix options: - -
-View NixOS hydenix options - -```nix -{ - hydenix = { - - #! Important options - enable = true; # enable hydenix - required, default false - hostname = "hydenix"; # hostname - timezone = "America/Vancouver"; # timezone - locale = "en_CA.UTF-8"; # locale - - #! Below are defaults - audio.enable = true; # enable audio module - boot = { - enable = true; # enable boot module - useSystemdBoot = true; # disable for GRUB - grubTheme = "Retroboot"; # or "Pochita" - grubExtraConfig = ""; # additional GRUB configuration - kernelPackages = pkgs.linuxPackages_zen; # default zen kernel - }; - gaming.enable = true; # enable gaming module - hardware.enable = true; # enable hardware module - network.enable = true; # enable network module - nix.enable = true; # enable nix module - sddm = { - enable = true; # enable sddm module - theme = "Candy" # or "Corners" - }; - system.enable = true; # enable system module - }; -} -``` - -
- -
-View Home Manager hydenix options - -```nix -{ - hydenix.hm = { - - #! Important options - enable = true; - - #! Below are defaults - comma.enable = true; # useful nix tool to run software without installing it first - dolphin.enable = true; # file manager - editors = { - enable = true; # enable editors module - neovim.enable = true; # enable neovim module - vscode = { - enable = true; # enable vscode module - wallbash = true; # enable wallbash extension for vscode - }; - vim.enable = true; # enable vim module - default = "code"; # default text editor - }; - fastfetch.enable = true; # fastfetch configuration - firefox.enable = true; # enable firefox module - gaming.enable = true; # enable gaming module - git = { - enable = true; # enable git module - name = null; # git user name eg "John Doe" - email = null; # git user email eg "john.doe@example.com" - }; - hyde.enable = true; # enable hyde module - hyprland = { - enable = true; # enable hyprland module - extraConfig = ""; # extra hyprland config text - }; - lockscreen = { - enable = true; # enable lockscreen module - hyprlock = true; # enable hyprlock lockscreen - swaylock = false; # enable swaylock lockscreen - }; - notifications.enable = true; # enable notifications module - qt.enable = true; # enable qt module - rofi.enable = true; # enable rofi module - screenshots = { - enable = true; # enable screenshots module - grim.enable = true; # enable grim screenshot tool - slurp.enable = true; # enable slurp region selection tool - satty.enable = false; # enable satty screenshot annotation tool - swappy.enable = true; # enable swappy screenshot editor - }; - wallpapers.enable = true; # enable wallpapers module - shell = { - enable = true; # enable shell module - zsh = { - enable = true; # enable zsh shell - plugins = [ "sudo" ]; # zsh plugins - configText = ""; # zsh config text - }; - bash.enable = false; # enable bash shell - fish.enable = false; # enable fish shell - pokego.enable = false; # enable Pokemon ASCII art scripts - p10k.enable = false; # enable p10k prompt - starship.enable = true; # enable starship prompt - }; - social = { - enable = true; # enable social module - discord.enable = true; # enable discord module - webcord.enable = true; # enable webcord module - vesktop.enable = true; # enable vesktop module - }; - spotify.enable = true; # enable spotify module - swww.enable = true; # enable swww wallpaper daemon - terminals = { - enable = true; # enable terminals module - kitty = { - enable = true; # enable kitty terminal - configText = ""; # kitty config text - }; - }; - theme = { - enable = true; # enable theme module - active = "Catppuccin Mocha"; # active theme name - themes = [ "Catppuccin Mocha" "Catppuccin Latte" ]; # default enabled themes, full list in https://github.com/richen604/hydenix/tree/main/hydenix/sources/themes - }; - waybar = { - enable = true; # enable waybar module - userStyle = ""; # custom waybar user-style.css - }; - wlogout.enable = true; # enable wlogout module - xdg.enable = true; # enable xdg module - }; -} -``` - -
- -
- - Back to Top - -
- -### What if I want to customize hydenix? - -Hydenix is designed to be customizable outside of the module options. Write your own modules, import your own flakes, packages, etc. - -If you need to disable any of the modules above in [module options](#what-are-the-module-options), simply disable the module and write your own configuration. Ideally referencing the module in the source code. - -Note however, it's very easy to overwrite hydenix defaults this way and may lead to bugs. Feel free to ask questions in our [Discord](https://discord.gg/AYbJ9MJez7) if you need help. - -
- - Back to Top - -
- -### What are some example configurations? - -Here's a list, feel free to make a PR to add your own! - -- [richen604/richendots](https://github.com/richen604/richendots) - -### How do I persist changes on reboot/rebuild/etc? - -> [!IMPORTANT] -> Do not edit any mutable files at runtime as they will be overwritten on rebuild
-> All edits must be done in your flake via nixos & home-manager options - -Some state files in HyDE are mutable by design. This allows certain theme changes during runtime. - -Example: - -Lets say you have the default theme set to `Catppuccin Mocha` in `hydenix.hm.theme.active`. - -You change a theme during runtime using `Meta + Shift + T` to `Catppuccin Latte`. -Your config is unchanged so when you reboot/relog/rebuild, the theme will revert to `Catppuccin Mocha`. - -```nix -{ - hydenix.hm.theme.active = "Catppuccin Mocha"; -} -``` - -Simply change the theme in your config to match your desired theme and rebuild. - -```nix -{ - hydenix.hm.theme.active = "Catppuccin Latte"; -} -``` - -But what about file you want to stop from reverting? waybar position or kitty config? -home-managers `home.file` allows you to do this - -```nix -# any file in `./modules/hm/` -{ - home.file = { - # copy kitty config to your template flake - # cp ~/.config/kitty/kitty.conf ~/path/to/flake/kitty.conf - ".config/kitty/kitty.conf" = { - source = ./kitty.conf; # path to your kitty config in your template flake - }; - # copy waybar position state to your template flake - # cp ~/.config/waybar/config.ctl ~/path/to/flake/config.ctl - ".config/waybar/config.ctl" = { - source = ./config.ctl; # path to your waybar config in your template flake - }; - }; -} -``` - -see [home.file options](https://home-manager-options.extranix.com/?query=home.file&release=master) for more information - -
- - Back to Top - -
- -### How do I add a new theme? - - - -### What is mutable.nix? - -> [!IMPORTANT] -> Do not edit any mutable files at runtime as they will be overwritten on rebuild
-> All edits must be done in your flake via nixos & home-manager options - -`mutable.nix` is a custom module that allows certain files to be copied instead of symlinked during system builds, making them writable at runtime. Key points: - -- Extends `home.file`, `xdg.configFile`, and `xdg.dataFile` with a `mutable` option -- Files marked as `mutable = true` (and `force = true`) will be writable -- Changes persist across rebuilds -- Useful for programs that need runtime configuration changes - -Example usage in scripts: - -```nix -home.activation = { - example = lib.hm.dag.entryAfter [ "mutableGeneration" ] '' - $DRY_RUN_CMD echo "example" - ''; -} -``` - -Credit: [@piousdeer](https://gist.github.com/piousdeer/b29c272eaeba398b864da6abf6cb5daa) - -
- - Back to Top - -
- -### Why do themes still show after I remove them from `hydenix.hm.theme.themes`? - -Themes are saved in `~/.config/hydenix/themes` so they will still show after you remove them from `hydenix.hm.theme.themes`. -To clear the saved themes, run `rm -rf ~/.config/hydenix/themes/THEME_NAME` for each theme you want to remove. - -
- - Back to Top - -
- -### Requesting features - -Please open a [feature request](https://github.com/richen604/hydenix/issues/new?template=feature_request.md) if you have any feature requests. - -
- - Back to Top - -
- -## Other FAQ - -### How do I run Hyprland in a VM? - -Hyprland vm is not well supported. check out [Hyprland - Running in a VM](https://wiki.hyprland.org/Getting-Started/Installation/#running-in-a-vm) - -Best bet is to have virtio, opengl, and VT-x support - -Non-NixOS hosts should run with [nixGL](https://github.com/nix-community/nixGL) eg `nixGL nix run .` - -
-Hardware Requirements -CPU - -- Intel CPU with VT-x or AMD CPU with AMD-V -- Virtualization enabled in BIOS/UEFI - -GPU - -- NVIDIA: GTX 600+ series (proprietary drivers) -- AMD: HD 7000+ series -- Intel: HD 4000+ (Ivy Bridge) -- OpenGL 3.3+ support required - -
- -
- -
-1. Install Drivers - -```bash -# Nvidia -sudo apt install nvidia-driver nvidia-utils # Debian/Ubuntu -sudo pacman -S nvidia nvidia-utils # Arch -# NixOS configuration -{ - hardware.graphics.enable = true; - hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; - hardware.nvidia.modesetting.enable = true; -} - -# AMD -sudo apt install mesa-utils vulkan-tools # Debian/Ubuntu -sudo pacman -S mesa lib32-mesa vulkan-radeon # Arch -# NixOS configuration -{ - hardware.graphics.enable = true; - hardware.graphics.extraPackages = with pkgs; [ amdvlk ]; -} - -# Intel -sudo apt install mesa-utils intel-media-va-driver # Debian/Ubuntu -sudo pacman -S mesa lib32-mesa intel-media-driver # Arch -# NixOS configuration -{ - hardware.graphics.enable = true; - hardware.graphics.extraPackages = with pkgs; [ intel-media-driver ]; -} - -# KVM modprobe -modprobe kvm -modprobe kvm_intel # or kvm_amd -# NixOS configuration -{ - boot.kernelModules = [ "kvm-intel" ]; # or "kvm-amd" for AMD processors - virtualisation.libvirtd.enable = true; -} -``` - -
- -
- -
-2. Verify Setup - -```bash -# Verify KVM support -egrep -c '(vmx|svm)' /proc/cpuinfo # Should return > 0 -lsmod | grep kvm # Check KVM modules - -# Host: Check OpenGL -glxinfo | grep "OpenGL" -``` - -
- -
- -
-3. Setup the VM - -To set up the VM, follow the instructions in the [Hyprland - Running in a VM](https://wiki.hyprland.org/Getting-Started/Installation/#running-in-a-vm) guide. - -Additionally, the following qemu options have been found to be successful: - -```bash --device virtio-vga-gl --display gtk,gl=on,grab-on-hover=on --usb -device usb-tablet --cpu host --enable-kvm --machine q35 --device intel-iommu --device ich9-intel-hda --device hda-output --vga none -``` - -
- -
- - Back to Top - -
\ No newline at end of file diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md deleted file mode 100644 index a2a1ba56..00000000 --- a/docs/troubleshooting.md +++ /dev/null @@ -1,34 +0,0 @@ -# Troubleshooting & Issues - -## Nix errors - -Nix errors can be tricky to diagnose, but the following information is required when creating an issue, please provide as much as possible. - -> [!TIP] -> rerun the command with `-v` to get more verbose output. -> you can also rerun the command with `--show-trace` to get a more detailed traceback. -> If the nix error is not clear, often the correct error message is somewhere in the *middle* of the error message. - -## System errors & bugs - -The following information is required when creating an issue, please provide as much as possible. -It's also possible to diagnose issues yourself with the information below. - -1. **System Logs** - - ```bash - journalctl -b # System logs - sudo systemctl status home-manager-$HOSTNAME.service # Home-manager status - ``` - -2. **System Information** - - ```bash - nix-shell -p nix-info --run "nix-info -m" - ``` - -3. **Configuration** - - Must have a github repo with your templated flake - -> [!NOTE] -> Custom modules and configurations have limited support. diff --git a/flake.lock b/flake.lock index 15d98adb..42e5abaa 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1751824240, - "narHash": "sha256-aDDC0CHTlL7QDKWWhdbEgVPK6KwWt+ca0QkmHYZxMzI=", + "lastModified": 1754365350, + "narHash": "sha256-NLWIkn1qM0wxtZu/2NXRaujWJ4Y1PSZlc7h0y6pOzOQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "fd9e55f5fac45a26f6169310afca64d56b681935", + "rev": "c5d7e957397ecb7d48b99c928611c6e780db1b56", "type": "github" }, "original": { @@ -60,11 +60,11 @@ ] }, "locked": { - "lastModified": 1751774635, - "narHash": "sha256-DuOznGdgMxeSlPpUu6Wkq0ZD5e2Cfv9XRZeZlHWMd1s=", + "lastModified": 1754195341, + "narHash": "sha256-YL71IEf2OugH3gmAsxQox6BJI0KOcHKtW2QqT/+s2SA=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "85686025ba6d18df31cc651a91d5adef63378978", + "rev": "b7fcd4e26d67fca48e77de9b0d0f954b18ae9562", "type": "github" }, "original": { @@ -75,11 +75,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1751432711, - "narHash": "sha256-136MeWtckSHTN9Z2WRNRdZ8oRP3vyx3L8UxeBYE+J9w=", + "lastModified": 1754316476, + "narHash": "sha256-Ry1gd1BQrNVJJfT11cpVP0FY8XFMx4DJV2IDp01CH9w=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "497ae1357f1ac97f1aea31a4cb74ad0d534ef41f", + "rev": "9368056b73efb46eb14fd4667b99e0f81b805f28", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9c80522c..f2a1280b 100644 --- a/flake.nix +++ b/flake.nix @@ -24,23 +24,21 @@ }; outputs = - { ... }@hydenix-pre-inputs: + inputs@{ hydenix-nixpkgs, ... }: let - # TODO: multi system support? system = "x86_64-linux"; - hydenix-inputs = hydenix-pre-inputs // { - pkgs = import hydenix-pre-inputs.hydenix-nixpkgs { - inherit system; - }; - lib = { - overlays = import ./hydenix/sources/overlay.nix { inputs = hydenix-pre-inputs; }; - nixOsModules = import ./hydenix/modules/system; - homeModules = import ./hydenix/modules/hm; - iso = import ./lib/iso/default.nix; - mkTheme = import ./hydenix/sources/themes/utils/mkTheme.nix; - inherit system; - }; + # Create lib attribute that template expects + lib = { + inherit system; + overlays = import ./hydenix/sources/overlay.nix { inherit inputs; }; + nixOsModules = ./hydenix/modules/system; + homeModules = ./hydenix/modules/hm; + }; + + # Internal inputs for building packages and configurations + hydenix-inputs = inputs // { + inherit lib; }; defaultConfig = import ./lib/config { @@ -53,78 +51,38 @@ inherit hydenix-inputs; }; - isoConfig = hydenix-inputs.lib.iso { - inherit hydenix-inputs; - }; - - isoVmConfig = import ./lib/vms/iso-vm.nix { - inherit hydenix-inputs; - }; - demoVmConfig = import ./lib/vms/demo-vm.nix { inherit hydenix-inputs; }; - hydevm = import ./lib/vms/hydevm/default.nix { - pkgs = hydenix-inputs.pkgs; - lib = hydenix-inputs.pkgs.lib; - }; - in { - lib = hydenix-inputs.lib; - - templates = { - default = { - path = ./template; - description = "Hydenix template"; - welcomeText = '' - ``` _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ - ``` - 1. edit `configuration.nix` with your preferences for hydenix - - visit https://github.com/richen604/hydenix for module documentation - 2. run `sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix` - 3. `git init && git add .` (flakes have to be managed via git) - 4. run any of the packages in your new `flake.nix` - - for rebuild, use `sudo nixos-rebuild switch --flake .` - 5. DON'T FORGET: change your password for all users with `passwd` from initialPassword set in `configuration.nix` - 6. NOTE: After rebuild, the first boot may take a while depending on how many `hydenix.hm.themes` are enabled, as the system generates cache. - ''; - }; + # Main API that template uses + # Will be depreciated in the next api update + inherit lib; + + # Direct module access + homeModules.default = ./hydenix/modules/hm; + nixosModules.default = ./hydenix/modules/system; + + overlays.default = import ./hydenix/sources/overlay.nix { inherit inputs; }; + + templates.default = { + path = ./template; + description = "Template for hydenix configuration"; }; + nixosConfigurations.default = defaultConfig; + packages.${system} = { # Use the VM configuration as default default = vmConfig.config.system.build.vm; - # Original NixOS configuration - nixos = defaultConfig.config.system.build.toplevel; - - # Explicitly named VM configuration - nixos-vm = vmConfig.config.system.build.vm; + # WIP: For a future demo installation & usage video demo-vm = demoVmConfig.config.system.build.vm; - # Demo VM configuration - iso-vm = isoVmConfig; - - # ISO configuration - iso = isoConfig.build-iso; - - # Add the burn-iso script as a package - burn-iso = isoConfig.burn-iso; - - # Add hyde-update package + # Helper to manage hyde updates hyde-update = import ./lib/hyde-update { inherit hydenix-inputs; }; - - # Add hydevm packages - hydevm = hydevm.defaultPackage; }; devShells.${system}.default = import ./lib/dev-shell.nix { inherit hydenix-inputs; }; diff --git a/hydenix/modules/hm/default.nix b/hydenix/modules/hm/default.nix index d70c0c75..331f22d3 100644 --- a/hydenix/modules/hm/default.nix +++ b/hydenix/modules/hm/default.nix @@ -15,7 +15,7 @@ ./gtk.nix ./git.nix ./hyde.nix - ./hyprland.nix + ./hyprland ./lockscreen.nix ./notifications.nix ./qt.nix diff --git a/hydenix/modules/hm/hyprland.nix b/hydenix/modules/hm/hyprland.nix deleted file mode 100644 index f5e21717..00000000 --- a/hydenix/modules/hm/hyprland.nix +++ /dev/null @@ -1,164 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -let - cfg = config.hydenix.hm.hyprland; -in -{ - - options.hydenix.hm.hyprland = { - enable = lib.mkOption { - type = lib.types.bool; - default = config.hydenix.hm.enable; - description = "Enable hyprland module"; - }; - - extraConfig = lib.mkOption { - type = lib.types.lines; - default = ""; - description = "Extra config for hyprland"; - }; - }; - - config = lib.mkIf cfg.enable { - home.packages = with pkgs; [ - hyprcursor - hyprutils - xdg-desktop-portal-hyprland - hyprpicker - hypridle - ]; - - home.activation.createHyprConfigs = lib.hm.dag.entryAfter [ "mutableGeneration" ] '' - mkdir -p "$HOME/.config/hypr/animations" - mkdir -p "$HOME/.config/hypr/themes" - - touch "$HOME/.config/hypr/animations/theme.conf" - touch "$HOME/.config/hypr/themes/colors.conf" - touch "$HOME/.config/hypr/themes/theme.conf" - touch "$HOME/.config/hypr/themes/wallbash.conf" - - chmod 644 "$HOME/.config/hypr/animations/theme.conf" - chmod 644 "$HOME/.config/hypr/themes/colors.conf" - chmod 644 "$HOME/.config/hypr/themes/theme.conf" - chmod 644 "$HOME/.config/hypr/themes/wallbash.conf" - ''; - - home.file = { - ".config/hypr/hyprland.conf" = { - source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/hyprland.conf"; - force = true; - }; - ".config/hypr/hyde.conf".source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/hyde.conf"; - ".config/hypr/keybindings.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/keybindings.conf"; - ".config/hypr/monitors.conf".source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/monitors.conf"; - ".config/hypr/nvidia.conf".source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/nvidia.conf"; - ".config/hypr/userprefs.conf" = { - text = '' - ${cfg.extraConfig} - ''; - force = true; - }; - ".config/hypr/windowrules.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/windowrules.conf"; - ".config/hypr/animations.conf" = { - source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations.conf"; - force = true; - mutable = true; - }; - ".config/hypr/animations/classic.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/classic.conf"; - ".config/hypr/animations/diablo-1.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/diablo-1.conf"; - ".config/hypr/animations/diablo-2.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/diablo-2.conf"; - ".config/hypr/animations/dynamic.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/dynamic.conf"; - ".config/hypr/animations/disable.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/disable.conf"; - ".config/hypr/animations/eevee-1.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/eevee-1.conf"; - ".config/hypr/animations/eevee-2.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/eevee-2.conf"; - ".config/hypr/animations/high.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/high.conf"; - ".config/hypr/animations/low-1.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/low-1.conf"; - ".config/hypr/animations/low-2.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/low-2.conf"; - ".config/hypr/animations/minimal-1.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/minimal-1.conf"; - ".config/hypr/animations/minimal-2.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/minimal-2.conf"; - ".config/hypr/animations/moving.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/moving.conf"; - ".config/hypr/animations/optimized.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/optimized.conf"; - ".config/hypr/animations/standard.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/standard.conf"; - ".config/hypr/animations/vertical.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/vertical.conf"; - ".config/hypr/animations/LimeFrenzy.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/LimeFrenzy.conf"; - ".config/hypr/hypridle.conf".source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/hypridle.conf"; - - # Shaders - ".config/hypr/shaders/blue-light-filter.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/blue-light-filter.frag"; - ".config/hypr/shaders/color-vision.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/color-vision.frag"; - ".config/hypr/shaders/.compiled.cache.glsl" = { - source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/.compiled.cache.glsl"; - force = true; - mutable = true; - }; - ".config/hypr/shaders.conf" = { - source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders.conf"; - force = true; - mutable = true; - }; - ".config/hypr/shaders/custom.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/custom.frag"; - ".config/hypr/shaders/disable.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/disable.frag"; - ".config/hypr/shaders/grayscale.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/grayscale.frag"; - ".config/hypr/shaders/invert-colors.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/invert-colors.frag"; - ".config/hypr/shaders/oled.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/oled.frag"; - ".config/hypr/shaders/oled-saver.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/oled-saver.frag"; - ".config/hypr/shaders/paper.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/paper.frag"; - ".config/hypr/shaders/vibrance.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/vibrance.frag"; - ".config/hypr/shaders/wallbash.frag".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/wallbash.frag"; - ".config/hypr/shaders/wallbash.inc".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/wallbash.inc"; - - # Workflows - ".config/hypr/workflows.conf" = { - source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows.conf"; - force = true; - mutable = true; - }; - ".config/hypr/workflows/default.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/default.conf"; - ".config/hypr/workflows/editing.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/editing.conf"; - ".config/hypr/workflows/gaming.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/gaming.conf"; - ".config/hypr/workflows/powersaver.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/powersaver.conf"; - ".config/hypr/workflows/snappy.conf".source = - "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/snappy.conf"; - }; - }; -} diff --git a/hydenix/modules/hm/hyprland/animations.nix b/hydenix/modules/hm/hyprland/animations.nix new file mode 100644 index 00000000..1b008750 --- /dev/null +++ b/hydenix/modules/hm/hyprland/animations.nix @@ -0,0 +1,73 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; + + animationPresets = [ + "LimeFrenzy" + "classic" + "diablo-1" + "diablo-2" + "disable" + "dynamic" + "end4" + "fast" + "high" + "ja" + "me-1" + "me-2" + "minimal-1" + "minimal-2" + "moving" + "optimized" + "standard" + "vertical" + ]; +in +{ + config = lib.mkIf (cfg.enable && cfg.animations.enable) { + home.file = lib.mkMerge [ + # Active animation preset + { + ".config/hypr/animations.conf" = + if cfg.animations.overrides ? ${cfg.animations.preset} then + { + text = '' + ${cfg.animations.overrides.${cfg.animations.preset}} + ${cfg.animations.extraConfig} + ''; + force = true; + mutable = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/${cfg.animations.preset}.conf"; + force = true; + mutable = true; + }; + } + + # All animation presets (with overrides) + (lib.listToAttrs ( + map (preset: { + name = ".config/hypr/animations/${preset}.conf"; + value = + if cfg.animations.overrides ? ${preset} then + { + text = cfg.animations.overrides.${preset}; + force = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/animations/${preset}.conf"; + }; + }) animationPresets + )) + ]; + }; +} diff --git a/hydenix/modules/hm/hyprland/assertions.nix b/hydenix/modules/hm/hyprland/assertions.nix new file mode 100644 index 00000000..6c193a07 --- /dev/null +++ b/hydenix/modules/hm/hyprland/assertions.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; + + # Collect all active overrides + activeOverrides = lib.filter (x: x != null && x != "") [ + (lib.optionalString (cfg.hypridle.overrideConfig != null) "hypridle.overrideConfig") + (lib.optionalString (cfg.keybindings.overrideConfig != null) "keybindings.overrideConfig") + (lib.optionalString (cfg.windowrules.overrideConfig != null) "windowrules.overrideConfig") + (lib.optionalString (cfg.nvidia.overrideConfig != null) "nvidia.overrideConfig") + (lib.optionalString (cfg.monitors.overrideConfig != null) "monitors.overrideConfig") + (lib.optionalString (cfg.overrideMain != null) "overrideMain") + ]; +in +{ + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = cfg.hypridle.overrideConfig == null || cfg.hypridle.overrideConfig != ""; + message = "hydenix.hm.hyprland.hypridle.overrideConfig is set but empty. This will override Hyde defaults and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + { + assertion = cfg.keybindings.overrideConfig == null || cfg.keybindings.overrideConfig != ""; + message = "hydenix.hm.hyprland.keybindings.overrideConfig is set but empty. This will override Hyde defaults and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + { + assertion = cfg.windowrules.overrideConfig == null || cfg.windowrules.overrideConfig != ""; + message = "hydenix.hm.hyprland.windowrules.overrideConfig is set but empty. This will override Hyde defaults and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + { + assertion = cfg.nvidia.overrideConfig == null || cfg.nvidia.overrideConfig != ""; + message = "hydenix.hm.hyprland.nvidia.overrideConfig is set but empty. This will override Hyde defaults and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + { + assertion = cfg.monitors.overrideConfig == null || cfg.monitors.overrideConfig != ""; + message = "hydenix.hm.hyprland.monitors.overrideConfig is set but empty. This will override Hyde defaults and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + { + assertion = cfg.overrideMain == null || cfg.overrideMain != ""; + message = "hydenix.hm.hyprland.overrideMain is set but empty. This will completely override Hyde's hyprland.conf and may break the system. Set to null to use Hyde defaults or provide valid configuration."; + } + ]; + + warnings = lib.optionals (cfg.enable && activeOverrides != [ ] && !cfg.suppressWarnings) [ + "hydenix.hm.hyprland: The following configs are overriding Hyde defaults. Note this may break hydenix, hope you know what you're doing! (set suppressWarnings = true to hide this warning): ${lib.concatStringsSep ", " activeOverrides}" + ]; + }; +} diff --git a/hydenix/modules/hm/hyprland/default.nix b/hydenix/modules/hm/hyprland/default.nix new file mode 100644 index 00000000..27f1d4c0 --- /dev/null +++ b/hydenix/modules/hm/hyprland/default.nix @@ -0,0 +1,73 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + imports = [ + ./options.nix + ./assertions.nix + ./animations.nix + ./shaders.nix + ./workflows.nix + ./hypridle.nix + ./keybindings.nix + ./windowrules.nix + ./nvidia.nix + ./monitors.nix + ]; + + config = lib.mkIf cfg.enable { + # Always include packages and base setup + home.packages = with pkgs; [ + hyprcursor + hyprutils + xdg-desktop-portal-hyprland + hyprpicker + hypridle + ]; + + home.activation.createHyprConfigs = lib.hm.dag.entryAfter [ "mutableGeneration" ] '' + mkdir -p "$HOME/.config/hypr/animations" + mkdir -p "$HOME/.config/hypr/themes" + mkdir -p "$HOME/.config/hypr/shaders" + mkdir -p "$HOME/.config/hypr/workflows" + + touch "$HOME/.config/hypr/animations/theme.conf" + touch "$HOME/.config/hypr/themes/colors.conf" + touch "$HOME/.config/hypr/themes/theme.conf" + touch "$HOME/.config/hypr/themes/wallbash.conf" + + chmod 644 "$HOME/.config/hypr/animations/theme.conf" + chmod 644 "$HOME/.config/hypr/themes/colors.conf" + chmod 644 "$HOME/.config/hypr/themes/theme.conf" + chmod 644 "$HOME/.config/hypr/themes/wallbash.conf" + ''; + + home.file = { + ".config/hypr/hyprland.conf" = + if cfg.overrideMain != null then + { + text = cfg.overrideMain; + force = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/hyprland.conf"; + force = true; + }; + + ".config/hypr/hyde.conf".source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/hyde.conf"; + + ".config/hypr/userprefs.conf" = { + text = cfg.extraConfig; + force = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/hypridle.nix b/hydenix/modules/hm/hyprland/hypridle.nix new file mode 100644 index 00000000..b80b4054 --- /dev/null +++ b/hydenix/modules/hm/hyprland/hypridle.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + config = lib.mkIf (cfg.enable && cfg.hypridle.enable) { + home.file = { + ".config/hypr/hypridle.conf" = + if cfg.hypridle.overrideConfig != null then + { + text = cfg.hypridle.overrideConfig; + force = true; + } + else + { + text = '' + ${lib.readFile "${pkgs.hydenix.hyde}/Configs/.config/hypr/hypridle.conf"} + ${cfg.hypridle.extraConfig} + ''; + force = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/keybindings.nix b/hydenix/modules/hm/hyprland/keybindings.nix new file mode 100644 index 00000000..dfe5f7de --- /dev/null +++ b/hydenix/modules/hm/hyprland/keybindings.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + config = lib.mkIf (cfg.enable && cfg.keybindings.enable) { + home.file = { + ".config/hypr/keybindings.conf" = + if cfg.keybindings.overrideConfig != null then + { + text = cfg.keybindings.overrideConfig; + force = true; + } + else + { + text = '' + ${lib.readFile "${pkgs.hydenix.hyde}/Configs/.config/hypr/keybindings.conf"} + ${cfg.keybindings.extraConfig} + ''; + force = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/monitors.nix b/hydenix/modules/hm/hyprland/monitors.nix new file mode 100644 index 00000000..7bd962f3 --- /dev/null +++ b/hydenix/modules/hm/hyprland/monitors.nix @@ -0,0 +1,29 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + config = lib.mkIf (cfg.enable && cfg.monitors.enable) { + home.file = { + ".config/hypr/monitors.conf" = + if cfg.monitors.overrideConfig != null then + { + text = cfg.monitors.overrideConfig; + force = true; + mutable = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/monitors.conf"; + force = true; + mutable = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/nvidia.nix b/hydenix/modules/hm/hyprland/nvidia.nix new file mode 100644 index 00000000..11842ac6 --- /dev/null +++ b/hydenix/modules/hm/hyprland/nvidia.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + config = lib.mkIf (cfg.enable && cfg.nvidia.enable) { + home.file = { + ".config/hypr/nvidia.conf" = + if cfg.nvidia.overrideConfig != null then + { + text = cfg.nvidia.overrideConfig; + force = true; + } + else + { + text = '' + ${lib.readFile "${pkgs.hydenix.hyde}/Configs/.config/hypr/nvidia.conf"} + ${cfg.nvidia.extraConfig} + ''; + force = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/options.nix b/hydenix/modules/hm/hyprland/options.nix new file mode 100644 index 00000000..e960841e --- /dev/null +++ b/hydenix/modules/hm/hyprland/options.nix @@ -0,0 +1,211 @@ +{ + config, + lib, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + options.hydenix.hm.hyprland = { + enable = lib.mkOption { + type = lib.types.bool; + default = config.hydenix.hm.enable; + description = "Enable hyprland module"; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Extra config appended to userprefs.conf"; + }; + overrideMain = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete override of hyprland.conf"; + }; + suppressWarnings = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Suppress warnings about configuration overrides"; + }; + + # Animation configurations + animations = { + enable = lib.mkEnableOption "animation configurations" // { + default = cfg.enable; + }; + preset = lib.mkOption { + type = lib.types.enum [ + "LimeFrenzy" + "classic" + "diablo-1" + "diablo-2" + "disable" + "dynamic" + "end4" + "fast" + "high" + "ja" + "me-1" + "me-2" + "minimal-1" + "minimal-2" + "moving" + "optimized" + "standard" + "vertical" + ]; + default = "standard"; + description = "Animation preset to use"; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional animation configuration"; + }; + overrides = lib.mkOption { + type = lib.types.attrsOf lib.types.lines; + default = { }; + description = "Override specific animation files by name"; + example = lib.literalExpression '' + { + "classic" = ''' + animation = windows, 1, 5, default + '''; + } + ''; + }; + }; + + # Shader configurations + shaders = { + enable = lib.mkEnableOption "shader configurations" // { + default = cfg.enable; + }; + overrides = lib.mkOption { + type = lib.types.attrsOf lib.types.lines; + default = { }; + description = "Override or add custom shaders"; + example = lib.literalExpression '' + { + "my-filter.frag" = ''' + precision mediump float; + // Custom shader code + '''; + } + ''; + }; + }; + + # Workflow configurations + workflows = { + enable = lib.mkEnableOption "workflow configurations" // { + default = cfg.enable; + }; + active = lib.mkOption { + type = lib.types.enum [ + "default" + "editing" + "gaming" + "powersaver" + "snappy" + ]; + default = "default"; + description = "Active workflow preset"; + }; + overrides = lib.mkOption { + type = lib.types.attrsOf lib.types.lines; + default = { }; + description = "Override or add custom workflows"; + example = lib.literalExpression '' + { + "my-workflow.conf" = ''' + // Custom workflow configuration + '''; + } + ''; + }; + }; + + # Hypridle configurations + hypridle = { + enable = lib.mkEnableOption "hypridle configurations" // { + default = cfg.enable; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional hypridle configuration"; + }; + overrideConfig = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete hypridle configuration override"; + }; + }; + + # Keybindings configurations + keybindings = { + enable = lib.mkEnableOption "keybindings configurations" // { + default = cfg.enable; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional keybindings configuration"; + }; + overrideConfig = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete keybindings configuration override"; + }; + }; + + # Window rules configurations + windowrules = { + enable = lib.mkEnableOption "window rules configurations" // { + default = cfg.enable; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional window rules configuration"; + }; + overrideConfig = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete window rules configuration override"; + }; + }; + + # NVIDIA configurations + nvidia = { + enable = lib.mkEnableOption "NVIDIA configurations" // { + default = config.hardware.nvidia.enabled or false; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional NVIDIA configuration"; + }; + overrideConfig = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete NVIDIA configuration override"; + }; + }; + + # Monitor configurations + monitors = { + enable = lib.mkEnableOption "monitor configurations" // { + default = cfg.enable; + }; + overrideConfig = lib.mkOption { + type = lib.types.nullOr lib.types.lines; + default = null; + description = "Complete monitor configuration override"; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/shaders.nix b/hydenix/modules/hm/hyprland/shaders.nix new file mode 100644 index 00000000..223eefc1 --- /dev/null +++ b/hydenix/modules/hm/hyprland/shaders.nix @@ -0,0 +1,67 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; + + standardShaders = [ + "blue-light-filter" + "color-vision" + "custom" + "disable" + "grayscale" + "invert-colors" + "oled" + "oled-saver" + "paper" + "vibrance" + "wallbash" + ]; +in +{ + config = lib.mkIf (cfg.enable && cfg.shaders.enable) { + home.file = lib.mkMerge [ + # Standard shaders (generated from list) + (lib.mkMerge [ + # Generate standard shader files from list + (lib.listToAttrs ( + map (shader: { + name = ".config/hypr/shaders/${shader}.frag"; + value = { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/${shader}.frag"; + }; + }) standardShaders + )) + + # Additional shader files + { + ".config/hypr/shaders/.compiled.cache.glsl" = { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/.compiled.cache.glsl"; + force = true; + mutable = true; + }; + ".config/hypr/shaders.conf" = { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders.conf"; + force = true; + mutable = true; + }; + ".config/hypr/shaders/wallbash.inc".source = + "${pkgs.hydenix.hyde}/Configs/.config/hypr/shaders/wallbash.inc"; + } + ]) + + # Custom/override shaders + (lib.mapAttrs' (name: content: { + name = ".config/hypr/shaders/${name}"; + value = { + text = content; + force = true; + }; + }) cfg.shaders.overrides) + ]; + }; +} diff --git a/hydenix/modules/hm/hyprland/windowrules.nix b/hydenix/modules/hm/hyprland/windowrules.nix new file mode 100644 index 00000000..889ba059 --- /dev/null +++ b/hydenix/modules/hm/hyprland/windowrules.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; +in +{ + config = lib.mkIf (cfg.enable && cfg.windowrules.enable) { + home.file = { + ".config/hypr/windowrules.conf" = + if cfg.windowrules.overrideConfig != null then + { + text = cfg.windowrules.overrideConfig; + force = true; + } + else + { + text = '' + ${lib.readFile "${pkgs.hydenix.hyde}/Configs/.config/hypr/windowrules.conf"} + ${cfg.windowrules.extraConfig} + ''; + force = true; + }; + }; + }; +} diff --git a/hydenix/modules/hm/hyprland/workflows.nix b/hydenix/modules/hm/hyprland/workflows.nix new file mode 100644 index 00000000..241bb93c --- /dev/null +++ b/hydenix/modules/hm/hyprland/workflows.nix @@ -0,0 +1,66 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hydenix.hm.hyprland; + + workflowPresets = [ + "default" + "editing" + "gaming" + "powersaver" + "snappy" + ]; +in +{ + config = lib.mkIf (cfg.enable && cfg.workflows.enable) { + home.file = lib.mkMerge [ + # Active workflow + { + ".config/hypr/workflows.conf" = + if cfg.workflows.overrides ? ${cfg.workflows.active} then + { + text = cfg.workflows.overrides.${cfg.workflows.active}; + force = true; + mutable = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/${cfg.workflows.active}.conf"; + force = true; + mutable = true; + }; + } + + # All workflow presets (with overrides) + (lib.listToAttrs ( + map (workflow: { + name = ".config/hypr/workflows/${workflow}.conf"; + value = + if cfg.workflows.overrides ? ${workflow} then + { + text = cfg.workflows.overrides.${workflow}; + force = true; + } + else + { + source = "${pkgs.hydenix.hyde}/Configs/.config/hypr/workflows/${workflow}.conf"; + }; + }) workflowPresets + )) + + # Custom workflows (exclude the standard presets) + (lib.mapAttrs' (name: content: { + name = ".config/hypr/workflows/${name}.conf"; + value = { + text = content; + force = true; + }; + }) (lib.filterAttrs (name: _: !(lib.elem name workflowPresets)) cfg.workflows.overrides)) + ]; + }; +} diff --git a/hydenix/modules/hm/shell.nix b/hydenix/modules/hm/shell.nix index ab178c05..bc461b84 100644 --- a/hydenix/modules/hm/shell.nix +++ b/hydenix/modules/hm/shell.nix @@ -93,8 +93,8 @@ in fastfetch ] ++ lib.optionals (cfg.zsh.enable || cfg.fish.enable) [ - eza - duf + eza + duf ] ++ lib.optionals cfg.zsh.enable [ zsh @@ -117,28 +117,138 @@ in enable = true; plugins = cfg.zsh.plugins; }; - initContent = '' - ${lib.optionalString cfg.pokego.enable '' - pokego --no-title -r 1,3,6 - ''} - ${lib.optionalString cfg.starship.enable '' - eval "$(${pkgs.starship}/bin/starship init zsh)" - export STARSHIP_CACHE=$XDG_CACHE_HOME/starship - export STARSHIP_CONFIG=$XDG_CONFIG_HOME/starship/starship.toml - ''} - ${lib.optionalString cfg.p10k.enable '' - # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. - # Initialization code that may require console input (password prompts, [y/n] - # confirmations, etc.) must go above this block; everything else may go below. - if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then - source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" - fi - source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme - ''} - ${lib.optionalString cfg.fastfetch.enable '' - fastfetch --logo-type kitty - ''} - ''; + + # Custom shell aliases integrated into programs.zsh + shellAliases = { + c = "clear"; + vc = "code"; + fastfetch = "fastfetch --logo-type kitty"; + ".." = "cd .."; + "..." = "cd ../.."; + ".3" = "cd ../../.."; + ".4" = "cd ../../../.."; + ".5" = "cd ../../../../.."; + mkdir = "mkdir -p"; + ffec = "_fuzzy_edit_search_file_content"; + ffcd = "_fuzzy_change_directory"; + ffe = "_fuzzy_edit_search_file"; + df = "_df"; + }; + + # Using the new initContent API with proper ordering + initContent = lib.mkMerge [ + # Early initialization (before completion init) - order 550 + (lib.mkOrder 550 '' + #!/usr/bin/env zsh + function no_such_file_or_directory_handler { + local red='\e[1;31m' reset='\e[0m' + printf "''${red}zsh: no such file or directory: %s''${reset}\n" "$1" + return 127 + } + + # best fzf aliases ever + _fuzzy_change_directory() { + local initial_query="$1" + local selected_dir + local fzf_options=('--preview=ls -p {}' '--preview-window=right:60%') + fzf_options+=(--height "80%" --layout=reverse --preview-window right:60% --cycle) + local max_depth=7 + + if [[ -n "$initial_query" ]]; then + fzf_options+=("--query=$initial_query") + fi + + #type -d + selected_dir=$(find . -maxdepth $max_depth \( -name .git -o -name node_modules -o -name .venv -o -name target -o -name .cache \) -prune -o -type d -print 2>/dev/null | fzf "''${fzf_options[@]}") + + if [[ -n "$selected_dir" && -d "$selected_dir" ]]; then + cd "$selected_dir" || return 1 + else + return 1 + fi + } + + _fuzzy_edit_search_file_content() { + # [f]uzzy [e]dit [s]earch [f]ile [c]ontent + local selected_file + selected_file=$(grep -irl "''${1:-}" ./ | fzf --height "80%" --layout=reverse --preview-window right:60% --cycle --preview 'cat {}' --preview-window right:60%) + + if [[ -n "$selected_file" ]]; then + if command -v "$EDITOR" &>/dev/null; then + "$EDITOR" "$selected_file" + else + echo "EDITOR is not specified. using vim. (you can export EDITOR in ~/.zshrc)" + vim "$selected_file" + fi + else + echo "No file selected or search returned no results." + fi + } + + _fuzzy_edit_search_file() { + local initial_query="$1" + local selected_file + local fzf_options=() + fzf_options+=(--height "80%" --layout=reverse --preview-window right:60% --cycle) + local max_depth=5 + + if [[ -n "$initial_query" ]]; then + fzf_options+=("--query=$initial_query") + fi + + # -type f: only find files + selected_file=$(find . -maxdepth $max_depth -type f 2>/dev/null | fzf "''${fzf_options[@]}") + + if [[ -n "$selected_file" && -f "$selected_file" ]]; then + if command -v "$EDITOR" &>/dev/null; then + "$EDITOR" "$selected_file" + else + echo "EDITOR is not specified. using vim. (you can export EDITOR in ~/.zshrc)" + vim "$selected_file" + fi + else + return 1 + fi + } + + _df() { + if [[ $# -ge 1 && -e "''${@: -1}" ]]; then + duf "''${@: -1}" + else + duf + fi + } + + # Some binds won't work on first prompt when deferred + bindkey '\e[H' beginning-of-line + bindkey '\e[F' end-of-line + '') + + # Regular initialization content + '' + ${lib.optionalString cfg.pokego.enable '' + pokego --no-title -r 1,3,6 + ''} + ${lib.optionalString cfg.starship.enable '' + eval "$(${pkgs.starship}/bin/starship init zsh)" + export STARSHIP_CACHE=$XDG_CACHE_HOME/starship + export STARSHIP_CONFIG=$XDG_CONFIG_HOME/starship/starship.toml + ''} + ${lib.optionalString cfg.p10k.enable '' + # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. + # Initialization code that may require console input (password prompts, [y/n] + # confirmations, etc.) must go above this block; everything else may go below. + if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then + source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" + fi + source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme + ''} + ${lib.optionalString cfg.fastfetch.enable '' + fastfetch --logo-type kitty + ''} + ${cfg.zsh.configText} + '' + ]; }; programs.fish = lib.mkIf cfg.fish.enable { @@ -147,10 +257,10 @@ in interactiveShellInit = '' # Disable greeting set -g fish_greeting - + # Source Hyde configuration source ${pkgs.hydenix.hyde}/Configs/.config/fish/hyde_config.fish - + ${lib.optionalString cfg.starship.enable '' if type -q starship starship init fish | source @@ -158,20 +268,20 @@ in set -gx STARSHIP_CONFIG $XDG_CONFIG_HOME/starship/starship.toml end ''} - + # fzf integration if type -q fzf fzf --fish | source end - + # Color settings set fish_pager_color_prefix cyan set fish_color_autosuggestion brblack - + ${lib.optionalString cfg.pokego.enable '' pokego --no-title -r 1,3,6 ''} - + ${lib.optionalString cfg.fastfetch.enable '' fastfetch --logo-type kitty ''} @@ -196,115 +306,6 @@ in home.file = lib.mkMerge [ (lib.mkIf cfg.zsh.enable { - # Shell configs - ".zshrc".text = '' - ${cfg.zsh.configText} - ''; - - # we are writing our own .zshenv/hyde.zshrc file to ensure that its properly sourcing nix paths, and removes all the arch nonsense - ".zshenv".text = '' - #!/usr/bin/env zsh - function no_such_file_or_directory_handler { - local red='\e[1;31m' reset='\e[0m' - printf "''${red}zsh: no such file or directory: %s''${reset}\n" "$1" - return 127 - } - - # best fzf aliases ever - _fuzzy_change_directory() { - local initial_query="$1" - local selected_dir - local fzf_options=('--preview=ls -p {}' '--preview-window=right:60%') - fzf_options+=(--height "80%" --layout=reverse --preview-window right:60% --cycle) - local max_depth=7 - - if [[ -n "$initial_query" ]]; then - fzf_options+=("--query=$initial_query") - fi - - #type -d - selected_dir=$(find . -maxdepth $max_depth \( -name .git -o -name node_modules -o -name .venv -o -name target -o -name .cache \) -prune -o -type d -print 2>/dev/null | fzf "''${fzf_options[@]}") - - if [[ -n "$selected_dir" && -d "$selected_dir" ]]; then - cd "$selected_dir" || return 1 - else - return 1 - fi - } - - _fuzzy_edit_search_file_content() { - # [f]uzzy [e]dit [s]earch [f]ile [c]ontent - local selected_file - selected_file=$(grep -irl "''${1:-}" ./ | fzf --height "80%" --layout=reverse --preview-window right:60% --cycle --preview 'cat {}' --preview-window right:60%) - - if [[ -n "$selected_file" ]]; then - if command -v "$EDITOR" &>/dev/null; then - "$EDITOR" "$selected_file" - else - echo "EDITOR is not specified. using vim. (you can export EDITOR in ~/.zshrc)" - vim "$selected_file" - fi - - else - echo "No file selected or search returned no results." - fi - } - - _fuzzy_edit_search_file() { - local initial_query="$1" - local selected_file - local fzf_options=() - fzf_options+=(--height "80%" --layout=reverse --preview-window right:60% --cycle) - local max_depth=5 - - if [[ -n "$initial_query" ]]; then - fzf_options+=("--query=$initial_query") - fi - - # -type f: only find files - selected_file=$(find . -maxdepth $max_depth -type f 2>/dev/null | fzf "''${fzf_options[@]}") - - if [[ -n "$selected_file" && -f "$selected_file" ]]; then - if command -v "$EDITOR" &>/dev/null; then - "$EDITOR" "$selected_file" - else - echo "EDITOR is not specified. using vim. (you can export EDITOR in ~/.zshrc)" - vim "$selected_file" - fi - else - return 1 - fi - } - - _df() { - if [[ $# -ge 1 && -e "''${@: -1}" ]]; then - duf "''${@: -1}" - else - duf - fi - } - - - alias c='clear' \ - vc='code' \ - fastfetch='fastfetch --logo-type kitty' \ - ..='cd ..' \ - ...='cd ../..' \ - .3='cd ../../..' \ - .4='cd ../../../..' \ - .5='cd ../../../../..' \ - mkdir='mkdir -p' \ - ffec='_fuzzy_edit_search_file_content' \ - ffcd='_fuzzy_change_directory' \ - ffe='_fuzzy_edit_search_file' \ - df='_df' - - # Some binds won't work on first prompt when deferred - bindkey '\e[H' beginning-of-line - bindkey '\e[F' end-of-line - - ''; - ".p10k.zsh" = { source = "${pkgs.hydenix.hyde}/Configs/.p10k.zsh"; enable = cfg.p10k.enable; @@ -313,7 +314,8 @@ in (lib.mkIf cfg.fish.enable { # Fish configs - ".config/fish/hyde_config.fish".source = "${pkgs.hydenix.hyde}/Configs/.config/fish/hyde_config.fish"; + ".config/fish/hyde_config.fish".source = + "${pkgs.hydenix.hyde}/Configs/.config/fish/hyde_config.fish"; ".config/fish/functions/df.fish".source = "${pkgs.hydenix.hyde}/Configs/.config/fish/functions/df.fish"; ".config/fish/functions/ffcd.fish".source = diff --git a/hydenix/sources/overlay.nix b/hydenix/sources/overlay.nix index 4a9bf729..2ee43409 100644 --- a/hydenix/sources/overlay.nix +++ b/hydenix/sources/overlay.nix @@ -6,12 +6,9 @@ let # Define all packages packages = { # Hyde core packages - hyde-cli = callPackage ./hyde-cli.nix { }; hyde-gallery = callPackage ./hyde-gallery.nix { }; - hyprdots = callPackage ./hyprdots.nix { }; # Additional packages pokego = callPackage ./pokego.nix { }; - pokemon-colorscripts = callPackage ./pokemon-colorscripts.nix { }; python-pyamdgpuinfo = callPackage ./python-pyamdgpuinfo.nix { }; Tela-circle-dracula = callPackage ./Tela-circle-dracula.nix { }; Bibata-Modern-Ice = callPackage ./Bibata-Modern-Ice.nix { }; diff --git a/hydenix/sources/themes/Moonlight.nix b/hydenix/sources/themes/Moonlight.nix index e2248d98..95587962 100644 --- a/hydenix/sources/themes/Moonlight.nix +++ b/hydenix/sources/themes/Moonlight.nix @@ -6,7 +6,7 @@ mkTheme rec { repo = "Moonlight"; rev = "main"; name = name; - sha256 = "sha256-e3qgwSzmKQnhzEsvdFmOlI8lv55XddTsNIEf6Aig5uM="; + sha256 = "sha256-1ZzLxHREUJqm/ckcsmc/95ka4PyoCRR9FF+xoH+egro="; }; meta = { description = "HyDE Theme: Moonlight"; diff --git a/hydenix/sources/themes/Piece-Of-Mind.nix b/hydenix/sources/themes/Piece-Of-Mind.nix index 8270315b..051466f4 100644 --- a/hydenix/sources/themes/Piece-Of-Mind.nix +++ b/hydenix/sources/themes/Piece-Of-Mind.nix @@ -6,7 +6,7 @@ mkTheme rec { repo = "Piece-Of-Mind"; rev = "main"; name = name; - sha256 = "sha256-eOnAOY/VERojV3TrHMtrDPtXsYPi3p4mz5InAt1Q7xo="; + sha256 = "sha256-KpFxJZBD6uvfpnrafW5wDfXRPOQXdxUCaT7pINb4IHI="; }; meta = { name = name; diff --git a/lib/config/default.nix b/lib/config/default.nix index 4f33352f..a3a9423c 100644 --- a/lib/config/default.nix +++ b/lib/config/default.nix @@ -4,7 +4,7 @@ }: hydenix-inputs.hydenix-nixpkgs.lib.nixosSystem { - inherit (hydenix-inputs.lib) system; + system = "x86_64-linux"; specialArgs = { inherit hydenix-inputs; }; diff --git a/lib/dev-shell.nix b/lib/dev-shell.nix index f6716650..9ca2f927 100644 --- a/lib/dev-shell.nix +++ b/lib/dev-shell.nix @@ -1,8 +1,9 @@ { hydenix-inputs }: let + system = "x86_64-linux"; pkgs = import hydenix-inputs.hydenix-nixpkgs { - inherit (hydenix-inputs.lib) system; + inherit system; config.allowUnfree = true; }; in diff --git a/lib/hyde-update/default.nix b/lib/hyde-update/default.nix index c135eae9..0dabb5ee 100644 --- a/lib/hyde-update/default.nix +++ b/lib/hyde-update/default.nix @@ -3,8 +3,9 @@ }: let + system = "x86_64-linux"; pkgs = import hydenix-inputs.hydenix-nixpkgs { - inherit (hydenix-inputs.lib) system; + inherit system; config.allowUnfree = true; }; diff --git a/lib/iso/default.nix b/lib/iso/default.nix deleted file mode 100644 index 795606d1..00000000 --- a/lib/iso/default.nix +++ /dev/null @@ -1,326 +0,0 @@ -{ - hydenix-inputs, - flakePath ? null, - ... -}: -let - - hydenix-pkgs = import hydenix-inputs.hydenix-nixpkgs { - inherit (hydenix-inputs.lib) system; - config.allowUnfree = true; - overlays = [ - hydenix-inputs.lib.overlays - ]; - }; - - # Add the ISO image module - isoImageModule = "${hydenix-inputs.hydenix-nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; - - # Create the base ISO configuration - isoSystem = hydenix-inputs.hydenix-nixpkgs.lib.nixosSystem { - inherit (hydenix-inputs.lib) system; - modules = [ - isoImageModule - { - # Explicitly allow unfree packages in the ISO - nixpkgs.config.allowUnfree = true; - - # Enable nix experimental features - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - # Live USB settings - isoImage.makeEfiBootable = true; - isoImage.makeUsbBootable = true; - isoImage.squashfsCompression = "zstd -Xcompression-level 6"; # Better compression ratio and speed - - # ISO-specific configuration - isoImage = { - edition = hydenix-pkgs.lib.mkForce "hydenix"; - isoBaseName = hydenix-pkgs.lib.mkForce "hydenix"; - isoName = hydenix-pkgs.lib.mkForce "hydenix.iso"; - volumeID = hydenix-pkgs.lib.mkForce "HYDENIX"; - }; - - # Improve boot experience - boot.kernelParams = [ - # Better hardware compatibility - "nomodeset" - "i915.modeset=1" - "nouveau.modeset=1" - # Improve boot messages - "boot.shell_on_fail" - # Memory management improvements - "zswap.enabled=1" - ]; - - # Better hardware support - hardware.enableRedistributableFirmware = true; - hardware.enableAllFirmware = true; - - # Add installation script and required packages to ISO - environment.systemPackages = with hydenix-pkgs; [ - (writeScriptBin "hydenix-install" (builtins.readFile ./nixos-install.sh)) - # Required by installation script - fzf - parted - dosfstools # for mkfs.fat - e2fsprogs # for mkfs.ext4 - util-linux # for wipefs, lsblk - util-linux.bin - git - vim - nano # More beginner-friendly editor - curl - wget - htop # System monitoring - - # Networking tools - networkmanager # Includes nmcli - iw - wirelesstools - - # Hardware detection and management - pciutils # for lspci - usbutils # for lsusb - dmidecode # for system information - - # Filesystem tools - gptfdisk # for gdisk/sgdisk (advanced partitioning) - ntfs3g # for NTFS support (dual-boot scenarios) - btrfs-progs # for btrfs support - xfsprogs # for XFS support - - # Compression tools - gzip - bzip2 - xz - zip - unzip - - # Troubleshooting tools - lshw # List hardware - smartmontools # Disk health - - # Documentation - man-pages - man-pages-posix - ]; - - # Enable NetworkManager - networking.networkmanager.enable = true; - networking.wireless.enable = false; # Disable wpa_supplicant as we're using NetworkManager - - # Better hardware support - services.xserver.videoDrivers = [ - "modesetting" - "fbdev" - "vesa" - ]; - services.fwupd.enable = true; # Firmware updates - - # Improve console experience - console = { - font = "Lat2-Terminus16"; - keyMap = hydenix-pkgs.lib.mkForce "us"; - useXkbConfig = true; - }; - - # Copy installation script to home directory - system.activationScripts.copyTemplate = - let - # This allows us to use this script for both the default ISO and user template flake - configPath = if flakePath == null then ../../template else flakePath; - in - '' - mkdir -p /home/nixos - cp -r ${configPath} /home/nixos/hydenix - chmod -R u+w /home/nixos/hydenix - chown -R nixos:nixos /home/nixos/hydenix - - # Create a helpful README in the home directory - cat > /home/nixos/README.txt << 'EOF' - HydeNix Installation Guide - ========================= - - Quick Start: - 1. Run 'hydenix-install' for guided installation - - For WiFi: - - Run 'nmtui' for a text-based network manager - - Or use 'nmcli device wifi connect password ' - - For troubleshooting: - - Check hardware: lspci, lsusb, lshw - - Check disks: fdisk -l, smartctl -a /dev/sdX - - Check logs: journalctl -xe - - Need more help? Visit: https://github.com/richen604/hydenix - EOF - - chmod 644 /home/nixos/README.txt - chown nixos:nixos /home/nixos/README.txt - ''; - - # Display welcome message and instructions at boot - services.getty.helpLine = '' - Welcome to HydeNix! 💻 - - WiFi Setup: - - Use 'nmtui' for text-based network configuration - - Or use 'nmcli device wifi connect password ' - - To start the installation: - 1. Run 'hydenix-install' to start the guided installation - 2. Follow the on-screen prompts - - For help, read /home/nixos/README.txt or visit: https://github.com/richen604/hydeni - ''; - - # Better internationalization support - i18n = { - supportedLocales = [ "all" ]; - defaultLocale = "en_US.UTF-8"; - }; - - # Auto-login for live system - services.getty.autologinUser = "nixos"; - - # Set timezone to UTC by default - time.timeZone = "UTC"; - } - ]; - }; -in -{ - - # Add a build-iso script that can be run with 'nix run' - build-iso = hydenix-pkgs.writeScriptBin "build-iso" '' - #!/usr/bin/env bash - set -euo pipefail - - # Colors for output - GREEN='\033[0;32m' - BLUE='\033[0;34m' - NC='\033[0m' # No Color - - # Get the actual ISO path - ISO_DIR="${isoSystem.config.system.build.isoImage}" - - echo -e "''${BLUE}Building HydeNix ISO...''${NC}" - echo -e "''${BLUE}This may take a while depending on your system.''${NC}" - - # Create the output directory if it doesn't exist - mkdir -p ./result - - # Find the ISO file - if [ -d "$ISO_DIR/iso" ]; then - ISO_PATH=$(find "$ISO_DIR/iso" -name "*.iso" -type f) - else - ISO_PATH=$(find "$ISO_DIR" -name "*.iso" -type f) - fi - - if [ -z "$ISO_PATH" ]; then - echo -e "''${RED}Error: Could not find ISO file in $ISO_DIR''${NC}" - echo "Directory contents:" - find "$ISO_DIR" -type f | sort - exit 1 - fi - - # Copy the ISO to the current directory - echo -e "''${BLUE}Copying ISO to ./result directory...''${NC}" - cp -v "$ISO_PATH" ./result/ - - ISO_FILENAME=$(basename "$ISO_PATH") - - echo -e "''${GREEN}ISO built successfully!''${NC}" - echo -e "''${BLUE}Your ISO is available at:''${NC} ./result/$ISO_FILENAME" - echo - echo -e "''${BLUE}To burn this ISO to a USB drive, you can use:''${NC}" - echo "nix run .#burn-iso -- ./result/$ISO_FILENAME /dev/sdX" - echo -e "''${BLUE}(Replace /dev/sdX with your USB device)''${NC}" - ''; - - burn-iso = hydenix-pkgs.writeScriptBin "burn-iso" '' - #!/usr/bin/env bash - set -euo pipefail - - # Colors for output - RED='\033[0;31m' - GREEN='\033[0;32m' - BLUE='\033[0;34m' - NC='\033[0m' # No Color - - if [ $# -ne 2 ]; then - echo -e "''${BLUE}Usage:''${NC} burn-iso " - echo -e "''${BLUE}Example:''${NC} burn-iso hydenix.iso /dev/sdb" - echo -e "\n''${BLUE}Available devices:''${NC}" - lsblk -d -o NAME,SIZE,TYPE,MODEL,MOUNTPOINT - exit 1 - fi - - ISO_FILE=$1 - DEVICE=$2 - - if [ ! -f "$ISO_FILE" ]; then - echo -e "''${RED}Error: ISO file '$ISO_FILE' not found''${NC}" - exit 1 - fi - - # Check if device exists - if [ ! -b "$DEVICE" ]; then - echo -e "''${RED}Error: Device '$DEVICE' does not exist or is not a block device''${NC}" - echo -e "''${BLUE}Available devices:''${NC}" - lsblk -d -o NAME,SIZE,TYPE,MODEL,MOUNTPOINT - exit 1 - fi - - # Check if device is mounted - if grep -q "$DEVICE" /proc/mounts; then - echo -e "''${RED}Warning: Device '$DEVICE' is currently mounted''${NC}" - echo "Mounted partitions:" - grep "$DEVICE" /proc/mounts - echo -e "''${BLUE}Please unmount all partitions before continuing''${NC}" - read -p "Attempt to unmount all partitions? (y/N) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - for mount in $(grep "$DEVICE" /proc/mounts | awk '{print $2}'); do - echo "Unmounting $mount..." - sudo umount "$mount" - done - else - exit 1 - fi - fi - - echo -e "''${RED}WARNING: This will ERASE ALL DATA on $DEVICE''${NC}" - echo -e "''${BLUE}Device details:''${NC}" - lsblk "$DEVICE" -o NAME,SIZE,TYPE,MODEL,MOUNTPOINT - echo - echo -e "''${RED}Double-check that this is the correct device!''${NC}" - read -p "Are you absolutely sure you want to continue? (y/N) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - echo -e "''${BLUE}Formatting device...''${NC}" - sudo wipefs -a "$DEVICE" - - echo -e "''${BLUE}Writing ISO to device...''${NC}" - # Calculate ISO size for progress reporting - ISO_SIZE=$(stat -c %s "$ISO_FILE") - sudo dd bs=4M if="$ISO_FILE" of="$DEVICE" conv=fsync status=progress - - echo -e "''${BLUE}Syncing...''${NC}" - sync - - echo -e "''${GREEN}Done! You can now safely remove the device.''${NC}" - echo -e "''${BLUE}To boot from this device:''${NC}" - echo "1. Restart your computer" - echo "2. Enter your BIOS/UEFI settings (usually by pressing F2, F12, DEL, or ESC during startup)" - echo "3. Select this device as the boot device" - echo "4. Save and exit" - fi - ''; - isoSystem = isoSystem; -} diff --git a/lib/iso/nixos-install.sh b/lib/iso/nixos-install.sh deleted file mode 100644 index e53e9d4b..00000000 --- a/lib/iso/nixos-install.sh +++ /dev/null @@ -1,332 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -cat <<"EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Check if running as root -if [ "$EUID" -ne 0 ]; then - echo -e "${RED}Please run as root${NC}" - exit 1 -fi - -# Check for required commands -check_requirements() { - local required_commands=("wipefs" "parted" "mkfs.fat" "mkfs.ext4" "lsblk" "fzf") - local missing_commands=() - - for cmd in "${required_commands[@]}"; do - if ! command -v "$cmd" >/dev/null 2>&1; then - missing_commands+=("$cmd") - fi - done - - if [ ${#missing_commands[@]} -ne 0 ]; then - echo -e "${RED}Error: Required commands not found: ${missing_commands[*]}${NC}" - exit 1 - fi -} - -# Calculate swap size based on RAM -get_swap_size() { - local mem_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}') - local mem_gb=$((mem_kb / 1024 / 1024)) - - if [ $mem_gb -le 2 ]; then - echo $((mem_gb * 2)) - elif [ $mem_gb -le 8 ]; then - echo $mem_gb - else - echo 8 - fi -} - -# Select installation drive -select_drive() { - # Check if any block devices exist - if ! lsblk -d -p -n -l -o NAME,SIZE,MODEL > /dev/null 2>&1; then - echo -e "${RED}Error: Unable to list block devices. Are you running in a virtual environment?${NC}" - echo -e "${RED}Debug info:${NC}" - ls -l /dev/sd* /dev/nvme* /dev/vd* 2>&1 || true - echo - exit 1 - fi - - local drives=$(lsblk -d -p -n -l -o NAME,SIZE,MODEL | grep -v "loop") - if [ -z "$drives" ]; then - echo -e "${RED}Error: No valid drives found${NC}" - exit 1 - fi - - # Quote the selection to handle whitespace properly - local selection - selection=$(echo "$drives" | fzf --header "Select installation drive" --height=10) - if [ -z "$selection" ]; then - echo -e "${RED}No drive selected${NC}" - exit 1 - fi - # Extract just the device path and ensure it's trimmed - echo "$selection" | awk '{print $1}' | tr -d '[:space:]' -} - -# Detect boot mode -detect_boot_mode() { - if [ -d "/sys/firmware/efi" ]; then - echo "uefi" - else - echo -e "${RED}Warning: UEFI boot mode not detected. NixOS strongly recommends UEFI boot.${NC}" - read -p "Continue with legacy BIOS boot anyway? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi - echo "bios" - fi -} - -# Main installation function -main() { - # Check requirements first - check_requirements - - echo -e "${RED}╔════════════════════════════════════════════════════════════════╗${NC}" - echo -e "${RED}║ STOP! READ CAREFULLY OR YOU MAY PERMANENTLY LOSE DATA! ║${NC}" - echo -e "${RED}╚════════════════════════════════════════════════════════════════╝${NC}" - echo - - # Explain partitioning scheme and give option to exit - echo -e "${BLUE}This script will perform a simple automated NixOS installation with:${NC}" - echo " • A two-partition layout (boot + root)" - echo " • No separate partitions for /home, /var, etc." - echo " • A swap file instead of a swap partition" - echo - echo -e "For UEFI systems (recommended):" - echo " • GPT partition table" - echo " • 512MiB EFI System Partition (ESP) formatted as FAT32" - echo " • Remaining space as ext4 root partition" - echo - echo -e "For Legacy BIOS systems (fallback):" - echo " • MBR partition table" - echo " • 512MiB boot partition" - echo " • Remaining space as ext4 root partition" - echo - - # Calculate and show swap size - local swap_size - swap_size=$(get_swap_size) - echo -e "${BLUE}Based on your system memory:${NC}" - echo " • Swap file size: ${swap_size}GB" - echo - - echo -e "${RED}WARNING: THIS WILL COMPLETELY ERASE THE SELECTED DRIVE!${NC}" - echo -e "${BLUE}If you need a custom partition layout (separate /home, encryption, etc.),${NC}" - echo -e "${BLUE}please exit and follow the manual partitioning instructions at:${NC}" - echo -e "${GREEN}https://nixos.org/manual/nixos/stable/#ch-installation${NC}" - echo - - # SECTION 1: PARTITIONING - echo -e "${BLUE}=== SECTION 1: DRIVE SELECTION AND PARTITIONING ===${NC}" - read -p "Continue with drive selection and partitioning? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo -e "${GREEN}Exiting installation. No changes were made.${NC}" - exit 0 - fi - - # Select drive - local selected_drive - selected_drive="$(select_drive)" - if [ ! -b "$selected_drive" ]; then - echo -e "${RED}Error: Invalid drive selected: $selected_drive${NC}" - exit 1 - fi - echo -e "${GREEN}Selected drive: $selected_drive${NC}" - - # Confirm selection - read -p "This will ERASE ALL DATA on $selected_drive. Continue? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo -e "${GREEN}Exiting installation. No changes were made.${NC}" - exit 1 - fi - - # Detect boot mode - local boot_mode - boot_mode=$(detect_boot_mode) - echo -e "${BLUE}Detected boot mode: $boot_mode${NC}" - - # Calculate sizes - local swap_size - swap_size=$(get_swap_size) - echo -e "${BLUE}Calculated swap size: ${swap_size}GB${NC}" - - # Wipe existing signatures - wipefs -a "$selected_drive" - - # Partition drive - if [ "$boot_mode" = "uefi" ]; then - # GPT/UEFI partitioning (preferred) - parted "$selected_drive" -- mklabel gpt - parted "$selected_drive" -- mkpart ESP fat32 1MiB 512MiB - parted "$selected_drive" -- set 1 esp on - parted "$selected_drive" -- mkpart primary 512MiB 100% - else - # MBR/BIOS partitioning (fallback) - echo -e "${RED}Warning: Using legacy BIOS boot mode. Some NixOS features may not work correctly.${NC}" - parted "$selected_drive" -- mklabel msdos - parted "$selected_drive" -- mkpart primary 1MiB 512MiB - parted "$selected_drive" -- set 1 boot on - parted "$selected_drive" -- mkpart primary 512MiB 100% - fi - - # Format partitions - local boot_partition - local root_partition - - # Handle different drive naming schemes (NVME vs SATA/IDE) - if [[ "$selected_drive" == *"nvme"* ]]; then - boot_partition="${selected_drive}p1" - root_partition="${selected_drive}p2" - else - boot_partition="${selected_drive}1" - root_partition="${selected_drive}2" - fi - - mkfs.fat -F 32 -n NIXBOOT "$boot_partition" - mkfs.ext4 -L NIXROOT "$root_partition" - - echo -e "${GREEN}Partitioning and formatting complete!${NC}" - - # SECTION 2: MOUNTING AND SWAP - echo -e "${BLUE}=== SECTION 2: MOUNTING PARTITIONS AND CREATING SWAP ===${NC}" - read -p "Continue with mounting partitions and creating swap? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo -e "${GREEN}Partitioning completed but installation aborted. Your drive has been partitioned but no files were copied.${NC}" - exit 0 - fi - - # Mount partitions - if [ -e "/dev/disk/by-label/NIXROOT" ] && [ -e "/dev/disk/by-label/NIXBOOT" ]; then - # Try mounting by labels first - mount /dev/disk/by-label/NIXROOT /mnt - mkdir -p /mnt/boot - mount /dev/disk/by-label/NIXBOOT /mnt/boot - else - # Fall back to direct device mounting - echo -e "${BLUE}Waiting for partition labels to be available...${NC}" - sleep 2 # Give udev a moment to create the labels - - # Try one more time with labels - if [ -e "/dev/disk/by-label/NIXROOT" ] && [ -e "/dev/disk/by-label/NIXBOOT" ]; then - mount /dev/disk/by-label/NIXROOT /mnt - mkdir -p /mnt/boot - mount /dev/disk/by-label/NIXBOOT /mnt/boot - else - # Fall back to direct device mounting - echo -e "${BLUE}Mounting partitions directly by device...${NC}" - mount "$root_partition" /mnt - mkdir -p /mnt/boot - mount "$boot_partition" /mnt/boot - fi - fi - - # Create and enable swap file - dd if=/dev/zero of=/mnt/.swapfile bs=1G count=$swap_size status=progress - chmod 600 /mnt/.swapfile - mkswap /mnt/.swapfile - swapon /mnt/.swapfile - - # Generate NixOS config - nixos-generate-config --root /mnt - - echo -e "${GREEN}Partitions mounted and swap file created!${NC}" - - # SECTION 3: HYDENIX TEMPLATING AND INSTALLATION - echo -e "${BLUE}=== SECTION 3: CONFIGURATION AND INSTALLATION ===${NC}" - read -p "Continue with configuration and installation? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo -e "${GREEN}Partitioning and mounting completed but installation aborted.${NC}" - echo -e "${BLUE}Your drive has been partitioned and mounted at /mnt.${NC}" - echo -e "${BLUE}You can continue with manual installation if desired.${NC}" - exit 0 - fi - - # Copy template to installation target - if [ -d "/home/nixos/hydenix" ]; then - echo -e "${GREEN}Hydenix configuration template found!${NC}" - echo -e "${BLUE}Copying Hydenix template to installation target...${NC}" - cp -r /home/nixos/hydenix /mnt/etc/ - chmod -R u+w /mnt/etc/hydenix - - # Generate hardware configuration - echo -e "${BLUE}Generating hardware configuration...${NC}" - nixos-generate-config --root /mnt --show-hardware-config > /mnt/etc/hydenix/hardware-configuration.nix - - echo -e "${GREEN}Basic system configuration complete!${NC}" - - # Ask if user wants to edit configuration before installing - echo -e "${BLUE}Would you like to edit configuration.nix before installing? (y/N)${NC}" - read -r edit_config - - if [[ $edit_config =~ ^[Yy]$ ]]; then - # Determine which editor to use - if command -v nano >/dev/null 2>&1; then - EDITOR="nano" - else - EDITOR="vim" - fi - - echo -e "${BLUE}Opening configuration.nix with $EDITOR...${NC}" - $EDITOR /mnt/etc/hydenix/configuration.nix - - echo -e "${GREEN}Configuration saved!${NC}" - fi - - # Final confirmation before installation - echo -e "${BLUE}Ready to install NixOS. This is the final step.${NC}" - read -p "Proceed with installation? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo -e "${GREEN}Configuration completed but installation aborted.${NC}" - echo -e "${BLUE}Your drive has been partitioned, mounted, and configured at /mnt.${NC}" - echo -e "${BLUE}You can continue with manual installation by running: nixos-install --root /mnt --flake \"/mnt/etc/hydenix#nixos\"${NC}" - exit 0 - fi - - # Install with default hostname and prompt for root password - echo -e "${BLUE}Installing Hydenix using flake...${NC}" - echo -e "${BLUE}You will be prompted to set the root password during installation.${NC}" - nixos-install --root /mnt --flake "/mnt/etc/hydenix#nixos" - - echo -e "${GREEN}Hydenix installation complete!${NC}" - echo -e "${BLUE}You can now reboot into your new system.${NC}" - echo "Run: reboot" - else - echo -e "${RED}Hydenix template not found. Falling back to manual configuration.${NC}" - echo -e "${GREEN}Basic system configuration complete!${NC}" - echo -e "${BLUE}Next steps:${NC}" - echo "1. Edit /mnt/etc/nixos/configuration.nix" - echo "2. Run nixos-install" - echo "3. Set root password" - echo "4. Reboot" - fi -} - -main "$@" \ No newline at end of file diff --git a/lib/vms/hydevm/README.md b/lib/vms/hydevm/README.md deleted file mode 100644 index 0150e76b..00000000 --- a/lib/vms/hydevm/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# HydeVM - Simplified VM Tool for HyDE Contributors - -HydeVM is a streamlined development tool that automatically sets up HyDE desktop environment in a virtual machine for testing different branches and commits. - -## Why? - -- **Zero Configuration**: Automatically downloads Arch Linux base image and sets up HyDE -- **Branch Testing**: Easily test any HyDE branch or commit hash -- **Smart Caching**: Creates cached snapshots for faster subsequent runs -- **Optional Persistence**: Choose whether changes should be saved or discarded -- **Contributor Focused**: Designed specifically for HyDE development workflow - -## Quick Start - -```bash -# Test master branch (non-persistent) -hydevm - -# Test a specific branch -hydevm feature-branch - -# Test with persistence (changes saved) -hydevm --persist dev-branch - -# Test specific commit -hydevm abc123def -``` - -## Usage - -### Basic Commands - -```bash -# Run master branch (default, non-persistent) -hydevm - -# Run specific branch or commit -hydevm [branch-name|commit-hash] - -# Run with persistence (changes will be saved) -hydevm --persist [branch-name|commit-hash] - -# List cached snapshots -hydevm --list - -# Clean all cached data -hydevm --clean - -# Show help -hydevm --help -``` - -### Examples - -```bash -# Test master branch, changes discarded on exit -hydevm - -# Test development branch with persistence -hydevm --persist dev - -# Test specific commit hash -hydevm a1b2c3d4 - -# Test feature branch, changes discarded -hydevm new-feature - -# List all cached snapshots -hydevm --list - -# Clean cache to start fresh -hydevm --clean -``` - -### Configuration - -Set these environment variables to customize VM resources: - -```bash -# Set VM memory (default: 4G) -VM_MEMORY=8G hydevm - -# Set VM CPU count (default: 2) -VM_CPUS=4 hydevm - -# Both together -VM_MEMORY=8G VM_CPUS=4 hydevm --persist dev -``` - -## First-Time Setup - -When you run a new branch/commit for the first time, hydevm will: - -1. Show a VM window with setup instructions -2. You'll need to: - - Login as `arch` / `arch` - - Run the provided curl command to download and execute the setup script - - Wait for HyDE installation to complete - - Run `sudo poweroff` to shutdown and create the snapshot - -**Example first run:** - -```bash -hydevm my-feature-branch -# VM opens with instructions -# Login as arch/arch, run the curl command shown -# Wait for installation, then sudo poweroff -# Snapshot is created automatically -``` - -**Subsequent runs are instant:** - -```bash -hydevm my-feature-branch # Uses cached snapshot - starts immediately! -``` - -## VM Details - -- **Login**: `arch` / `arch` -- **SSH Access**: `ssh arch@localhost -p 2222` -- **Persistence**: Optional flag determines if changes are saved -- **Snapshots**: Stored in `./.hyde-cache/hydevm/snapshots/` -- **Base Image**: Cached in `./.hyde-cache/hydevm/archbase.qcow2` - -## Development Workflow - -```bash -# Test your feature branch -hydevm my-feature - -# Make changes and test with persistence -hydevm --persist my-feature - -# Test different commits -hydevm abc123 # older commit -hydevm def456 # newer commit - -# Clean up when done -hydevm --clean -``` - -## Technical Notes - -- Uses KVM acceleration when available -- Copy-on-write snapshots minimize disk usage -- Automatic branch/commit detection and checkout -- SSH port forwarding for remote access -- Non-persistent mode uses temporary overlays diff --git a/lib/vms/hydevm/default.nix b/lib/vms/hydevm/default.nix deleted file mode 100644 index 56c56885..00000000 --- a/lib/vms/hydevm/default.nix +++ /dev/null @@ -1,291 +0,0 @@ -{ - pkgs ? import { }, - lib ? pkgs.lib, -}: - -let - archImageUrl = "https://geo.mirror.pkgbuild.com/images/v20250415.336224/Arch-Linux-x86_64-basic-20250415.336224.qcow2"; - - hydevmScript = pkgs.writeShellScriptBin "hydevm" '' - set -e - - # Configuration - CACHE_DIR="$(pwd)/.hyde-cache/hydevm" - BASE_IMAGE="$CACHE_DIR/archbase.qcow2" - SNAPSHOTS_DIR="$CACHE_DIR/snapshots" - HYDE_REPO="https://github.com/HyDE-Project/HyDE.git" - - # Create cache directories - mkdir -p "$CACHE_DIR" "$SNAPSHOTS_DIR" - - function print_usage() { - echo "HydeVM - Simplified VM tool for HyDE contributors" - echo "" - echo "Usage: hydevm [OPTIONS] [BRANCH/COMMIT]" - echo "" - echo "Arguments:" - echo " BRANCH/COMMIT Git branch or commit hash (default: master)" - echo "" - echo "Options:" - echo " --persist Make VM changes persistent" - echo " --list List available snapshots" - echo " --clean Clean all cached data" - echo " --help Show this help" - echo "" - echo "Environment Variables:" - echo " VM_MEMORY=8G Set VM memory (default: 4G)" - echo " VM_CPUS=4 Set VM CPU count (default: 2)" - echo "" - echo "Examples:" - echo " hydevm # Run master branch (non-persistent)" - echo " hydevm --persist # Run master branch (persistent)" - echo " hydevm feature-branch # Run specific branch" - echo " hydevm abc123 # Run specific commit" - echo " hydevm --persist dev # Run dev branch with persistence" - } - - function download_archbox() { - if [ ! -f "$BASE_IMAGE" ]; then - echo "📦 Downloading Arch Linux base image..." - ${pkgs.curl}/bin/curl -L "${archImageUrl}" -o "$BASE_IMAGE" - echo "✅ Base image downloaded successfully" - fi - } - - function get_snapshot_name() { - local ref="$1" - if [ -z "$ref" ]; then - echo "master" - else - # Sanitize branch/commit name for filename - echo "$ref" | sed 's/[^a-zA-Z0-9._-]/_/g' - fi - } - - function create_hyde_snapshot() { - local ref="''${1:-master}" - local snapshot_name=$(get_snapshot_name "$ref") - local snapshot_path="$SNAPSHOTS_DIR/hyde-$snapshot_name.qcow2" - - # Check if snapshot already exists - if [ -f "$snapshot_path" ]; then - echo "📸 Snapshot for '$ref' already exists" - return 0 - fi - - echo "🔨 Creating HyDE snapshot for '$ref'..." - - # Create temporary VM image for setup - local temp_image="$CACHE_DIR/temp-setup.qcow2" - ${pkgs.qemu}/bin/qemu-img create -f qcow2 -F qcow2 -b "$BASE_IMAGE" "$temp_image" - - # Create setup script that will be available in the VM - local setup_script="$CACHE_DIR/setup.sh" - cat > "$setup_script" </dev/null; then - echo "Checking out branch: $ref" - git checkout -b "$ref" "origin/$ref" - else - echo "Checking out commit: $ref" - git checkout "$ref" - fi - fi - - echo "" - echo "🎨 HyDE repository cloned and ready!" - echo "🚀 Starting HyDE installation..." - cd /home/arch/HyDE/Scripts - ./install.sh - - echo "" - echo "✅ HyDE installation complete!" - echo "💾 Please shutdown the VM now by running: sudo poweroff" - echo " This will create the snapshot for future use." - SETUP_EOF - - chmod +x "$setup_script" - - echo "" - echo "🖥️ Starting VM for HyDE installation..." - echo "📋 SETUP INSTRUCTIONS:" - echo " 1. Wait for the VM to boot to login prompt" - echo " 2. Login as: arch / arch" - echo " 3. Run: curl -s http://10.0.2.2:8000/setup.sh -o ./setup.sh" - echo " 4. Run: chmod +x ./setup.sh" - echo " 5. Run: ./setup.sh" - echo " 6. Wait for installation to complete" - echo " 7. Run: sudo poweroff" - echo "" - echo "Starting simple HTTP server for script delivery..." - - # Start simple HTTP server in background to serve the setup script - cd "$CACHE_DIR" - ${pkgs.python3}/bin/python3 -m http.server 8000 & - local server_pid=$! - - # Start VM for setup - ${pkgs.qemu}/bin/qemu-system-x86_64 \ - -m "''${VM_MEMORY:-8G}" \ - -smp "''${VM_CPUS:-4}" \ - -enable-kvm \ - -cpu host \ - -drive file="$temp_image",format=qcow2,if=virtio \ - -device virtio-vga-gl \ - -display gtk,gl=on,grab-on-hover=on \ - -device virtio-net,netdev=net0 \ - -netdev user,id=net0 \ - -boot menu=on - - # Kill the HTTP server - kill $server_pid 2>/dev/null || true - - echo "" - echo "💾 Converting VM to snapshot..." - - # Convert temporary image to final snapshot - ${pkgs.qemu}/bin/qemu-img convert -O qcow2 "$temp_image" "$snapshot_path" - - # Cleanup - rm -f "$temp_image" "$setup_script" - - echo "✅ Snapshot created: hyde-$snapshot_name" - echo "🚀 You can now run: hydevm $ref" - } - - function run_vm() { - local ref="''${1:-master}" - local persistent="''${2:-false}" - local snapshot_name=$(get_snapshot_name "$ref") - local snapshot_path="$SNAPSHOTS_DIR/hyde-$snapshot_name.qcow2" - - # Ensure snapshot exists - if [ ! -f "$snapshot_path" ]; then - echo "📸 Snapshot for '$ref' not found, creating it..." - create_hyde_snapshot "$ref" - fi - - local vm_disk - if [ "$persistent" = "true" ]; then - echo "🔒 Running in persistent mode - changes will be saved" - vm_disk="$snapshot_path" - else - echo "🔄 Running in non-persistent mode - changes will be discarded" - vm_disk="$(mktemp -p "$CACHE_DIR" overlay.XXXXXX.qcow2)" - ${pkgs.qemu}/bin/qemu-img create -f qcow2 -F qcow2 -b "$snapshot_path" "$vm_disk" - trap "rm -f '$vm_disk'" EXIT - fi - - echo "🚀 Starting HyDE VM (branch/commit: $ref)..." - echo " Login: arch / arch" - echo " SSH: ssh arch@localhost -p 2222" - - ${pkgs.qemu}/bin/qemu-system-x86_64 \ - -m "''${VM_MEMORY:-4G}" \ - -smp "''${VM_CPUS:-2}" \ - -enable-kvm \ - -cpu host \ - -drive file="$vm_disk",format=qcow2,if=virtio \ - -device virtio-vga-gl \ - -display gtk,gl=on,grab-on-hover=on \ - -device virtio-net,netdev=net0 \ - -netdev user,id=net0,hostfwd=tcp::2222-:22 \ - -boot menu=on \ - ''${VM_EXTRA_ARGS:-} - } - - function list_snapshots() { - echo "📸 Available HyDE snapshots:" - if [ -d "$SNAPSHOTS_DIR" ]; then - find "$SNAPSHOTS_DIR" -name "hyde-*.qcow2" -exec basename {} \; | \ - sed 's/^hyde-//' | sed 's/\.qcow2$//' | sort - else - echo "No snapshots found" - fi - } - - function clean_cache() { - echo "🧹 Cleaning HydeVM cache..." - rm -rf "$CACHE_DIR" - echo "✅ Cache cleaned" - } - - # Main logic - persistent="false" - ref="master" - - # Parse arguments - while [ $# -gt 0 ]; do - case "$1" in - --persist) - persistent="true" - shift - ;; - --list) - list_snapshots - exit 0 - ;; - --clean) - clean_cache - exit 0 - ;; - --help|-h) - print_usage - exit 0 - ;; - -*) - echo "❌ Unknown option: $1" - print_usage - exit 1 - ;; - *) - ref="$1" - shift - ;; - esac - done - - # Ensure archbox is available - download_archbox - - # Run VM - run_vm "$ref" "$persistent" - ''; -in -{ - defaultPackage = hydevmScript; - - mkHydeVM = - { - memory ? "4G", - cpus ? 2, - extraArgs ? "", - }: - pkgs.writeShellScriptBin "run-hydevm" '' - VM_MEMORY="${memory}" VM_CPUS="${toString cpus}" VM_EXTRA_ARGS="${extraArgs}" ${hydevmScript}/bin/hydevm "$@" - ''; -} diff --git a/lib/vms/iso-vm.nix b/lib/vms/iso-vm.nix deleted file mode 100644 index a5fae2d0..00000000 --- a/lib/vms/iso-vm.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ hydenix-inputs, ... }: -let - # Define pkgs for easier access - pkgs = import hydenix-inputs.hydenix-nixpkgs { - inherit (hydenix-inputs.lib) system; - config.allowUnfree = true; - }; - - # Import the ISO configuration - isoConfig = ( - import ../iso/default.nix { - inherit hydenix-inputs; - } - ); - - # Get the actual path to the ISO image file - isoPath = "${isoConfig.isoSystem.config.system.build.isoImage}/iso/hydenix.iso"; - - # TODO: needs uefi bootloader - # TODO: fix resolution/display -in -# Instead of a NixOS system, create a direct VM script -pkgs.writeShellScriptBin "run-demo-vm" '' - QEMU=${pkgs.qemu}/bin/qemu-system-x86_64 - - # Create a virtual disk if it doesn't exist yet - if [ ! -f ./nixos-disk.qcow2 ]; then - ${pkgs.qemu}/bin/qemu-img create -f qcow2 ./nixos-disk.qcow2 30G - fi - - # Run QEMU with the ISO as boot device - $QEMU \ - -enable-kvm \ - -m 8192 \ - -smp 6 \ - -cpu host \ - -machine q35,accel=kvm \ - -drive file=./nixos-disk.qcow2,if=virtio,cache=writeback \ - -drive media=cdrom,file=${isoPath},readonly=on \ - -boot d \ - -device virtio-vga-gl \ - -display gtk,gl=on,grab-on-hover=on \ - -usb -device usb-tablet \ - -device intel-iommu \ - -device ich9-intel-hda \ - -device hda-output \ -'' diff --git a/template/README.md b/template/README.md index 18292187..b8df57e6 100644 --- a/template/README.md +++ b/template/README.md @@ -1,79 +1,68 @@ -# Hydenix Template +NixOS -Welcome to the Hydenix template! +# hydenix template flake -This template is designed to help you get started with Hydenix. It includes a basic configuration for Hydenix and some common modules. +This is now your personal NixOS configuration.\ +Add packages, customize themes, or even disable hydenix and setup your own wm/de.\ +Enjoy the full power of Nix! -If you just templated this flake, you can follow these steps to get started: +visit the [docs/installation.md](./docs/installation.md) to get started. -1. edit `configuration.nix` with your preferences for hydenix - - options needing to be changed are marked with `! EDIT` - - (optional) in your template flake folder, review both `./configuration.nix` and `./modules/hm/default.nix` for more options -2. run `sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix` -3. `git init && git add .` (flakes have to be managed via git) -4. run any of the packages in your new `flake.nix` - - for rebuild, use `sudo nixos-rebuild switch --flake .` -5. DON'T FORGET: change your password for all users with `passwd` from initialPassword set in `configuration.nix` +## file structure -NOTE: After launching hydenix, you can run `hyde-shell reload` to generate cache for remaining themes if you want. +### core configuration files -All module options are documented [here](https://github.com/richen604/hydenix/blob/main/docs/faq.md#What-are-the-module-options). +| file | description | +|------|-------------| +| `flake.nix` | main flake configuration and entry point | +| `configuration.nix` | nixos system configuration | +| `hardware-configuration.nix` | hardware-specific settings (auto-generated) | -Other than that, this is your own nixos configuration. You can do whatever you want with it. -Add modules, change packages, add flakes, even disable hydenix and try something else! +### documentation -If you have any questions, please refer to the [FAQ](https://github.com/richen604/hydenix/blob/main/docs/faq.md) or [Hydenix README](https://github.com/richen604/hydenix/blob/main/README.md). +| file | purpose | +|------|---------| +| [`docs/installation.md`](./docs/installation.md) | installation guide and setup instructions | +| [`docs/options.md`](./docs/options.md) | available module configuration options | +| [`docs/faq.md`](./docs/faq.md) | frequently asked questions and solutions | +| [`docs/troubleshooting.md`](./docs/troubleshooting.md) | common issues and fixes | +| [`docs/upgrading.md`](./docs/upgrading.md) | how to upgrade your configuration | +| [`docs/contributing.md`](./docs/contributing.md) | guidelines for contributing | +| [`docs/community.md`](./docs/community.md) | community configurations and examples | -You can also reach out to me on the [Hyde Discord](https://discord.gg/AYbJ9MJez7) or [Hydenix GitHub Discussions](https://github.com/richen604/hydenix/discussions). +### write your own modules -## Upgrading +> **note:** Use these directories to override or extend hydenix modules with your custom configurations. -Hydenix can be upgraded, downgraded, or version locked easy. -in your template flake folder, update hydenix to main using +| directory | type | purpose | +|-----------|------|---------| +| `modules/hm/` | home manager | custom home-manager module definitions (and for `hydenix.hm` options) | +| `modules/system/` | nixos system | custom system-level module definitions (and for `hydenix` options) | + +### directory tree ```bash -nix flake update hydenix +hydenix/ +├── README.md +├── flake.nix +├── configuration.nix +├── hardware-configuration.nix +├── docs/ +│ ├── *.md files +│ └── assets/ +└── modules/ + ├── hm/default.nix + └── system/default.nix ``` -or define a specific version in your `flake.nix` template - -```nix -inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - hydenix = { - # Available inputs: - # Main: github:richen604/hydenix - # Dev: github:richen604/hydenix/dev - # Commit: github:richen604/hydenix/ - # Version: github:richen604/hydenix/v1.0.0 - url = "github:richen604/hydenix"; - }; - }; -``` +## next steps -run `nix flake update hydenix` again to load the update, then rebuild your system to apply the changes - -## When to Upgrade - -```mermaid -graph TD - A[v2.3.1] --> B[MAJOR] - A --> C[MINOR] - A --> D[PATCH] - B --> E[Breaking Changes
Review Release Notes for API Changes] - C --> F[New Features
Safe to Update] - D --> G[Bug Fixes
Safe to Update] - - style A fill:#c79bf0,stroke:#ebbcba,stroke-width:2px,color:#000 - style B fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style C fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style D fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 - style E fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style F fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 - style G fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 -``` +- to learn more about nix, see [nix resources](./docs/faq.md#how-do-i-learn-more-about-nix) +- see [module options](./docs/options.md) for configuration +- check the [faq](./docs/faq.md) and [troubleshooting](./docs/troubleshooting.md) guides + +## getting help -- **Always review [release notes](https://github.com/richen604/hydenix/releases) for major updates (API changes)** -- Keep up with patches for stability -- Update to minor versions for new features - \ No newline at end of file +- [hydenix issues](https://github.com/richen604/hydenix/issues) +- [hydenix discussions](https://github.com/richen604/hydenix/discussions) +- [hyde discord](https://discord.gg/AYbJ9MJez7) diff --git a/template/configuration.nix b/template/configuration.nix index 6881c9ee..7ab3380c 100644 --- a/template/configuration.nix +++ b/template/configuration.nix @@ -3,8 +3,11 @@ ... }: let - # Package declaration - # --------------------- + # ======================================== + # PACKAGE CONFIGURATION + # ======================================== + # This sets up the package system with proper overlays + # Most users won't need to modify this section pkgs = import inputs.hydenix.inputs.hydenix-nixpkgs { inherit (inputs.hydenix.lib) system; @@ -20,42 +23,75 @@ let }; in { - - # Set pkgs for hydenix globally, any file that imports pkgs will use this + # Set pkgs for hydenix globally nixpkgs.pkgs = pkgs; + # ======================================== + # MODULE IMPORTS + # ======================================== imports = [ + # Required modules - don't modify unless you know what you're doing inputs.hydenix.inputs.home-manager.nixosModules.home-manager - ./hardware-configuration.nix inputs.hydenix.lib.nixOsModules - ./modules/system + ./modules/system # Your custom system modules + ./hardware-configuration.nix # Auto-generated hardware config - # === GPU-specific configurations === + # ======================================== + # HARDWARE CONFIGURATION + # ======================================== + # Uncomment the lines that match your hardware + # Run `lshw -short` or `lspci` to identify your hardware - /* - For drivers, we are leveraging nixos-hardware - Most common drivers are below, but you can see more options here: https://github.com/NixOS/nixos-hardware - */ + # ---------------------------------------- + # GPU Configuration (choose one) + # ---------------------------------------- - #! EDIT THIS SECTION - # For NVIDIA setups + # NVIDIA GPUs: + # 1. Uncomment the line below: # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-gpu-nvidia - - # For AMD setups + # + # 2. If you have hybrid graphics (laptop), also set these: + # hardware.nvidia.prime.intelBusId = "PCI:0:2:0"; # Run: lspci | grep VGA + # hardware.nvidia.prime.nvidiaBusId = "PCI:1:0:0"; # to get correct IDs + # + # 3. For newer cards, you might want open drivers: + # hardware.nvidia.open = true; + + # AMD GPUs: # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-gpu-amd - # === CPU-specific configurations === - # For AMD CPUs + # ---------------------------------------- + # CPU Configuration (choose one) + # ---------------------------------------- + + # AMD CPUs: # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-cpu-amd - # For Intel CPUs - inputs.hydenix.inputs.nixos-hardware.nixosModules.common-cpu-intel + # Intel CPUs (also enables Intel graphics): + # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-cpu-intel + + # ---------------------------------------- + # Additional Hardware Modules + # ---------------------------------------- + # Uncomment based on your system type: + + # For high-DPI displays (4K, etc.): + # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-hidpi - # === Other common modules === - inputs.hydenix.inputs.nixos-hardware.nixosModules.common-pc - inputs.hydenix.inputs.nixos-hardware.nixosModules.common-pc-ssd + # For laptops: + # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-pc-laptop + + # For SSD storage: + # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-pc-ssd + + # For HDD storage: + # inputs.hydenix.inputs.nixos-hardware.nixosModules.common-pc-hdd ]; + # ======================================== + # HOME MANAGER CONFIGURATION + # ======================================== + # This manages user-specific configurations (dotfiles, themes, etc.) home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -63,64 +99,77 @@ in inherit inputs; }; - #! EDIT THIS USER (must match users defined below) + # ---------------------------------------- + # User Configuration + # ---------------------------------------- + # REQUIRED: Change "hydenix" to your actual username + # This must match the username you define in users.users below users."hydenix" = { ... }: { imports = [ inputs.hydenix.lib.homeModules - # Nix-index-database - for comma and command-not-found + # Command-not-found and comma tool support inputs.nix-index-database.hmModules.nix-index - ./modules/hm + ./modules/hm # Your custom home-manager modules ]; }; }; - # IMPORTANT: Customize the following values to match your preferences - hydenix = { - enable = true; # Enable the Hydenix module - - #! EDIT THESE VALUES - hostname = "hydenix"; # Change to your preferred hostname - timezone = "America/Vancouver"; # Change to your timezone - locale = "en_CA.UTF-8"; # Change to your preferred locale - - /* - Optionally edit the below values, or leave to use hydenix defaults - visit ./modules/hm/default.nix for more options - - audio.enable = true; # enable audio module - boot = { - enable = true; # enable boot module - useSystemdBoot = true; # disable for GRUB - grubTheme = "Retroboot"; # or "Pochita" - grubExtraConfig = ""; # additional GRUB configuration - kernelPackages = pkgs.linuxPackages_zen; # default zen kernel - }; - gaming.enable = true; # enable gaming module - hardware.enable = true; # enable hardware module - network.enable = true; # enable network module - nix.enable = true; # enable nix module - sddm = { - enable = true; # enable sddm module - theme = "Candy"; # or "Corners" - }; - system.enable = true; # enable system module - */ - }; - - #! EDIT THESE VALUES (must match users defined above) + # ======================================== + # USER ACCOUNT SETUP + # ======================================== + # REQUIRED: This creates your user account + # Change "hydenix" to your desired username (must match above) users.users.hydenix = { - isNormalUser = true; # Regular user account - initialPassword = "hydenix"; # Default password (CHANGE THIS after first login with passwd) + isNormalUser = true; + # SECURITY: Change this password after first login with `passwd` + initialPassword = "hydenix"; + + # User groups (determines permissions): extraGroups = [ - "wheel" # For sudo access - "networkmanager" # For network management - "video" # For display/graphics access - # Add other groups as needed + "wheel" # Sudo access (admin privileges) + "networkmanager" # Network configuration + "video" # Graphics/display access ]; - shell = pkgs.zsh; # Change if you prefer a different shell + + # Default shell (options: pkgs.bash, pkgs.zsh, pkgs.fish) + shell = pkgs.zsh; + }; + + # ======================================== + # HYDENIX CONFIGURATION + # ======================================== + # Main configuration for the Hydenix desktop environment + hydenix = { + enable = true; # Enable Hydenix modules + + # ---------------------------------------- + # Basic System Settings (REQUIRED) + # ---------------------------------------- + # REQUIRED: Set your computer's network name + hostname = "hydenix"; # Change to something unique + + # REQUIRED: Set your timezone + # Examples: "America/New_York", "Europe/London", "Asia/Tokyo" + # Full list: `timedatectl list-timezones` + timezone = "America/Vancouver"; + + # REQUIRED: Set your locale/language + # Examples: "en_US.UTF-8", "en_GB.UTF-8", "de_DE.UTF-8" + locale = "en_CA.UTF-8"; + + # ---------------------------------------- + # Optional Settings + # ---------------------------------------- + # For more configuration options, see: + # https://github.com/richen604/hydenix/blob/main/docs/options.md }; + # ---------------------------------------- + # System Version + # ---------------------------------------- + # Don't change this unless you know what you're doing + # This helps with system upgrades and compatibility system.stateVersion = "25.05"; } diff --git a/template/docs/assets/option-search.png b/template/docs/assets/option-search.png new file mode 100644 index 00000000..6ca05df7 Binary files /dev/null and b/template/docs/assets/option-search.png differ diff --git a/template/docs/community.md b/template/docs/community.md new file mode 100644 index 00000000..de3b2545 --- /dev/null +++ b/template/docs/community.md @@ -0,0 +1,10 @@ +NixOS + +# hydenix community + +here are a list of community configs using hydenix. + +- [richen604/richendots](https://github.com/richen604/richendots) +- [Razkaroth/solitude](https://github.com/Razkaroth/solitude) + +if you have a config you'd like to share, please open a PR to add it to the list. diff --git a/docs/contributing.md b/template/docs/contributing.md similarity index 50% rename from docs/contributing.md rename to template/docs/contributing.md index b0a15d99..b4ef459f 100644 --- a/docs/contributing.md +++ b/template/docs/contributing.md @@ -1,16 +1,18 @@ -# Contributing +NixOS -This project uses [direnv](https://direnv.net/) for pre-commit hooks. Please install it first: +# contributing -- **Nix**: `nix-env -iA nixpkgs.direnv` -- **MacOS**: `brew install direnv` -- **Ubuntu/Debian**: `apt-get install direnv` +this project uses [direnv](https://direnv.net/) for pre-commit hooks. please install it first: + +- **nix**: `nix-env -iA nixpkgs.direnv` +- **macos**: `brew install direnv` +- **ubuntu/debian**: `apt-get install direnv` then run `direnv allow` to enable the hooks -More documentation on the codebase can be found at [Template README](template/README.md) +more documentation on the codebase can be found at [template README](template/README.md) -This project enforces [Conventional Commits](https://www.conventionalcommits.org/) format for all commit messages. Each commit message must follow this structure: +this project enforces [conventional commits](https://www.conventionalcommits.org/) format for all commit messages. each commit message must follow this structure: ```bash type(optional-scope): subject @@ -20,7 +22,7 @@ type(optional-scope): subject [optional footer(s)] ``` -Where: +where: - **type** must be one of: - `feat`: A new feature @@ -38,27 +40,26 @@ Where: - examples: vm, themes, home, cli, docs, etc. - **subject** must: - - be lowercase - not end with a period - be descriptive -Examples: +examples: - `feat(vm): add support for fedora vm configuration` - `fix: correct wallpaper path in material theme` - `docs: update installation instructions` - `chore: update dependencies` -## Pull Requests +## pull requests -1. Fork the repository -2. Create your feature branch (`git checkout -b feature/amazing-feature`) -3. Commit your changes using conventional commits -4. Push to the branch (`git push origin feature/amazing-feature`) -5. Open a Pull Request +1. fork the repository +2. create your feature branch (`git checkout -b feature/amazing-feature`) +3. commit your changes using conventional commits +4. push to the branch (`git push origin feature/amazing-feature`) +5. open a pull request -## Changelog +## changelog -The changelog is automatically generated from commit messages. Clear, well-formatted commit messages ensure your changes are properly documented. +the changelog is automatically generated from commit messages. clear, well-formatted commit messages ensure your changes are properly documented. -For more details, see the [Conventional Commits specification](https://www.conventionalcommits.org/). \ No newline at end of file +for more details, see the [conventional commits specification](https://www.conventionalcommits.org/). diff --git a/template/docs/faq.md b/template/docs/faq.md new file mode 100644 index 00000000..606ecf06 --- /dev/null +++ b/template/docs/faq.md @@ -0,0 +1,468 @@ +NixOS + +# faq + +## general FAQ + +- [faq](#faq) + - [general FAQ](#general-faq) + - [why should I use nixos?](#why-should-i-use-nixos) + - [how do I learn more about nix?](#how-do-i-learn-more-about-nix) + - [hydenix FAQ](#hydenix-faq) + - [how do I upgrade hydenix?](#how-do-i-upgrade-hydenix) + - [when should I upgrade?](#when-should-i-upgrade) + - [how do I fix (nix error / system error / bug / etc)?](#how-do-i-fix-nix-error--system-error--bug--etc) + - [common errors](#common-errors) + - [`error: hash mismatch in fixed-output derivation`](#error-hash-mismatch-in-fixed-output-derivation) + - [`Existing file '...' is in the way of '...'`](#existing-file--is-in-the-way-of-) + - [what are the module options?](#what-are-the-module-options) + - [what if I want to customize hydenix?](#what-if-i-want-to-customize-hydenix) + - [what are some example configurations?](#what-are-some-example-configurations) + - [how do I persist changes on reboot/rebuild/etc?](#how-do-i-persist-changes-on-rebootrebuildetc) + - [how do I add a new theme?](#how-do-i-add-a-new-theme) + - [what is mutable.nix?](#what-is-mutablenix) + - [why do themes still show after I remove them from `hydenix.hm.theme.themes`?](#why-do-themes-still-show-after-i-remove-them-from-hydenixhmthemethemes) + - [requesting features](#requesting-features) + - [other faq](#other-faq) + - [how do I run hyprland in a vm?](#how-do-i-run-hyprland-in-a-vm) + +### why should I use nixos? + +nixos offers several key advantages: + +1. **reproducible setups**: roll back to working states instantly if something breaks. +2. **configuration as code**: version control your entire OS setup. +3. **no dependency hell**: packages are isolated, allowing multiple versions side by side. +4. **declarative approach**: describe the desired end state rather than steps to achieve it. +5. **risk-free experimentation**: test configurations without permanent consequences. +6. **developer-friendly**: create isolated environments with precise dependencies. + +there's a learning curve, but the benefits are worth it. + + + +### how do I learn more about nix? + +> [!TIP] +> nix is a powerful package manager and configuration system that can be overwhelming at first. here are some resources to help you get started: + +general resources + +- [nix packages](https://search.nixos.org/packages) +- [nix options](https://search.nixos.org/options) +- [home manager options](https://home-manager-options.extranix.com/?query=&release=master) +- [nixos wiki](https://nixos.wiki) +- [nixpkgs discussions](https://discourse.nixos.org) +- [nixpkgs issues](https://github.com/NixOS/nixpkgs/issues) + + + +## hydenix FAQ + +### how do I upgrade hydenix? + +hydenix can be upgraded, downgraded, or version locked easy. +in your template flake folder, update hydenix to main using + +```bash +nix flake update hydenix +``` + +or define a specific version in your `flake.nix` template + +```nix +inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + hydenix = { + # Available inputs: + # Main: github:richen604/hydenix + # Dev: github:richen604/hydenix/dev + # Commit: github:richen604/hydenix/ + # Version: github:richen604/hydenix/v1.0.0 + url = "github:richen604/hydenix"; + }; + }; +``` + +run `nix flake update hydenix` again to load the update, then rebuild your system to apply the changes + +### when should I upgrade? + +```mermaid +graph TD + A[v2.3.1] --> B[major] + A --> C[minor] + A --> D[patch] + B --> E[breaking changes
review release notes for api changes] + C --> F[new features
safe to update] + D --> G[bug fixes
safe to update] + + style A fill:#c79bf0,stroke:#ebbcba,stroke-width:2px,color:#000 + style B fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style C fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style D fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style E fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 + style F fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 + style G fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 +``` + +- **always review [release notes](https://github.com/richen604/hydenix/releases) for major updates (api changes)** +- keep up with patches for stability +- update to minor versions for new features + +### how do I fix (nix error / system error / bug / etc)? + +please see the [troubleshooting](./troubleshooting.md) guide for more information on how to diagnose and fix issues. +or create an issue in the [hydenix GitHub repository](https://github.com/richen604/hydenix/issues). + +### common errors + +#### `error: hash mismatch in fixed-output derivation` + +this error occurs when nix expects a specific hash for a downloaded file, but the actual file has a different hash due to upstream changes. + +these usually happen with themes as they are updated frequently. + +Example: + +```bash +error: hash mismatch in fixed-output derivation '/nix/store/2s2n054di1wg8d3sw50wqhs10yg8svj0-Code-Garden.drv': + specified: sha256-ZAmxhz7MK24htAcPdnNMZF/K7Cw7vru80xZn+7yJgXQ= + got: sha256-HHC15pPHJ+ylQ56yYysEoKjKYUAoye2WHmt4Q2vyffk= +``` + +**solution: override the package in configuration.nix** + +if I haven't updated this in the repo yet, add this overlay to your existing overlays in `configuration.nix` to fix the error: + +```nix +overlays = [ + inputs.hydenix.lib.overlays + # fix hash mismatch errors for catppuccin mocha + (final: prev: { + # replace 'hydenix.themes."catppuccin mocha"' with the actual failing package, for theme names check https://github.com/richen604/hydenix/blob/main/hydenix/sources/themes/default.nix + hydenix.themes."Catppuccin Mocha" = prev.hydenix.themes."Catppuccin Mocha".overrideAttrs (oldAttrs: { + src = prev.fetchFromGitHub { + # use the hash from error message under "got:" + sha256 = "HHC15pPHJ+ylQ56yYysEoKjKYUAoye2WHmt4Q2vyffk="; + }; + }); + }) + (final: prev: { + userPkgs = import inputs.nixpkgs { + config.allowUnfree = true; + }; + }) +]; +``` + +#### `Existing file '...' is in the way of '...'` + +this error occurs when home-manager tries to manage a file that already exists and wasn't created by home-manager. + +example: + +```bash +Existing file '/home/user/.config/kitty/kitty.conf' is in the way of '/nix/store/...-home-manager-files/.config/kitty/kitty.conf' +``` + +**solution 1: remove existing files (recommended)** + +remove the conflicting files and let home-manager recreate them: + +```bash +# Remove the specific file +rm ~/.config/kitty/kitty.conf + +# Or remove entire config directory if needed (careful not to delete important files) +rm -rf ~/.config/kitty/ +``` + +**solution 2: backup existing files** + +if you want to preserve your existing configuration: + +```bash +# Create backup +mv ~/.config/kitty/kitty.conf ~/.config/kitty/kitty.conf.backup + +# Then rebuild to let home-manager create the new file +sudo nixos-rebuild switch +``` + +**solution 3: force home-manager to backup automatically** + +add this to your `configuration.nix` to automatically backup conflicting files: + +```nix +{ + home-manager.backupFileExtension = "backup"; +} +``` + +this will automatically rename existing files with a `.backup` extension when home-manager encounters conflicts, allowing the rebuild to proceed without manual intervention only once. + +> [!WARNING] +> if there is a conflict again, home-manager will error for you to manually resolve it. i don't include this by default as automating backups may not be ideal for users and it does not really solve the issue with managing backups + +### what are the module options? + +Visit [options.md](./options.md) for more information on the module options. + +### what if I want to customize hydenix? + +hydenix is designed to be customizable outside of the module options. write your own modules, import your own flakes, packages, etc. + +if you need to disable any of the modules above in [module options](#what-are-the-module-options), simply disable the module and write your own configuration. ideally referencing the module in the source code. + +note however, it's very easy to overwrite hydenix defaults this way and may lead to bugs. feel free to ask questions in our [discord](https://discord.gg/AYbJ9MJez7) if you need help. + + + +### what are some example configurations? + +see [community configs](./community.md) for examples. + +### how do I persist changes on reboot/rebuild/etc? + +> [!IMPORTANT] +> do not edit any mutable files at runtime as they may be overwritten on rebuild
+> all edits must be done in your flake via nixos & home-manager options + +some state files in hydenix are mutable by design. this allows certain theme changes during runtime. + +example: + +lets say you have the default theme set to `Catppuccin Mocha` in `hydenix.hm.theme.active`. + +you change a theme during runtime using `Meta + Shift + T` to `Catppuccin Latte`. +your config is unchanged so when you reboot/relog/rebuild, the theme will revert to `Catppuccin Mocha`. + +```nix +{ + hydenix.hm.theme.active = "Catppuccin Mocha"; +} +``` + +simply change the theme in your config to match your desired theme and rebuild. + +```nix +{ + hydenix.hm.theme.active = "Catppuccin Latte"; +} +``` + +but what about file you want to stop from reverting? waybar position or kitty config? +home-managers `home.file` allows you to do this + +```nix +# any file in `./modules/hm/` +{ + home.file = { + # copy kitty config to your template flake + # cp ~/.config/kitty/kitty.conf ~/path/to/flake/kitty.conf + ".config/kitty/kitty.conf" = { + source = ./kitty.conf; # path to your kitty config in your template flake + }; + # copy waybar position state to your template flake + # cp ~/.config/waybar/config.ctl ~/path/to/flake/config.ctl + ".config/waybar/config.ctl" = { + source = ./config.ctl; # path to your waybar config in your template flake + }; + }; +} +``` + +see [home.file options](https://home-manager-options.extranix.com/?query=home.file&release=master) for more information + + + +### how do I add a new theme? + + + +### what is mutable.nix? + +> [!IMPORTANT] +> do not edit any mutable files at runtime as they may be overwritten on rebuild
+> all edits must be done in your flake via nixos & home-manager options + +`mutable.nix` is a custom module that allows certain files to be copied instead of symlinked during system builds, making them writable at runtime. key points: + +- extends `home.file`, `xdg.configFile`, and `xdg.dataFile` with a `mutable` option +- files marked as `mutable = true` (and `force = true`) will be writable +- changes persist across rebuilds +- useful for programs that need runtime configuration changes + +example usage in scripts: + +```nix +home.activation = { + example = lib.hm.dag.entryAfter [ "mutableGeneration" ] '' + $DRY_RUN_CMD echo "example" + ''; +} +``` + +credit: [@piousdeer](https://gist.github.com/piousdeer/b29c272eaeba398b864da6abf6cb5daa) + + + +### why do themes still show after I remove them from `hydenix.hm.theme.themes`? + +themes are saved in `~/.config/hydenix/themes` so they will still show after you remove them from `hydenix.hm.theme.themes`. +to clear the saved themes, run `rm -rf ~/.config/hydenix/themes/THEME_NAME` for each theme you want to remove. + + + +### requesting features + +please open a [feature request](https://github.com/richen604/hydenix/issues/new?template=feature_request.md) if you have any feature requests. + + + +## other faq + +### how do I run hyprland in a vm? + +hyprland vm is not well supported. check out [hyprland - running in a vm](https://wiki.hyprland.org/Getting-Started/Installation/#running-in-a-vm) + +best bet is to have virtio, opengl, and VT-x support + +non-nixos hosts should run with [nixGL](https://github.com/nix-community/nixGL) eg `nixGL nix run .` + +
+hardware requirements +CPU + +- Intel CPU with VT-x or AMD CPU with AMD-V +- Virtualization enabled in BIOS/UEFI + +GPU + +- NVIDIA: GTX 600+ series (proprietary drivers) +- AMD: HD 7000+ series +- Intel: HD 4000+ (Ivy Bridge) +- OpenGL 3.3+ support required + +
+ +
+ +
+1. install drivers + +```bash +# Nvidia +sudo apt install nvidia-driver nvidia-utils # Debian/Ubuntu +sudo pacman -S nvidia nvidia-utils # Arch +# NixOS configuration +{ + hardware.graphics.enable = true; + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; + hardware.nvidia.modesetting.enable = true; +} + +# AMD +sudo apt install mesa-utils vulkan-tools # Debian/Ubuntu +sudo pacman -S mesa lib32-mesa vulkan-radeon # Arch +# NixOS configuration +{ + hardware.graphics.enable = true; + hardware.graphics.extraPackages = with pkgs; [ amdvlk ]; +} + +# Intel +sudo apt install mesa-utils intel-media-va-driver # Debian/Ubuntu +sudo pacman -S mesa lib32-mesa intel-media-driver # Arch +# NixOS configuration +{ + hardware.graphics.enable = true; + hardware.graphics.extraPackages = with pkgs; [ intel-media-driver ]; +} + +# KVM modprobe +modprobe kvm +modprobe kvm_intel # or kvm_amd +# NixOS configuration +{ + boot.kernelModules = [ "kvm-intel" ]; # or "kvm-amd" for AMD processors + virtualisation.libvirtd.enable = true; +} +``` + +
+ +
+ +
+2. verify setup + +```bash +# Verify KVM support +egrep -c '(vmx|svm)' /proc/cpuinfo # Should return > 0 +lsmod | grep kvm # Check KVM modules + +# Host: Check OpenGL +glxinfo | grep "OpenGL" +``` + +
+ +
+ +
+3. setup the vm + +to set up the vm, follow the instructions in the [hyprland - running in a vm](https://wiki.hyprland.org/Getting-Started/Installation/#running-in-a-vm) guide. + +additionally, the following qemu options have been found to be successful: + +```bash +-device virtio-vga-gl +-display gtk,gl=on,grab-on-hover=on +-usb -device usb-tablet +-cpu host +-enable-kvm +-machine q35 +-device intel-iommu +-device ich9-intel-hda +-device hda-output +-vga none +``` + +
+ + diff --git a/template/docs/installation.md b/template/docs/installation.md new file mode 100644 index 00000000..323b6fb4 --- /dev/null +++ b/template/docs/installation.md @@ -0,0 +1,64 @@ +NixOS + +# installation + +> [!CAUTION] +> the templated flake is designed for a minimal install of nixos. install nixos first, then follow the instructions below. + +1. **initialize the flake template** + + ```bash + # create a new directory and initialize the template + mkdir hydenix && cd hydenix + nix flake init -t github:richen604/hydenix + ``` + +2. **configure your system** + + edit `configuration.nix` following the detailed comments: + + - **optional:** see [module options](./options.md) for advanced configuration + +3. **generate hardware configuration** + + ```bash + sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix + ``` + +4. **initialize git repository** + + ```bash + git init && git add . + ``` + + we do this because flakes must be managed via git. and its good practice to version control your configuration + +5. **build and switch to the new configuration** + + ```bash + sudo nixos-rebuild switch --flake .#hydenix + ``` + + > [!NOTE] + > if you made mistakes, it will fail here. try following: + > - read the error carefully, it may be self-explanatory + > - troubleshooting steps in [troubleshooting & issues](./troubleshooting.md) + > - read the [faq](./faq.md), it may have the answer you're looking for + > - please don't hesitate to ask in [discord](https://discord.gg/AYbJ9MJez7) or [github discussions](https://github.com/richen604/hydenix/discussions)! + +6. **launch hydenix** + + reboot and log in. + + > [!IMPORTANT] + > do not forget to set your password + > + > ```bash + > passwd + > ``` + + you can generate the theme cache with the below: + + ```bash + hyde-shell reload + ``` diff --git a/template/docs/options.md b/template/docs/options.md new file mode 100644 index 00000000..5e7a1b84 --- /dev/null +++ b/template/docs/options.md @@ -0,0 +1,240 @@ + +NixOS + +# hydenix options + +- [hydenix options](#hydenix-options) + - [module documentation](#module-documentation) + - [required options](#required-options) + - [default options](#default-options) + +## module documentation + +going to let you in on a secret: the nix options system *is* the documentation.\ +let's walk through an example. say you want to find info about `hydenix.hm.hyprland`.\ +the easiest way is to search the github repo for the options: + +[search for `hydenix.hm.hyprland`](https://github.com/richen604/hydenix/search?q=hydenix.hm.hyprland) + +you'll see the options in the search results, something like this: + +![options search example](./assets/option-search.png) + +click on the file to see the actual options definition, which looks something like this: + +```nix + options.hydenix.hm.hyprland = { + enable = lib.mkOption { + type = lib.types.bool; + default = config.hydenix.hm.enable; + description = "Enable hyprland module"; + }; + + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Extra config for hyprland"; + }; + }; +``` + +notice that `extraConfig` has type `lines`, which means it accepts multiline strings. +so you'd configure it like this: + +```nix +hydenix.hm.hyprland.extraConfig = '' + # hyprland.conf + windowrule = float, ^(.*) +'' +``` + +you can find the full list of option types in the [nixos manual](https://nlewo.github.io/nixos-manual-sphinx/development/option-types.xml.html). + +## required options + +these are the required options for hydenix. +you *must* set these options or else hydenix will not load. + +```nix +{ + hydenix = { + enable = true; # enable hydenix - required, default false + hostname = "hydenix"; # hostname + timezone = "America/Vancouver"; # timezone + locale = "en_CA.UTF-8"; # locale + hm.enable = true; + }; +} +``` + +## default options + +below are the default options for hydenix. they are in *object format* and any options you may follow the steps above to see any of the options implementation and documentation. + +> [!important] +> `hydenix.hm` options must be used within a home-manager module, eg `./modules/hm/default.nix`. + +```nix +{ + hydenix = { + + # important options + enable = true; # enable hydenix - required, default false + hostname = "hydenix"; # hostname + timezone = "America/Vancouver"; # timezone + locale = "en_CA.UTF-8"; # locale + + # nixos hydenix options + audio.enable = true; # enable audio module + boot = { + enable = true; # enable boot module + useSystemdBoot = true; # disable for GRUB + grubTheme = "Retroboot"; # or "Pochita" + grubExtraConfig = ""; # additional GRUB configuration + kernelPackages = pkgs.linuxPackages_zen; # default zen kernel + }; + gaming.enable = true; # enable gaming module + hardware.enable = true; # enable hardware module + network.enable = true; # enable network module + nix.enable = true; # enable nix module + sddm = { + enable = true; # enable sddm module + theme = "Candy" # or "Corners" + }; + system.enable = true; # enable system module + + # home-manager hydenix options + hm = { + enable = true; # enable home-manager module + comma.enable = true; # useful nix tool to run software without installing it first + dolphin.enable = true; # file manager + editors = { + enable = true; # enable editors module + neovim.enable = true; # enable neovim module + vscode = { + enable = true; # enable vscode module + wallbash = true; # enable wallbash extension for vscode + }; + vim.enable = true; # enable vim module + default = "code"; # default text editor + }; + fastfetch.enable = true; # fastfetch configuration + firefox.enable = true; # enable firefox module + gaming.enable = true; # enable gaming module + git = { + enable = true; # enable git module + name = null; # git user name eg "John Doe" + email = null; # git user email eg "john.doe@example.com" + }; + hyde.enable = true; # enable hyde module + hyprland = { + enable = true; # enable hyprland module + extraConfig = ""; # extra config appended to userprefs.conf + overrideMain = null; # complete override of hyprland.conf + suppressWarnings = false; # suppress warnings + # Animation configurations + animations = { + enable = true; # enable animation configurations + preset = "standard"; # animation preset: "LimeFrenzy", "classic", "diablo-1", "diablo-2", "disable", "dynamic", "end4", "fast", "high", "ja", "me-1", "me-2", "minimal-1", "minimal-2", "moving", "optimized", "standard", "vertical" + extraConfig = ""; # additional animation configuration + overrides = { }; # override specific animation files by name + }; + # Shader configurations + shaders = { + enable = true; # enable shader configurations + overrides = { }; # override or add custom shaders + }; + # Workflow configurations + workflows = { + enable = true; # enable workflow configurations + active = "default"; # active workflow preset: "default", "editing", "gaming", "powersaver", "snappy" + overrides = { }; # override or add custom workflows + }; + # Hypridle configurations + hypridle = { + enable = true; # enable hypridle configurations + extraConfig = ""; # additional hypridle configuration + overrideConfig = null; # complete hypridle configuration override (null or lib.types.lines) + }; + # Keybindings configurations + keybindings = { + enable = true; # enable keybindings configurations + extraConfig = ""; # additional keybindings configuration + overrideConfig = null; # complete keybindings configuration override (null or lib.types.lines) + }; + # Window rules configurations + windowrules = { + enable = true; # enable window rules configurations + extraConfig = ""; # additional window rules configuration + overrideConfig = null; # complete window rules configuration override (null or lib.types.lines) + }; + # NVIDIA configurations + nvidia = { + enable = false; # enable NVIDIA configurations (defaults to config.hardware.nvidia.enabled) + extraConfig = ""; # additional NVIDIA configuration + overrideConfig = null; # complete NVIDIA configuration override (null or lib.types.lines) + }; + # Monitor configurations + monitors = { + enable = true; # enable monitor configurations + overrideConfig = null; # complete monitor configuration override (null or lib.types.lines) + }; + }; + lockscreen = { + enable = true; # enable lockscreen module + hyprlock = true; # enable hyprlock lockscreen + swaylock = false; # enable swaylock lockscreen + }; + notifications.enable = true; # enable notifications module + qt.enable = true; # enable qt module + rofi.enable = true; # enable rofi module + screenshots = { + enable = true; # enable screenshots module + grim.enable = true; # enable grim screenshot tool + slurp.enable = true; # enable slurp region selection tool + satty.enable = false; # enable satty screenshot annotation tool + swappy.enable = true; # enable swappy screenshot editor + }; + wallpapers.enable = true; # enable wallpapers module + shell = { + enable = true; # enable shell module + zsh = { + enable = true; # enable zsh shell + plugins = [ "sudo" ]; # zsh plugins + configText = ""; # zsh config text + }; + bash.enable = false; # enable bash shell + fish.enable = false; # enable fish shell + pokego.enable = false; # enable Pokemon ASCII art scripts + p10k.enable = false; # enable p10k prompt + starship.enable = true; # enable starship prompt + }; + social = { + enable = true; # enable social module + discord.enable = true; # enable discord module + webcord.enable = true; # enable webcord module + vesktop.enable = true; # enable vesktop module + }; + spotify.enable = true; # enable spotify module + swww.enable = true; # enable swww wallpaper daemon + terminals = { + enable = true; # enable terminals module + kitty = { + enable = true; # enable kitty terminal + configText = ""; # kitty config text + }; + }; + theme = { + enable = true; # enable theme module + active = "Catppuccin Mocha"; # active theme name + themes = [ "Catppuccin Mocha" "Catppuccin Latte" ]; # default enabled themes, full list in https://github.com/richen604/hydenix/tree/main/hydenix/sources/themes + }; + waybar = { + enable = true; # enable waybar module + userStyle = ""; # custom waybar user-style.css + }; + wlogout.enable = true; # enable wlogout module + xdg.enable = true; # enable xdg module + }; + }; +} diff --git a/template/docs/troubleshooting.md b/template/docs/troubleshooting.md new file mode 100644 index 00000000..3a8baeb6 --- /dev/null +++ b/template/docs/troubleshooting.md @@ -0,0 +1,30 @@ +NixOS + +# troubleshooting & issues + +## nix errors + +nix errors can be tricky to diagnose, but the below might assist in diagnosing the issue. + +> [!TIP] +> rerun the command with `-v` to get more verbose output. +> you can also rerun the command with `--show-trace` to get a more detailed traceback. +> if the nix error is not clear, often the correct error message is somewhere in the *middle* of the error message. + +## system errors & bugs + +the following information is required when creating an issue, please provide as much as possible. +it's also possible to diagnose issues yourself with the information below. + +1. **system logs** + + ```bash + journalctl -b # System logs + sudo systemctl status home-manager-$HOSTNAME.service # Home-manager status + ``` + +2. **system information** + + ```bash + nix-shell -p nix-info --run "nix-info -m" + ``` diff --git a/template/docs/upgrading.md b/template/docs/upgrading.md new file mode 100644 index 00000000..9dd089c3 --- /dev/null +++ b/template/docs/upgrading.md @@ -0,0 +1,56 @@ +NixOS + +# upgrading + +hydenix can be upgraded, downgraded, or version locked easy. +in your template flake folder, update hydenix to main using: + +```bash +nix flake update hydenix +``` + +or define a specific version in your `flake.nix` template: + +```nix +inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + hydenix = { + # Available inputs: + # Main: github:richen604/hydenix + # Dev: github:richen604/hydenix/dev + # Commit: github:richen604/hydenix/ + # Version: github:richen604/hydenix/v1.0.0 + url = "github:richen604/hydenix"; + }; + }; +``` + +run `nix flake update hydenix` again to load the update, then rebuild your system to apply the changes. + +## when to upgrade + +```mermaid +graph TD + A[v2.3.1] --> B[major] + A --> C[minor] + A --> D[patch] + B --> E[breaking changes
review release notes for api changes] + C --> F[new features
safe to update] + D --> G[bug fixes
safe to update] + + style A fill:#c79bf0,stroke:#ebbcba,stroke-width:2px,color:#000 + style B fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style C fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style D fill:#ebbcba,stroke:#c79bf0,stroke-width:2px,color:#000 + style E fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 + style F fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 + style G fill:#f6f6f6,stroke:#c79bf0,stroke-width:2px,color:#000 +``` + +
+ +> [!Important] +> +> - **always review [release notes](https://github.com/richen604/hydenix/releases) for major updates (API changes)** +> - update to minor versions for new features +> - keep up with patches for stability diff --git a/template/flake.nix b/template/flake.nix index 2f1fa506..125f1e9d 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -25,8 +25,6 @@ outputs = { ... }@inputs: let - HOSTNAME = "hydenix"; - hydenixConfig = inputs.hydenix.inputs.hydenix-nixpkgs.lib.nixosSystem { inherit (inputs.hydenix.lib) system; specialArgs = { @@ -39,7 +37,6 @@ in { - nixosConfigurations.nixos = hydenixConfig; - nixosConfigurations.${HOSTNAME} = hydenixConfig; + nixosConfigurations.hydenix = hydenixConfig; }; } diff --git a/template/modules/hm/default.nix b/template/modules/hm/default.nix index 0e10dfa8..ec4ce80c 100644 --- a/template/modules/hm/default.nix +++ b/template/modules/hm/default.nix @@ -12,95 +12,6 @@ ]; # hydenix home-manager options go here - hydenix.hm = { - #! Important options - enable = true; - /* - ! Below are defaults, no need to uncomment them all - comma.enable = true; # useful nix tool to run software without installing it first - dolphin.enable = true; # file manager - editors = { - enable = true; # enable editors module - neovim = true; # enable neovim module - neovim = true; # enable neovim module - vscode = { - enable = true; # enable vscode module - wallbash = true; # enable wallbash extension for vscode - }; - vim = true; # enable vim module - default = "code"; # default text editor - vim = true; # enable vim module - default = "code"; # default text editor - }; - fastfetch.enable = true; # fastfetch configuration - firefox.enable = true; # enable firefox module - git = { - enable = true; # enable git module - name = null; # git user name eg "John Doe" - email = null; # git user email eg "john.doe@example.com" - }; - hyde.enable = true; # enable hyde module - hyprland = { - enable = true; # enable hyprland module - extraConfig = ""; # extra hyprland config text - }; - lockscreen = { - enable = true; # enable lockscreen module - hyprlock = true; # enable hyprlock lockscreen - swaylock = false; # enable swaylock lockscreen - }; - notifications.enable = true; # enable notifications module - qt.enable = true; # enable qt module - rofi.enable = true; # enable rofi module - screenshots = { - enable = true; # enable screenshots module - grim.enable = true; # enable grim screenshot tool - slurp.enable = true; # enable slurp region selection tool - satty.enable = false; # enable satty screenshot annotation tool - swappy.enable = true; # enable swappy screenshot editor - }; - shell = { - enable = true; # enable shell module - zsh = { - enable = true; # enable zsh shell - plugins = [ "sudo" ]; # zsh plugins - configText = ""; # zsh config text - }; - bash.enable = false; # enable bash shell - fish.enable = false; # enable fish shell - pokego.enable = false; # enable Pokemon ASCII art scripts - p10k.enable = false; # enable p10k prompt - starship.enable = true; # enable starship prompt - }; - social = { - enable = true; # enable social module - discord.enable = true; # enable discord module - webcord.enable = true; # enable webcord module - vesktop.enable = true; # enable vesktop module - }; - spotify.enable = true; # enable spotify module - swww.enable = true; # enable swww wallpaper daemon - terminals = { - enable = true; # enable terminals module - kitty = { - enable = true; # enable kitty terminal - configText = ""; # kitty config text - }; - }; - theme = { - enable = true; # enable theme module - active = "Catppuccin Mocha"; # active theme name - themes = [ - "Catppuccin Mocha" - "Catppuccin Latte" - ]; # default enabled themes, full list in https://github.com/richen604/hydenix/tree/main/hydenix/sources/themes - }; - waybar = { - enable = true; # enable waybar module - userStyle = ""; # custom waybar user-style.css - }; - wlogout.enable = true; # enable wlogout module - xdg.enable = true; # enable xdg module - */ - }; + hydenix.hm.enable = true; + # Visit https://github.com/richen604/hydenix/blob/main/docs/options.md for more options } diff --git a/vm/arch-vm.nix b/vm/arch-vm.nix deleted file mode 100644 index 5628bf20..00000000 --- a/vm/arch-vm.nix +++ /dev/null @@ -1,113 +0,0 @@ -{ pkgs, userConfig, ... }: - -let - vmUtils = import ./vm-utils.nix { inherit pkgs; }; - vmName = "arch-vm"; - vmImage = "output-arch-vm/arch-vm"; - - archVmHcl = pkgs.writeText "arch-vm.pkr.hcl" '' - packer { - required_plugins { - qemu = { - version = ">= 1.0.0" - source = "github.com/hashicorp/qemu" - } - } - } - - source "qemu" "arch" { - iso_url = "https://geo.mirror.pkgbuild.com/iso/latest/archlinux-x86_64.iso" - iso_checksum = "file:https://geo.mirror.pkgbuild.com/iso/latest/sha256sums.txt" - output_directory = "output-arch-vm" - shutdown_command = "echo 'packer' | sudo -S shutdown -P now" - disk_size = "${toString userConfig.vm.diskSize}" - format = "qcow2" - accelerator = "kvm" - ssh_username = "${userConfig.username}" - ssh_password = "${userConfig.defaultPassword}" - ssh_timeout = "20m" - vm_name = "arch-vm" - memory = "${toString userConfig.vm.memorySize}" - cpus = "${toString userConfig.vm.cores}" - headless = false - boot_wait = "8s" - boot_command = [ - "", - "/usr/bin/curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/arch-preseed.sh", - "/usr/bin/bash arch-preseed.sh" - ] - http_directory = "${toString ./.}/scripts/preseed" - ssh_handshake_attempts = "20" - } - - build { - sources = ["source.qemu.arch"] - - provisioner "shell" { - inline = [ - "sudo pacman -Syu --noconfirm", - "sudo pacman -S --noconfirm base-devel git vim", - ] - } - - provisioner "shell" { - script = "${toString ./.}/scripts/install-nix.sh" - } - - provisioner "shell" { - script = "${toString ./.}/../../lib/gen-config.sh" - } - - provisioner "shell" { - inline = [ - "mkdir -p /home/${userConfig.username}/hydenix" - ] - } - - provisioner "file" { - source = "${toString ./.}/../../" - destination = "/home/${userConfig.username}/hydenix" - } - - provisioner "shell" { - script = "${toString ./.}/scripts/install/arch-setup.sh" - } - - provisioner "shell" { - inline = [ - "cd /home/${userConfig.username}/hydenix", - ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh", - "nix run home-manager/master -- switch --flake .#${userConfig.username}-generic", - "nix-channel --add https://github.com/guibou/nixGL/archive/main.tar.gz nixgl && nix-channel --update", - "nix-env -iA nixgl.auto.nixGLDefault", - ] - } - - } - ''; -in -pkgs.writeShellScriptBin "run-arch-vm" '' - # Check if VM image exists, if not, build it - if [ ! -f "${vmImage}" ]; then - echo "VM image not found. Building it now..." - - # Clean up existing output directory - rm -rf output-arch-vm - - ${vmUtils.cleanupVM vmName} - - ${pkgs.packer}/bin/packer init ${archVmHcl} - ${pkgs.packer}/bin/packer build ${archVmHcl} - - # Check if build was successful - if [ ! -f "${vmImage}" ]; then - echo "Failed to build VM image. Exiting." - exit 1 - fi - fi - - ${vmUtils.createAndStartVM { - inherit vmName vmImage userConfig; - osVariant = "archlinux"; - }} -'' diff --git a/vm/fedora-vm.nix b/vm/fedora-vm.nix deleted file mode 100644 index 1f1da45f..00000000 --- a/vm/fedora-vm.nix +++ /dev/null @@ -1,148 +0,0 @@ -{ pkgs, userConfig, ... }: - -let - vmUtils = import ./vm-utils.nix { inherit pkgs; }; - vmName = "fedora-vm"; - vmImage = "output-fedora-vm/fedora-vm"; - - generateKickstartScript = pkgs.writeShellScriptBin "generate-kickstart" '' - #!/bin/bash - # Define variables from userConfig - ROOT_PASSWORD="${userConfig.defaultPassword}" - USERNAME="${userConfig.username}" - USER_PASSWORD="${userConfig.defaultPassword}" - DISK_SIZE=${toString userConfig.vm.diskSize} - - # Calculate partition sizes based on disk size - ROOT_SIZE=$((DISK_SIZE * 70 / 100)) # 70% for root - HOME_SIZE=$((DISK_SIZE * 20 / 100)) # 20% for home - SWAP_SIZE=$((DISK_SIZE * 5 / 100)) # 5% for swap - - # Path to the original Kickstart template - KICKSTART_TEMPLATE="${toString ./.}/scripts/preseed/fedora-kickstart.ks.template" - - # Use a temporary directory for the processed Kickstart file - TEMP_DIR="/tmp/fedora-kickstart" - mkdir -p $TEMP_DIR - KICKSTART_PROCESSED="$TEMP_DIR/fedora-kickstart.ks" - - # Replace placeholders with actual values - sudo sed -e "s/{{ root_password }}/$ROOT_PASSWORD/g" \ - -e "s/{{ username }}/$USERNAME/g" \ - -e "s/{{ user_password }}/$USER_PASSWORD/g" \ - -e "s/{{ root_size }}/$ROOT_SIZE/g" \ - -e "s/{{ home_size }}/$HOME_SIZE/g" \ - -e "s/{{ swap_size }}/$SWAP_SIZE/g" \ - $KICKSTART_TEMPLATE > $KICKSTART_PROCESSED - ''; - - fedoraVmHcl = pkgs.writeText "fedora-vm.pkr.hcl" '' - packer { - required_plugins { - qemu = { - version = ">= 1.0.0" - source = "github.com/hashicorp/qemu" - } - } - } - - source "qemu" "fedora" { - iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/x86_64/iso/Fedora-Server-dvd-x86_64-40-1.14.iso" - iso_checksum = "32d9ab1798fc8106a0b06e873bdcd83a3efea8412c9401dfe4097347ed0cfc65" - output_directory = "output-fedora-vm" - shutdown_command = "echo 'packer' | sudo -S shutdown -P now" - disk_size = "${toString userConfig.vm.diskSize}" - format = "qcow2" - accelerator = "kvm" - ssh_username = "${userConfig.username}" - ssh_password = "${userConfig.defaultPassword}" - ssh_timeout = "20m" - vm_name = "fedora-vm" - memory = "${toString userConfig.vm.memorySize}" - cpus = "${toString userConfig.vm.cores}" - headless = false - boot_command = [ - "", - "e", - "", - " inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/fedora-kickstart.ks" - ] - http_directory = "/tmp/fedora-kickstart" - ssh_handshake_attempts = "20" - } - - build { - sources = ["source.qemu.fedora"] - - provisioner "shell" { - inline = [ - "sudo dnf update -y", - "sudo dnf install -y git vim", - "echo 'Size of /root:' && sudo du -sh /root", - "echo 'Size of /home:' && sudo du -sh /home" - ] - } - - provisioner "shell" { - script = "${toString ./.}/scripts/install-nix.sh" - } - - provisioner "shell" { - script = "${toString ./.}/../../lib/gen-config.sh" - } - - provisioner "shell" { - inline = [ - "mkdir -p /home/${userConfig.username}/hydenix/hydenix" - ] - } - - provisioner "file" { - source = "${toString ./.}/../../" - destination = "/home/${userConfig.username}/hydenix" - } - - provisioner "shell" { - script = "${toString ./.}/scripts/install/fedora-setup.sh" - } - - provisioner "shell" { - inline = [ - "cd /home/${userConfig.username}/hydenix/hydenix", - ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh", - "nix run home-manager/master -- switch --flake .#${userConfig.username}-generic", - "nix-channel --add https://github.com/guibou/nixGL/archive/main.tar.gz nixgl && nix-channel --update", - "nix-env -iA nixgl.auto.nixGLDefault", - ] - } - } - ''; -in -pkgs.writeShellScriptBin "run-fedora-vm" '' - # Check if VM image exists, if not, build it - if [ ! -f "${vmImage}" ]; then - echo "VM image not found. Building it now..." - - # Generate the Kickstart file - ${generateKickstartScript}/bin/generate-kickstart - - # Clean up existing output directory - rm -rf output-fedora-vm - - ${vmUtils.cleanupVM vmName} - - ${pkgs.packer}/bin/packer init ${fedoraVmHcl} - ${pkgs.packer}/bin/packer build ${fedoraVmHcl} - - # Check if build was successful - if [ ! -f "${vmImage}" ]; then - echo "Failed to build VM image. Exiting." - exit 1 - fi - fi - - ${vmUtils.createAndStartVM { - inherit vmName vmImage userConfig; - osVariant = "fedora37"; - }} -'' diff --git a/vm/scripts/install-nix.sh b/vm/scripts/install-nix.sh deleted file mode 100644 index 9afa2c40..00000000 --- a/vm/scripts/install-nix.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm - -# Add Nix to PATH for the current session and future logins -echo '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' >>~/.bashrc -echo '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' >>~/.bash_profile - -# Source Nix environment for the current session -. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh diff --git a/vm/scripts/install/arch-setup.sh b/vm/scripts/install/arch-setup.sh deleted file mode 100644 index 89d05c06..00000000 --- a/vm/scripts/install/arch-setup.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -set -e - -cat <<"EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will set up Arch Linux for Hydenix." -# read -p "Do you want to proceed? (y/n) " REPLY -# echo -# if [[ ! $REPLY =~ ^[Yy]$ ]]; then -# echo "Setup cancelled." -# exit 0 -# fi - -CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/hydenix/config.nix" - -if [ -f "$CONFIG_FILE" ]; then - echo "Config file found. Contents:" - cat "$CONFIG_FILE" -else - echo "Config file not found at $CONFIG_FILE" - exit 1 -fi - -echo "Using config file: $CONFIG_FILE" - -# Function to read values from config.nix -read_config() { - local result - result=$(grep "^[[:space:]]*$1[[:space:]]*=" "$CONFIG_FILE" | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -d '";') - if [ -n "$result" ]; then - echo "$result" - else - echo "Error: Failed to read $1 from config file" >&2 - return 1 - fi -} - -# Read configuration values -USERNAME=$(read_config "username") -TIMEZONE=$(read_config "timezone") -LOCALE=$(read_config "locale") -DEFAULT_PASSWORD=$(read_config "defaultPassword") - -echo "Setting up Arch Linux with the following configuration:" -echo "Username: $USERNAME" -echo "Timezone: $TIMEZONE" -echo "Locale: $LOCALE" -echo - -# read -p "Is this correct? (y/n) " CONFIRM -# if [[ ! $CONFIRM =~ ^[Yy]$ ]]; then -# echo "Please update your config.nix file and run this script again." -# exit 1 -# fi - -# Enable parallel downloads in pacman -echo "Enabling parallel downloads in pacman..." -sudo sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf - -# Update mirrorlist -echo "Updating mirrorlist..." -sudo pacman -S --noconfirm --needed reflector -sudo reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlist - -# Update package database -sudo pacman -Sy --noconfirm - -# Install base packages -echo "Installing base packages..." - -# TODO: review -sudo pacman -S --needed --noconfirm \ - zsh polkit udisks2 openssh \ - pipewire pipewire-pulse \ - sddm \ - networkmanager \ - qemu-guest-agent spice-vdagent \ - libvirt \ - upower \ - iptables \ - libinput \ - xf86-input-libinput \ - dconf - -# Enable services (without starting them yet) -sudo systemctl enable \ - sshd \ - NetworkManager \ - upower \ - libvirtd - -# Set timezone -sudo timedatectl set-timezone "$TIMEZONE" - -# Set locale -sudo localectl set-locale LANG="$LOCALE" - -# Edit existing user -sudo usermod -aG wheel,video "$USERNAME" -sudo chsh -s /bin/zsh "$USERNAME" -echo "$USERNAME:$DEFAULT_PASSWORD" | sudo chpasswd - -# Set up Hyprland to run on boot -echo "Setting up Hyprland to run on boot..." -sudo mkdir -p /usr/share/wayland-sessions -sudo tee /usr/share/wayland-sessions/hyprland.desktop >/dev/null </dev/null < < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will set up macOS for Hydenix." -read -p "Do you want to proceed? (y/n) " REPLY -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo "Setup cancelled." - exit 0 -fi - -CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/hydenix/config.nix" - -if [ -f "$CONFIG_FILE" ]; then - echo "A config.nix file already exists at $CONFIG_FILE" - read -p "Do you want to use the existing config? (y/n) " USE_EXISTING - if [[ ! $USE_EXISTING =~ ^[Yy]$ ]]; then - echo "Please run gen-config to create a new config file." - exit 1 - fi -else - echo "No config file found. Please run gen-config first." - exit 1 -fi - -# Function to read values from config.nix -read_config() { - nix eval --impure --expr "let config = import $CONFIG_FILE; in config.$1" 2>/dev/null | tr -d '"' -} - -# Read configuration values -USERNAME=$(read_config "username") -TIMEZONE=$(read_config "timezone") -LOCALE=$(read_config "locale") -DEFAULT_PASSWORD=$(read_config "defaultPassword") - -echo "Setting up macOS with the following configuration:" -echo "Username: $USERNAME" -echo "Timezone: $TIMEZONE" -echo "Locale: $LOCALE" -echo - -read -p "Is this correct? (y/n) " CONFIRM -if [[ ! $CONFIRM =~ ^[Yy]$ ]] -then - echo "Please update your config.nix file and run this script again." - exit 1 -fi - -# Install Homebrew if not already installed -if ! command -v brew &> /dev/null; then - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -fi - -# Install necessary packages -brew install \ - zsh \ - dbus \ - openssh \ - pipewire \ - wireplumber - -# Set timezone -sudo systemsetup -settimezone "$TIMEZONE" - -# Set locale -sudo languagesetup -langspec "$LOCALE" - -# Create user -sudo dscl . -create /Users/"$USERNAME" -sudo dscl . -create /Users/"$USERNAME" UserShell /bin/zsh -sudo dscl . -create /Users/"$USERNAME" RealName "$USERNAME" -sudo dscl . -create /Users/"$USERNAME" UniqueID "1001" -sudo dscl . -create /Users/"$USERNAME" PrimaryGroupID 20 -sudo dscl . -create /Users/"$USERNAME" NFSHomeDirectory /Users/"$USERNAME" -sudo dscl . -passwd /Users/"$USERNAME" "$DEFAULT_PASSWORD" -sudo dscl . -append /Groups/admin GroupMembership "$USERNAME" - -# Install Nix -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install - -# Source Nix -if [ -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then - . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh -fi - -echo "macOS setup complete. Please restart your system." diff --git a/vm/scripts/install/debian-setup.sh b/vm/scripts/install/debian-setup.sh deleted file mode 100644 index cfe7d5a7..00000000 --- a/vm/scripts/install/debian-setup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# TODO: Debian setup script and VM diff --git a/vm/scripts/install/fedora-setup.sh b/vm/scripts/install/fedora-setup.sh deleted file mode 100644 index bb166bfd..00000000 --- a/vm/scripts/install/fedora-setup.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -set -e - -cat <<"EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will set up Fedora for Hydenix." - -# TODO: add confirmation and confirmation skip flag -# read -p "Do you want to proceed? (y/n) " REPLY -# echo -# if [[ ! $REPLY =~ ^[Yy]$ ]]; then -# echo "Setup cancelled." -# exit 0 -# fi - -CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/hydenix/config.nix" - -if [ -f "$CONFIG_FILE" ]; then - echo "Config file found. Contents:" - cat "$CONFIG_FILE" -else - echo "Config file not found at $CONFIG_FILE" - exit 1 -fi - -echo "Using config file: $CONFIG_FILE" - -# Function to read values from config.nix -read_config() { - local result - result=$(grep "^[[:space:]]*$1[[:space:]]*=" "$CONFIG_FILE" | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -d '";') - if [ -n "$result" ]; then - echo "$result" - else - echo "Error: Failed to read $1 from config file" >&2 - return 1 - fi -} - -# Read configuration values -USERNAME=$(read_config "username") -TIMEZONE=$(read_config "timezone") -LOCALE=$(read_config "locale") -DEFAULT_PASSWORD=$(read_config "defaultPassword") - -echo "Setting up Fedora with the following configuration:" -echo "Username: $USERNAME" -echo "Timezone: $TIMEZONE" -echo "Locale: $LOCALE" -echo - -# TODO: add confirmation and confirmation skip flag -# read -p "Is this correct? (y/n) " CONFIRM -# if [[ ! $CONFIRM =~ ^[Yy]$ ]]; then -# echo "Please update your config.nix file and run this script again." -# exit 1 -# fi - -# Enable fastest mirror -echo "Enabling fastest mirror..." -sudo dnf config-manager --save --setopt=fastestmirror=True - -# Update package database and upgrade system -sudo dnf update -y - -# Install base packages -echo "Installing base packages..." - -# TODO: review -sudo dnf install -y \ - zsh polkit udisks2 openssh \ - pipewire pipewire-pulseaudio \ - sddm \ - NetworkManager \ - qemu-guest-agent spice-vdagent \ - libvirt \ - upower \ - iptables \ - libinput \ - xorg-x11-drv-libinput - -# Enable services (without starting them yet) -sudo systemctl enable \ - sshd \ - NetworkManager \ - upower \ - libvirtd - -# Set timezone -sudo timedatectl set-timezone "$TIMEZONE" - -# Set locale -sudo localectl set-locale LANG="$LOCALE" - -# Edit existing user -sudo usermod -aG wheel,video "$USERNAME" -sudo chsh -s /bin/zsh "$USERNAME" -echo "$USERNAME:$DEFAULT_PASSWORD" | sudo chpasswd - -# Set up Hyprland to run on boot -echo "Setting up Hyprland to run on boot..." -sudo mkdir -p /usr/share/wayland-sessions -sudo tee /usr/share/wayland-sessions/hyprland.desktop >/dev/null </dev/null < < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -# TODO: Ubuntu setup script diff --git a/vm/scripts/preseed/arch-preseed.sh b/vm/scripts/preseed/arch-preseed.sh deleted file mode 100644 index 64ce3334..00000000 --- a/vm/scripts/preseed/arch-preseed.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -set -ex - -# Set up partitions -parted /dev/vda --script mklabel gpt -parted /dev/vda --script mkpart primary 1 3 -parted /dev/vda --script set 1 bios_grub on -parted /dev/vda --script mkpart primary ext4 3 100% - -# Format partitions -mkfs.ext4 /dev/vda2 - -# Mount partitions -mount /dev/vda2 /mnt - -# Initialize pacman keyring -pacman-key --init -pacman-key --populate archlinux - -# Install base system -pacstrap /mnt base linux linux-firmware - -# Generate fstab -genfstab -U /mnt >>/mnt/etc/fstab - -# Chroot and configure system -arch-chroot /mnt /bin/bash < /etc/locale.gen -locale-gen -echo "LANG=en_US.UTF-8" > /etc/locale.conf - -# Set hostname -echo "hydenix" > /etc/hostname - -# Set root password -echo "root:hydenix" | chpasswd - -# Install and configure bootloader -pacman -S --noconfirm grub -grub-install --target=i386-pc --boot-directory=/boot --recheck /dev/vda -grub-mkconfig -o /boot/grub/grub.cfg - -# Enable network services -pacman -S --noconfirm networkmanager -systemctl enable NetworkManager - -# Enable SSH -pacman -S --noconfirm openssh -systemctl enable sshd - -# Create a non-root user -useradd -m -G wheel -s /bin/bash hydenix -echo "hydenix:hydenix" | chpasswd -echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers - -# Install additional useful packages -pacman -S --noconfirm vim sudo - -# Ensure mkinitcpio is run -mkinitcpio -P -EOF - -# Unmount partitions -umount -R /mnt - -# Force sync to ensure all writes are completed -sync - -# Reboot -reboot diff --git a/vm/scripts/preseed/fedora-kickstart.ks.template b/vm/scripts/preseed/fedora-kickstart.ks.template deleted file mode 100644 index 1e0c346f..00000000 --- a/vm/scripts/preseed/fedora-kickstart.ks.template +++ /dev/null @@ -1,67 +0,0 @@ -# Kickstart file for Fedora automated installation - -# Use text mode install -text - -# Set the language and keyboard -lang en_US.UTF-8 -keyboard us - -# Set the timezone -timezone UTC - -# Configure network -network --bootproto=dhcp --device=link --activate - -# Set the root password -rootpw --plaintext {{ root_password }} - -# Create user -user --name={{ username }} --groups=wheel --password={{ user_password }} - -# System services -services --enabled="sshd,NetworkManager" - -# Custom partitioning -part biosboot --size=1 # 1MB for BIOS boot -part / --size={{ root_size }} --grow # Root partition size, grows to fill space -part /home --size={{ home_size }} --grow # Home partition size, grows to fill space -part swap --size={{ swap_size }} # Swap partition size - -# Use the first available disk (vda in this case) -ignoredisk --only-use=vda - -# Clear all partitions -clearpart --all --initlabel --drives=vda - -# System bootloader configuration -bootloader --location=mbr --boot-drive=vda - -# Disable the Setup Agent on first boot -firstboot --disable - -# Accept the EULA -eula --agreed - -# Reboot after installation -reboot - -# Package selection -%packages -@core -vim -sudo -openssh-server -%end - -# Post-installation script -%post -# Enable sudo for wheel group -echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers - -# Update all packages -dnf upgrade -y - -# Enable SELinux -sed -i 's/SELINUX=.*$/SELINUX=enforcing/' /etc/selinux/config -%end diff --git a/vm/scripts/vm-host/arch-setup.sh b/vm/scripts/vm-host/arch-setup.sh deleted file mode 100755 index 55b1641e..00000000 --- a/vm/scripts/vm-host/arch-setup.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -# Add a new variable for the skip confirmation flag -SKIP_CONFIRM=false - -# Parse command line arguments -while [[ "$#" -gt 0 ]]; do - case $1 in - --skip-confirm) SKIP_CONFIRM=true ;; - *) echo "Unknown parameter: $1"; exit 1 ;; - esac - shift -done - -echo "This script will install the necessary dependencies for running VMs on Arch Linux." -echo "These dependencies include QEMU, libvirt, and virt-manager, which are required for creating and managing virtual machines." -echo "The script will also configure your system to run libvirtd service and add your user to the libvirt group." - -# Only ask for confirmation if SKIP_CONFIRM is false -if [ "$SKIP_CONFIRM" = false ]; then - read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]] - then - echo "Installation cancelled." - exit 1 - fi -fi - -# Install required packages -sudo pacman -S --noconfirm qemu libvirt virt-manager ebtables dnsmasq - -# Start and enable libvirtd service -sudo systemctl enable --now libvirtd.service - -# Add user to libvirt group -sudo usermod -aG libvirt $USER - -echo "Arch Linux host dependencies installed successfully." -echo "Please log out and log back in for group changes to take effect." diff --git a/vm/scripts/vm-host/darwin-setup.sh b/vm/scripts/vm-host/darwin-setup.sh deleted file mode 100755 index f9d65a6d..00000000 --- a/vm/scripts/vm-host/darwin-setup.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will install the necessary dependencies for running VMs on macOS (Darwin)." -echo "These dependencies include QEMU and libvirt, which are required for creating and managing virtual machines." -echo "Note that GUI applications like virt-manager are not available on macOS, so you may need to use command-line tools or consider alternatives like UTM." - -read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo "Installation cancelled." - exit 1 -fi - -# Check if Homebrew is installed -if ! command -v brew &> /dev/null; then - echo "Homebrew is not installed. Please install it first: https://brew.sh/" - exit 1 -fi - -# Install required packages -brew install qemu libvirt - -# Start libvirt service -brew services start libvirt - -echo "macOS (Darwin) host dependencies installed successfully." -echo "Note: GUI applications like virt-manager are not available on macOS." -echo "You may need to use command-line tools or consider alternatives like UTM." diff --git a/vm/scripts/vm-host/debian-setup.sh b/vm/scripts/vm-host/debian-setup.sh deleted file mode 100755 index 829ab800..00000000 --- a/vm/scripts/vm-host/debian-setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will install the necessary dependencies for running VMs on Debian." -echo "These dependencies include QEMU, libvirt, and virt-manager, which are required for creating and managing virtual machines." -echo "The script will also configure your system to run libvirtd service and add your user to the libvirt group." - -read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo "Installation cancelled." - exit 1 -fi - -# Update package lists -sudo apt update - -# Install required packages -sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager - -# Add user to libvirt group -sudo usermod -aG libvirt $USER - -# Start and enable libvirtd service -sudo systemctl enable --now libvirtd - -echo "Debian host dependencies installed successfully." -echo "Please log out and log back in for group changes to take effect." diff --git a/vm/scripts/vm-host/fedora-setup.sh b/vm/scripts/vm-host/fedora-setup.sh deleted file mode 100755 index 345483d8..00000000 --- a/vm/scripts/vm-host/fedora-setup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will install the necessary dependencies for running VMs on Fedora." -echo "These dependencies include the virtualization group package, which contains QEMU, libvirt, and other required tools for creating and managing virtual machines." -echo "The script will also configure your system to run libvirtd service and add your user to the libvirt group." - -read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo "Installation cancelled." - exit 1 -fi - -# Install required packages -sudo dnf install -y @virtualization - -# Start and enable libvirtd service -sudo systemctl enable --now libvirtd - -# Add user to libvirt group -sudo usermod -aG libvirt $USER - -echo "Fedora host dependencies installed successfully." -echo "Please log out and log back in for group changes to take effect." diff --git a/vm/scripts/vm-host/nixos-setup.sh b/vm/scripts/vm-host/nixos-setup.sh deleted file mode 100755 index 22b14b31..00000000 --- a/vm/scripts/vm-host/nixos-setup.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script provides instructions for setting up NixOS as a host for running VMs." -echo "The required configuration includes enabling libvirtd, adding your user to the libvirt group, and installing virt-manager." -echo "These changes are necessary to create and manage virtual machines on your NixOS system." - -echo "To set up NixOS as a host for running VMs, add the following to your configuration.nix:" -echo -echo "virtualisation.libvirtd.enable = true;" -echo "users.users..extraGroups = [ \"libvirtd\" ];" -echo "environment.systemPackages = with pkgs; [ virt-manager ];" -echo -echo "Then, run 'sudo nixos-rebuild switch' to apply the changes." diff --git a/vm/scripts/vm-host/ubuntu-setup.sh b/vm/scripts/vm-host/ubuntu-setup.sh deleted file mode 100755 index 57eebd4c..00000000 --- a/vm/scripts/vm-host/ubuntu-setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cat << "EOF" - _ _ _ _ - | | | | | | (_) - | |__| |_ _ __| | ___ _ __ ___ __ - | __ | | | |/ _` |/ _ \ '_ \| \ \/ / - | | | | |_| | (_| | __/ | | | |> < - |_| |_|\__, |\__,_|\___|_| |_|_/_/\_\ - __/ | - |___/ ❄️ Powered by Nix ❄️ -EOF - -echo "This script will install the necessary dependencies for running VMs on Ubuntu." -echo "These dependencies include QEMU, libvirt, and virt-manager, which are required for creating and managing virtual machines." -echo "The script will also configure your system to run libvirtd service and add your user to the libvirt group." - -read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - echo "Installation cancelled." - exit 1 -fi - -# Update package lists -sudo apt update - -# Install required packages -sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager - -# Add user to libvirt group -sudo usermod -aG libvirt $USER - -# Start and enable libvirtd service -sudo systemctl enable --now libvirtd - -echo "Ubuntu host dependencies installed successfully." -echo "Please log out and log back in for group changes to take effect." diff --git a/vm/vm-utils.nix b/vm/vm-utils.nix deleted file mode 100644 index cf77519e..00000000 --- a/vm/vm-utils.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ pkgs }: -rec { - # Common function to create default network - createDefaultNetwork = '' - if ! sudo ${pkgs.libvirt}/bin/virsh net-list --all | grep -q "default"; then - sudo ${pkgs.libvirt}/bin/virsh net-define /dev/stdin < - default - - - - - - - - - EOF - sudo ${pkgs.libvirt}/bin/virsh net-start default - sudo ${pkgs.libvirt}/bin/virsh net-autostart default - fi - ''; - - # Common function to clean up existing VM - cleanupVM = vmName: '' - if sudo ${pkgs.libvirt}/bin/virsh list --all | grep -q "${vmName}"; then - sudo ${pkgs.libvirt}/bin/virsh destroy "${vmName}" || true - sudo ${pkgs.libvirt}/bin/virsh undefine "${vmName}" --remove-all-storage - fi - ''; - - # Common function to launch VM viewer - launchViewer = vmName: userConfig: '' - echo "To connect to the VM, use: virt-viewer --connect qemu:///system --attach ${vmName}" - echo "Default login: username '${userConfig.username}', password '${userConfig.defaultPassword}'" - - sleep 5 - - if [ "$DISPLAY" != "" ]; then - ${pkgs.xorg.xhost}/bin/xhost +SI:localuser:$(id -un) - sudo -E ${pkgs.virt-viewer}/bin/virt-viewer --connect qemu:///system --attach "${vmName}" - else - echo "No display detected. Unable to open virt-viewer automatically." - echo "You can try running 'virt-viewer --connect qemu:///system --attach ${vmName}' manually when X is available." - fi - ''; - - # Common function to create and start VM - createAndStartVM = - { - vmName, - vmImage, - osVariant, - userConfig, - }: - '' - ${createDefaultNetwork} - - ${cleanupVM vmName} - - sudo ${pkgs.virt-manager}/bin/virt-install \ - --connect qemu:///system \ - --name "${vmName}" \ - --memory ${toString userConfig.vm.memorySize} \ - --vcpus ${toString userConfig.vm.cores} \ - --disk path=${vmImage},format=qcow2 \ - --import \ - --os-variant ${osVariant} \ - --network network=default \ - --graphics spice,gl.enable=yes,listen=none,rendernode=/dev/dri/renderD128 \ - --video virtio \ - --noautoconsole - - sudo ${pkgs.libvirt}/bin/virsh --connect qemu:///system start "${vmName}" - - ${launchViewer vmName userConfig} - ''; -}