8000 feat(nix): Support nixos by yutkat · Pull Request #3640 · yutkat/dotfiles · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(nix): Support nixos #3640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

feat(nix): Support nixos #3640

wants to merge 16 commits into from

Conversation

yutkat
Copy link
Owner
@yutkat yutkat commented Jun 5, 2025

No description provided.

Copy link
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @yutkat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

As Gemini, your code-assist companion, I've reviewed this pull request. The primary intent of this PR, based on the title and the significant changes, is to introduce and integrate Nix and Home Manager into the dotfiles management. This involves migrating configuration from previous methods (like Zinit for program installation and manual file management) to a declarative approach using Nix flakes. The changes enable support for NixOS as a primary platform and streamline configuration management for other Linux distributions via Home Manager standalone.

Highlights

  • Nix/Home Manager Integration: The dotfiles have been refactored to use Nix flakes (flake.nix) and Home Manager (home.nix, home-manager/). This shifts the configuration and package management to a declarative system, making it easier to manage dependencies and configurations across different machines.
  • NixOS Support: Adds specific configurations for NixOS systems (nixos/) including system-level settings, bootloader, networking, fonts, input methods, and display management (using greetd/regreet for Hyprland).
  • Standalone Home Manager Support: Includes configurations (home-manager/) designed for using Home Manager on non-NixOS distributions (like Arch, Ubuntu, Fedora) to manage user-level packages and dotfiles.
  • Revised Installation Script: The install.sh script has been completely rewritten to handle the installation of Nix (multi-user or single-user), enable flakes, install Home Manager standalone, and provide instructions for applying the configurations using nixos-rebuild switch or home-manager switch. It also includes an uninstall option.
  • Zsh Configuration Changes: Significant changes were made to the Zsh configuration (.config/zsh/) to comment out Zinit management for many programs (like eza, ripgrep, bat, trashy, neovim, gh) presumably to rely on Nix/Home Manager for their installation. Conditional sourcing based on command existence was added for some plugin configurations.
  • Application Configuration Updates: Various application configurations have been updated, including changes to Chrome flags, CopyQ settings, Hyprland environment variables and window rules, Vivaldi configuration, and Walker entries/icons.
  • Neovim Plugin Updates: The lazy-lock.json file was updated, indicating updates to several Neovim plugins. Additionally, mason-conform.nvim was added, and nixfmt was configured as a formatter for Nix files.

Changelog

Click here to see the changelog
  • .config/chrome-flags.conf
    • Added --disable-features=WaylandTextInputV3 flag.
  • .config/copyq/copyq.conf
    • Changed disable_tray from false to true.
    • Added item_data_threshold=1024.
    • Added navigation_style=0.
    • Added update_clipboard_owner_delay_ms=-1.
    • Added num_sel_fg=.
  • .config/environment.d/50-i3-sway.conf
    • Replaced previous environment variable definitions with a path likely managed by Home Manager.
  • .config/fcitx5/conf/mozc.conf
    • Added InputState="Follow Global Configuration".
  • .config/gtk-4.0/settings.ini
    • Added a new file defining GTK 4 settings (theme, icons, font, cursor, sounds, dark theme preference, recent files).
  • .config/hypr/config.d/env.conf
    • Added env = FCITX_DATA_HOME,$HOME/.config/fcitx5/data.
  • .config/hypr/config.d/startup.conf
    • Changed windowrulev2 to windowrule for CopyQ rules.
    • Updated CopyQ class matching regex from (com.github.hluk.copyq) to .*copyq.
    • Added a 'Logout' entry to the Walker configuration (hyprctl dispatch exit).
  • .config/nvim/lazy-lock.json
    • Updated commit hashes for numerous Neovim plugins (e.g., copilot.lua, debugprint.nvim, gitsigns.nvim, mason.nvim, mason-lspconfig.nvim, neoconf.nvim, neogit, nui.nvim, nvim-dap, nvim-dap-virtual-text, nvim-lint, nvim-lspconfig, nvim-scrollbar, nvim-surround, nvim-treesitter, nvim-treesitter-context, nvim-treesitter-textobjects, nvim-various-textobjs, octo.nvim, one-small-step-for-vimkind, rustaceanvim, translate.nvim).
    • Added mason-conform.nvim plugin entry.
  • .config/nvim/lua/rc/pluginconfig/conform.lua
    • Added nix = { "nixfmt" } to formatters_by_ft.
  • .config/nvim/lua/rc/pluginlist.lua
    • Added mason-conform.nvim plugin definition.
  • .config/vivaldi-stable.conf
    • Replaced previous Vivaldi flags with a single line referencing chromium-flags.conf.
  • .config/walker/config.toml
    • Updated icons for Shutdown, Reboot, and Lock Screen entries to use symbolic versions.
    • Added a 'Logout' entry with hyprctl dispatch exit.
  • .config/zsh/rc/alias.zsh
    • Removed the -x flag from the disk-usage alias.
  • .config/zsh/rc/function.zsh
    • Removed the explicit lspconfig.setup_handlers block from the mason-lspconfig.nvim configuration.
  • .config/zsh/rc/myplugins/command_config.zsh/command_config.zsh
    • Removed an empty line.
  • .config/zsh/rc/pluginconfig/fzf_atload.zsh
    • Added conditional sourcing for fzf key-bindings and completion scripts.
  • .config/zsh/rc/pluginconfig/trashy_atload.zsh
    • Added alias rm='trash put'.
  • .config/zsh/rc/pluginlist.zsh
    • Commented out Zinit configurations for numerous programs (zoxide, fzf, eza, ripgrep, fd, bat, trashy, tealdeer, procs, delta, mmv, zsh, git, neovim, wezterm, translate-shell, direnv, mise, gh, wakatime), indicating a shift to Nix/Home Manager for these.
    • Changed fzf loading to use is-snippet.
    • Added conditional sourcing for some plugin configurations (eza_atload.zsh, bat_atload.zsh, trashy_atload.zsh, neovim_atload.zsh, gh_atload.zsh) if the corresponding command exists.
  • .gitignore
    • Added /.config/nvim/lazy-lock.json to the ignored list.
    • Added Nix/Nixos/home-manager directories and system-etc to the list of paths not to ignore (prefixed with !).
  • .zshenv
    • Added $HOME/.config/zsh/scripts/(N-/) to the path array.
    • Added export GPG_TTY=$(tty).
  • README.md
    • Updated Tokei badge URL.
    • Revised 'Supported OS' section to highlight NixOS and differentiate GUI/CLI support.
    • Rewrote 'Install' section with detailed instructions for NixOS and other OS using Home Manager standalone, including flake configuration editing and using nixos-rebuild switch or home-manager switch.
    • Updated 'Temporary Install' instructions to use a Docker container and the new install.sh --single option.
    • Removed i3 and sway from the list of optional GUI environments.
  • flake.nix
    • Added a new file defining the Nix flake structure.
    • Specifies inputs: nixpkgs, home-manager, neovim-nightly-overlay.
    • Defines outputs for nixosConfigurations and homeConfigurations.
    • Includes host definitions (lemp10, X1C10, test, system-test) with system type, host-specific config path, GUI/System enablement flags, and default username.
    • Provides functions (mkNixosSystem, mkHomeManagerConfiguration) to build configurations based on host attributes.
    • Allows overriding the username via the NIX_USERNAME environment variable.
  • home-manager/cli.nix
    • Added a new file defining Home Manager configuration for CLI packages (git, zsh, neovim, gcc, pythonEnv, nodejs, deno, zip, unzip, eza, wakatime-cli, mise, direnv, translate-shell, gh, ripgrep, delta, tldr, trashy, bat, fd, procs, mmv-go, fzf, sqlite).
    • Adds the python environment bin directory to the session path.
    • Enables neovim (using nightly overlay), zsh, and gpg programs.
    • Configures the gpg-agent service with ssh support and pinentry-curses.
  • home-manager/gui.nix
    • Added a new file defining Home Manager configuration for GUI packages (vivaldi, wezterm, nordzy-cursor-theme, waybar, walker, wl-clipboard-rs, hyprpaper, dunst, libnotify, copyq, hypridle, hyprlock, grim, slurp, pyprland, brightnessctl, adwaita-icon-theme, arc-theme, comixcursors, gnome-themes-extra, papirus-icon-theme).
    • Includes a Nixpkgs overlay to configure Vivaldi with command line arguments read from .config/vivaldi-stable.conf.
    • Enables Hyprland with UWSM and Xwayland.
    • Disables fontconfig.
  • home.nix
    • Added a new file defining the main Home Manager configuration.
    • Imports cli.nix and conditionally imports gui.nix based on the enableGui special argument.
    • Sets home.username, home.homeDirectory, and home.stateVersion.
    • Uses a helper function (mkLink) to create symlinks for files in .config (excluding systemd and environment.d) and .config/environment.d.
    • Creates symlinks for .xinitrc, .xprofile, and .zshenv.
    • Creates executable symlinks for x-terminal-emulator (wezterm) and x-www-browser (vivaldi), conditionally linking to the Nix store path if GUI is enabled, otherwise linking to /usr/bin.
    • Adds an activation script to set the global git config include path.
    • Sets the LD_LIBRARY_PATH session variable to include sqlite.
    • Enables nixpkgs.config.allowUnfree and programs.home-manager.
  • install.sh
    • Completely rewrote the script to manage Nix and Home Manager installation and setup.
    • Added options --single for single-user Nix installation and --uninstall for complete cleanup.
    • Includes functions for detecting OS, checking root, showing help, removing dead symlinks, uninstalling Nix (multi-user/single-user), cleaning user files, installing Nix (multi-user/single-user), enabling flakes, installing Home Manager standalone, and setting up for NixOS or standalone systems.
    • Provides clear logging with colors.
    • Replaced previous dotsinstaller.sh and arch-extra-setup.sh calls with Nix/Home Manager logic.
  • nixos/configuration.nix
    • Added a new file defining the main NixOS system configuration.
    • Imports hardware-configuration.nix.
    • Configures systemd-boot, networking (NetworkManager), timezone, locale/input method (fcitx5 with mozc/gtk), fonts, Xserver (disables GDM/Gnome, enables greetd/regreet), Hyprland with UWSM, XKB layout, locate, printing (CUPS), sound (Pipewire), sudo.
    • Defines the user account with necessary groups and zsh as the shell.
    • Enables programs.zsh and nixpkgs.config.allowUnfree.
    • Adds nix-index to system packages.
    • Sets system.stateVersion and enables nix-command and flakes experimental features.
  • nixos/hardware-configuration.nix
    • Added a new file (likely generated) defining hardware-specific settings for NixOS.
  • nixos/hosts/lemp10/configuration.nix
    • Added a new host-specific NixOS configuration file for 'lemp10'.
    • Imports its hardware configuration.
    • Adds udev rules for custom key mappings on a System76 Lemur.
  • nixos/hosts/lemp10/hardware-configuration.nix
    • Added a new host-specific hardware configuration file (likely generated) for 'lemp10', defining filesystems and LUKS.
  • system-etc/udev/README.md
    • Added a new file explaining the commands needed to apply udev rules after copying.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


From scattered files,
A flake takes hold,
Declarative dreams,
In stories told,
Your system configured, brave and bold.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request aims to enhance the system's functionality by incorporating NixOS configurations and improving various aspects of the user environment. The changes span multiple configuration files, shell scripts, and documentation. While the changes appear to be well-structured, there are several areas that could benefit from further review and refinement.

Summary of Findings

  • Tray Disablement: The tray is disabled in copyq.conf without explanation.
  • Environment File Replacement: The 50-i3-sway.conf file is replaced with a single-line path, requiring verification.
  • Window Rule Syntax Change: The windowrulev2 syntax is replaced with windowrule in startup.conf, requiring compatibility checks.
  • Nixfmt Availability: The conform.lua file adds nixfmt without checking its availability.
  • Disk Usage Alias: The -x option is removed from the disk-usage alias, requiring clarification.
  • FZF Plugin Loading: The fzf plugin is loaded as a snippet, requiring functionality checks.
  • Conditional Plugin Sourcing: The eza and gh plugins are conditionally sourced, requiring initialization checks.
  • Gitignore Lockfile: The lazy-lock.json file is added to .gitignore, requiring justification.
  • ZSH Path Inclusion: A new path is added to the ZSH path variable, requiring security considerations.
  • GPG TTY Export: The GPG_TTY variable is exported, requiring environmental awareness.
  • Nix Flake Check: The nix flake check command is run without the --no-build flag.

Merge Readiness

The pull request introduces significant changes to the system configuration and installation process. While the changes appear to be well-structured, there are several areas that require further clarification and refinement. It is recommended that the pull request not be merged until the issues identified in the review comments are addressed. I am unable to approve this pull request, and users should have others review and approve this code before merging.

@@ -20,7 +20,7 @@ command_history_size=100
confirm_exit=true
copy_clipboard=false
copy_selection=false
disable_tray=false
disable_tray=true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Why is the tray disabled? Disabling the tray might affect the usability of the application. Please add a comment explaining the rationale behind this change.

Comment on lines +51 to +53
windowrule=float,class:.*copyq
windowrule=size 50% 50%,class:.*copyq
windowrule=center,class:.*copyq

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The windowrulev2 syntax is being replaced with windowrule. Ensure that this change is compatible with the current version of Hyprland and that the new syntax functions as expected.

@@ -38,5 +38,6 @@ require("conform").setup({
},
formatters_by_ft = {
markdown = { "my_markdown" },
nix = { "nixfmt" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding nix = { "nixfmt" } to the formatters_by_ft table will enable nixfmt for Nix files. Is nixfmt installed and configured correctly? Consider adding a check to ensure nixfmt is available before attempting to use it.

@@ -166,7 +166,7 @@ function alias-improve() {
}

alias hdu='ncdu --color dark -rr -x --exclude .git --exclude node_modules'
alias disk-usage='sudo ncdu --color dark -rr -x --exclude .git --exclude node_modules /'
alias disk-usage='sudo ncdu --color dark -rr --exclude .git --exclude node_modules /'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The -x option was removed from the disk-usage alias. What was the reason for removing this option? Does this change affect the functionality of the alias?

alias disk-usage='sudo ncdu --color dark -rr -x --exclude .git --exclude node_modules /'

src"shell-integration.zsh" \
atload"source $ZHOMEDIR/rc/pluginconfig/fzf_atload.zsh" \
for @junegunn/fzf
is-snippet for "$ZHOMEDIR/rc/pluginconfig/fzf_atload.zsh"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The fzf plugin is now loaded as a snippet. Ensure that this change doesn't break any existing functionality or customizations related to fzf.

@@ -24,6 +24,7 @@ typeset -xT SUDO_PATH sudo_path
path=(
$HOME/.local/share/zsh/zinit/polaris/bin(N-/)
$HOME/bin(N-/)
$HOME/.config/zsh/scripts/(N-/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding $HOME/.config/zsh/scripts/(N-/) to the path variable will include scripts in that directory in the shell's executable search path. Ensure that all scripts in this directory are safe and intended to be executable.

@@ -113,3 +114,4 @@
helpline=white,black
roottext=lightgrey,black
'
export GPG_TTY=$(tty)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Exporting GPG_TTY=$(tty) sets the TTY for GPG operations. Is this necessary for all environments where this configuration is used? Consider making this conditional based on the environment.

Comment on lines +145 to +146
./install.sh --single
exec bash

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command exec bash is used after installing in temporary install. This will terminate the current shell. Is this the intended behavior?

Comment on lines +34 to +41
if [[ $EUID -eq 0 ]]; then
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
log_error "Single-user mode should not be run as root"
else
log_error "This script should not be run as root"
fi
exit 1
fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The script checks if it's running as root and exits if it is. However, it displays an error message indicating that it shouldn't be run as root. It should be clarified whether running as root is completely disallowed or if there are specific scenarios where it might be necessary (e.g., for certain installation steps).


# Check if flake.nix is valid
log_info "Validating flake configuration..."
if nix flake check --no-build 2>/dev/null; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The nix flake check command is run without the --no-build flag. This might cause unnecessary builds during the installation process. Consider adding the --no-build flag to avoid these builds.

@yutkat yutkat changed the title feat(nix): Support nixso feat(nix): Support nixos Jun 5, 2025
@yutkat yutkat force-pushed the nixos branch 2 times, most recently from aa6bf75 to a461e1f Compare June 5, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0