Install Vagrant on NixOS
Creado el: 13 de diciembre de 2024
Creado el: 13 de diciembre de 2024
how to install vagrant in nixos
Installing Vagrant on NixOS involves a few steps, including installing Vagrant itself, setting up a virtualization provider (like VirtualBox or libvirt), and configuring your system accordingly. Below is a comprehensive guide to help you get Vagrant up and running on NixOS.
configuration.nixTo install Vagrant system-wide, you can add it to your configuration.nix file.
Edit your configuration.nix:
Open /etc/nixos/configuration.nix in your preferred text editor with root privileges. For example:
bashsudo nano /etc/nixos/configuration.nix
Add Vagrant to environment.systemPackages:
Locate the environment.systemPackages section and add vagrant to the list. It should look something like this:
nix{ environment.systemPackages = with pkgs; [ # ... other packages vagrant ]; # If you plan to use VirtualBox as the provider virtualisation.virtualbox.host.enable = true; }
Note: If you plan to use VirtualBox as your provider, ensure you enable the VirtualBox module as shown above.
Apply the configuration:
bashsudo nixos-rebuild switch
nix-envIf you prefer a user-specific installation without modifying the system configuration:
Install Vagrant:
bashnix-env -iA nixos.vagrant
Vagrant requires a virtualization provider to create and manage virtual machines. The most common providers are VirtualBox and libvirt. Below are instructions for both.
Note: VirtualBox may have licensing restrictions and might require additional setup on NixOS.
Enable VirtualBox in configuration.nix:
As shown earlier, ensure you have the following line in your configuration.nix:
nixvirtualisation.virtualbox.host.enable = true;
Rebuild NixOS Configuration:
bashsudo nixos-rebuild switch
Add Your User to the vboxusers Group:
bashsudo usermod -aG vboxusers $(whoami)
After running this command, log out and log back in for the group change to take effect.
Install Extension Packs (Optional):
If you need additional features like USB support, download and install the VirtualBox Extension Pack from the official website.
libvirt is a more NixOS-friendly virtualization solution and is recommended for better integration.
Enable libvirt and related services in configuration.nix:
nix{ virtualisation.libvirtd.enable = true; virtualisation.libvirtd.extraConfig = '' unix_sock_group = "libvirt" unix_sock_rw_perms = "0770" ''; networking.firewall.allowedTCPPorts = [ 16509 ]; users.groups.libvirt = {}; }
Rebuild NixOS Configuration:
bashsudo nixos-rebuild switch
Install a libvirt-compatible provider for Vagrant:
Vagrant uses plugins to interact with providers. Install the vagrant-libvirt plugin:
bashvagrant plugin install vagrant-libvirt
Ensure Your User is in the libvirt Group:
bashsudo usermod -aG libvirt $(whoami)
Log out and log back in for the changes to take effect.
Check Vagrant Version:
bashvagrant --version
You should see output similar to:
Vagrant 2.x.x
Verify the Provider:
For VirtualBox:
bashvagrant plugin list
Ensure that the VirtualBox provider is available.
For libvirt:
bashvagrant plugin list
Ensure that vagrant-libvirt is listed.
Initialize a Vagrant Project:
Create a new directory and initialize a Vagrant project to test:
bashmkdir ~/vagrant-test cd ~/vagrant-test vagrant init hashicorp/bionic64
Start the Vagrant Machine:
bashvagrant up
Depending on your provider, Vagrant will create and start the virtual machine.
Permissions Issues:
If you encounter permission errors, ensure your user is part of the necessary groups (vboxusers for VirtualBox or libvirt for libvirt) and that you've logged out and back in after adding yourself to the groups.
Provider Not Recognized:
Make sure you've installed the correct Vagrant plugins for your chosen provider (vagrant-libvirt for libvirt).
Firewall Settings:
If you're using libvirt, ensure that the necessary ports (like 16509 for libvirt's TCP port) are open in your firewall settings.
Check Logs:
For VirtualBox issues, check the VirtualBox logs located in ~/.VirtualBox or /var/log/virtualbox.
For libvirt, check logs using:
bashjournalctl -u libvirtd
By following the above steps, you should have Vagrant successfully installed and configured on your NixOS system. Choose the virtualization provider that best fits your workflow and ensure all configurations are correctly applied.
texterror: Package ‘vagrant-2.4.1’ in /nix/store/0xdh22rhgd3232g6ml2h7a6bmprspn4b-nixos-24.05/nixos/pkgs/development/tools/vagrant/default.nix:116 has an unfree license (‘bsl11’), refusing to evaluate. a) To temporarily allow unfree packages, you can use an environment variable for a single invocation of the nix tools. $ export NIXPKGS_ALLOW_UNFREE=1 Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake, then pass `--impure` in order to allow use of environment variables. b) For `nixos-rebuild` you can set { nixpkgs.config.allowUnfree = true; } in configuration.nix to override this. Alternatively you can configure a predicate to allow specific packages: { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "vagrant" ]; } c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add { allowUnfree = true; } to ~/.config/nixpkgs/config.nix.
The error message you're encountering indicates that the Vagrant package you're trying to install has an unfree license (bsl11), and your NixOS system is configured to disallow unfree packages by default. To resolve this, you'll need to allow unfree packages in your NixOS configuration. Below are detailed steps to help you enable unfree packages and successfully install Vagrant.
Error Message:
error: Package ‘vagrant-2.4.1’ in /nix/store/0xdh22rhgd3232g6ml2h7a6bmprspn4b-nixos-24.05/nixos/pkgs/development/tools/vagrant/default.nix:116 has an unfree license (‘bsl11’), refusing to evaluate.
Explanation:
bsl11): The package vagrant-2.4.1 is licensed under the Business Source License 1.1 (bsl11), which is considered unfree by NixOS standards.You have several options to allow unfree packages in NixOS. Choose the one that best fits your needs:
Pros:
Cons:
Steps:
Edit configuration.nix:
Open your NixOS configuration file with a text editor. You can use nano, vim, or any editor of your choice.
bashsudo nano /etc/nixos/configuration.nix
Add allowUnfree = true; to nixpkgs.config:
Locate the nixpkgs.config section. If it doesn't exist, you can add it. Insert the following lines:
nix{ nixpkgs.config = { allowUnfree = true; }; environment.systemPackages = with pkgs; [ # ... other packages vagrant ]; # If you plan to use VirtualBox as the provider virtualisation.virtualbox.host.enable = true; }
Rebuild the NixOS Configuration:
Apply the changes by rebuilding your NixOS system.
bashsudo nixos-rebuild switch
Verify Installation:
Check if Vagrant is installed correctly.
bashvagrant --version
Pros:
Cons:
Steps:
Edit configuration.nix:
bashsudo nano /etc/nixos/configuration.nix
Set allowUnfreePredicate:
Add a predicate that allows only the vagrant package.
nix{ nixpkgs.config = { allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "vagrant" ]; }; environment.systemPackages = with pkgs; [ # ... other packages vagrant ]; # If you plan to use VirtualBox as the provider virtualisation.virtualbox.host.enable = true; }
Rebuild the NixOS Configuration:
bashsudo nixos-rebuild switch
Verify Installation:
bashvagrant --version
Pros:
Cons:
Steps:
Create or Edit User Configuration:
Open (or create) the user-specific Nix configuration file.
bashmkdir -p ~/.config/nixpkgs nano ~/.config/nixpkgs/config.nix
Add allowUnfree = true;:
nix{ allowUnfree = true; }
Install Vagrant Using nix-env:
bashnix-env -iA nixos.vagrant
Verify Installation:
bashvagrant --version
After enabling unfree packages using one of the options above, you can continue with the Vagrant installation as outlined in the initial guide. Here's a brief recap:
VirtualBox:
configuration.nix.libvirt:
vagrant-libvirt installed.bashvagrant plugin install vagrant-libvirt
VirtualBox:
bashsudo usermod -aG vboxusers $(whoami)
libvirt:
bashsudo usermod -aG libvirt $(whoami)
Note: After adding yourself to these groups, log out and log back in for the changes to take effect.
bashmkdir ~/vagrant-test cd ~/vagrant-test vagrant init hashicorp/bionic64 vagrant up
Permission Issues:
vboxusers or libvirt group.Provider Not Recognized:
vagrant-libvirt for libvirt).Vagrantfile.Firewall Settings:
libvirt, ensure port 16509 is open.Check Logs:
VirtualBox Logs: Located in ~/.VirtualBox or /var/log/virtualbox.
libvirt Logs:
bashjournalctl -u libvirtd
By following the above steps, you should be able to enable unfree packages on your NixOS system and successfully install Vagrant. Choose the option that best aligns with your preferences for system configuration and package management.
If you encounter further issues or have additional questions, feel free to ask!
❯ source "$(nix eval --raw 'github:precice/nix-packages#precice-openfoam-adapter.out')/bin/s
et-openfoam-adapter-vars"
/nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/bin/set-openfoam-adapter-vars (line 53): Unsupported use of '='. In fish, please use 'set LD_LIBRARY_PATH /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib:/run/current-system/sw/lib/:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude:'.
LD_LIBRARY_PATH=/nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib:/run/current-system/sw/lib/:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib:/nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
from sourcing file /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/bin/set-openfoam-adapter-vars
source: Error while reading file '/nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/bin/set-openfoam-adapter-vars'
this cause because i am in fish, how to solve it?
The error you're encountering occurs because the set-openfoam-adapter-vars script is written for Bash or a POSIX-compliant shell, and you're attempting to source it in the Fish shell. Fish has a different syntax for setting environment variables, which leads to the error:
Unsupported use of '='. In fish, please use 'set LD_LIBRARY_PATH ...'.
To resolve this, you have a few options:
bass to Bridge Bash and FishBelow, I'll detail each method so you can choose the one that best fits your workflow.
If the set-openfoam-adapter-vars script primarily sets environment variables (like LD_LIBRARY_PATH), you can manually translate those settings into Fish syntax.
Inspect the Script:
First, take a look at what the set-openfoam-adapter-vars script is doing. You can view its contents using:
bashcat "$(nix eval --raw 'github:precice/nix-packages#precice-openfoam-adapter.out')/bin/set-openfoam-adapter-vars"
From your error message, it seems the primary action is setting LD_LIBRARY_PATH.
Convert Variable Assignments to Fish Syntax:
In Fish, setting an environment variable is done using the set command. Here's how you can translate the LD_LIBRARY_PATH assignment:
Bash Syntax:
bashLD_LIBRARY_PATH=/path1:/path2:/path3 export LD_LIBRARY_PATH
Fish Syntax:
fishset -x LD_LIBRARY_PATH /path1 /path2 /path3
Explanation:
set is the Fish command for setting variables.-x exports the variable to the environment.LD_LIBRARY_PATH expects colon-separated paths. Therefore, you need to manually join them with colons.Set the Variable Correctly:
To ensure LD_LIBRARY_PATH is colon-separated in Fish, you can use the string command to join the paths:
fishset -x LD_LIBRARY_PATH /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib /run/current-system/sw/lib/ /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude -U fish_user_paths
However, to join them with colons, use:
fishset -x LD_LIBRARY_PATH (string join : /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib /run/current-system/sw/lib/ /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude)
Add to Fish Configuration for Persistence:
To make these changes persistent across terminal sessions, add the set command to your Fish configuration file (~/.config/fish/config.fish):
fish# Open the Fish config file in your preferred editor nano ~/.config/fish/config.fish
Add the following line:
fishset -x LD_LIBRARY_PATH (string join : /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib /run/current-system/sw/lib/ /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude)
Save and close the file (Ctrl + O, Enter, then Ctrl + X in Nano).
Reload Fish Configuration:
Apply the changes without restarting the terminal:
fishsource ~/.config/fish/config.fish
Verify the Variable:
Check if LD_LIBRARY_PATH is set correctly:
fishecho $LD_LIBRARY_PATH
You should see the colon-separated paths as defined.
If the original script sets multiple environment variables or performs more complex operations, manually translating each line can be tedious. In such cases, creating a Fish-compatible wrapper can help.
Create a New Fish Script:
Let's create a new script named set-openfoam-adapter-vars.fish.
fishnano ~/set-openfoam-adapter-vars.fish
Add Fish-Compatible Commands:
Based on the error message, the script sets LD_LIBRARY_PATH. Add the corresponding Fish command:
fish#!/usr/bin/env fish set -x LD_LIBRARY_PATH /nix/store/v1s5wrh1bpspzlnm2jb3db4canhb7j19-precice-openfoam-adapter-1.2.1/lib /run/current-system/sw/lib/ /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib/dummy /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/platforms/linux64GccDPInt32Opt/lib /nix/store/88f52z1ndxmaxv6xxywf85xm2qmwicnc-openfoam-2206/src/OpenFOAM/lnInclude
If there are more variables being set in the original script, translate each one similarly.
Make the Script Executable:
bashchmod +x ~/set-openfoam-adapter-vars.fish
Source the Fish Script:
In your terminal, run:
fishsource ~/set-openfoam-adapter-vars.fish
Verify the Variables:
fishecho $LD_LIBRARY_PATH
Ensure the paths are correctly set.
Automate Sourcing (Optional):
To automatically source this script every time you start a new Fish session, add the source command to your Fish config:
fishecho 'source ~/set-openfoam-adapter-vars.fish' >> ~/.config/fish/config.fish
bass to Bridge Bash and FishIf the set-openfoam-adapter-vars script is complex and contains numerous Bash-specific commands, using a helper tool like bass can bridge the gap between Bash and Fish.
Install bass:
You can install bass using fisher (a Fish package manager). If you don't have fisher installed, first install it:
fishcurl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
Then, install bass:
fishfisher install edc/bass
Use bass to Source the Script:
bass allows you to run Bash commands and import environment variables into Fish.
fishbass source (nix eval --raw 'github:precice/nix-packages#precice-openfoam-adapter.out')/bin/set-openfoam-adapter-vars
Explanation:
bass source <script> runs the script in a Bash subshell and imports the environment variables into Fish.Verify the Variables:
fishecho $LD_LIBRARY_PATH
Ensure that LD_LIBRARY_PATH and any other variables set by the script are correctly imported.
Automate Using a Function (Optional):
To make this process smoother, you can create a Fish function that uses bass to source the script:
fishfunction set_openfoam_adapter_vars bass source (nix eval --raw 'github:precice/nix-packages#precice-openfoam-adapter.out')/bin/set-openfoam-adapter-vars end
Add this function to your Fish config:
fishecho 'function set_openfoam_adapter_vars; bass source (nix eval --raw '"'"'github:precice/nix-packages#precice-openfoam-adapter.out'"'"')/bin/set-openfoam-adapter-vars; end' >> ~/.config/fish/config.fish
Now, you can simply run set_openfoam_adapter_vars whenever you need to set the variables.
Persisting Variables Across Sessions:
Ensure that environment variables are set every time you start a new terminal session. Adding the appropriate set commands to your ~/.config/fish/config.fish file ensures persistence.
Avoiding Conflicts:
Be cautious when modifying LD_LIBRARY_PATH, as incorrect settings can lead to library conflicts or unexpected behavior in other applications.
Understanding Nix Shells:
Nix provides nix-shell, which can set up isolated environments with specific variables and dependencies. Consider using nix-shell or Nix Flakes to manage your development environments more seamlessly.
Documentation and Support:
precice-openfoam-adapter for Fish-specific instructions or environment variable requirements.The core issue arises from attempting to source a Bash-specific script in the Fish shell, leading to syntax errors. To overcome this:
bass to bridge between Bash and Fish, allowing you to source the original script and import its environment variables.Choose the method that aligns best with your comfort level and workflow requirements. If you frequently work with scripts designed for Bash, integrating bass into your Fish setup can provide a flexible and powerful solution.
If you need further assistance or encounter additional issues, feel free to ask!
i have use sudo nixos-rebuild switch flake ..
how to use home manager command?
When using Nix flakes on NixOS, Home Manager can be integrated two ways: either as a module in your system configuration, or via the standalone home-manager command. The approach you choose depends on your personal preference and project structure. Below are detailed instructions on how to set up and use the home-manager command with flakes.
If you already have a flake-based NixOS configuration, you can integrate Home Manager directly as an imported module. This approach means you don’t necessarily need a separate home-manager command, because nixos-rebuild switch --flake will also manage your home configuration.
Typical flake.nix Structure:
nix{ description = "NixOS configuration with Home Manager as a module"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; home-manager.url = "github:nix-community/home-manager"; }; outputs = { self, nixpkgs, home-manager, ... }: let system = "x86_64-linux"; # or use: system = builtins.currentSystem; in { nixosConfigurations.myHost = nixpkgs.lib.nixosSystem { inherit system; modules = [ ./configuration.nix # Import the Home Manager module home-manager.nixosModules.home-manager # Optionally include a separate home configuration ./home.nix ]; }; }; }
Example home.nix (used by Home Manager as a module):
nix{ config, pkgs, ... }: { home.username = "your-username"; home.homeDirectory = "/home/your-username"; programs.home-manager.enable = true; # Example Home Manager options: home.packages = with pkgs; [ neovim fish # ... ]; # ... }
Build and Switch:
bashsudo nixos-rebuild switch --flake /path/to/your/flake#myHost
home-manager switch command.home-manager Command with Flakes (Standalone Approach)If you prefer having a separate Home Manager command (e.g. for per-user config or to apply home configurations without requiring sudo), you can use Home Manager as a flake-based application.
Using the flake directly, you can run Home Manager without installing it globally:
bashnix run "github:nix-community/home-manager" -- switch --flake /path/to/your/home-flake
/path/to/your/home-flake.If you find yourself doing this often, you can define an alias or add the following line to your shell’s config (e.g., .bashrc, .zshrc, or Fish config):
bashalias hm='nix run "github:nix-community/home-manager" --'
Then you can simply do:
bashhm switch --flake /path/to/your/home-flake
You can also permanently install a flake-based Home Manager as a user profile entry:
bashnix profile install "github:nix-community/home-manager"
After installing, the home-manager binary will be available in your user profile, and you can run:
bashhome-manager switch --flake /path/to/your/home-flake
Minimal flake.nix for Home Manager alone (without a NixOS system configuration):
nix{ description = "Standalone Home Manager flake example"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; home-manager.url = "github:nix-community/home-manager"; }; outputs = { self, nixpkgs, home-manager, ... }: let system = "x86_64-linux"; # or use: system = builtins.currentSystem; in { homeConfigurations.yourUsername = home-manager.lib.homeManagerConfiguration { inherit system; pkgs = import nixpkgs { inherit system; }; modules = [ { home.username = "yourUsername"; home.homeDirectory = "/home/yourUsername"; programs.home-manager.enable = true; home.packages = with pkgs; [ neovim fish # ... ]; # Example configuration for fish programs.fish.enable = true; } ]; }; }; }
Applying the Configuration:
Navigate to the directory containing your flake.nix:
bashcd /path/to/home-flake
Switch to the new configuration:
bashhome-manager switch --flake .
This command:
homeConfigurations.yourUsername.nixos-rebuild vs home-manager switchsudo nixos-rebuild switch --flake ...:
Applies system-wide settings (kernel, services, system packages) and, if Home Manager is used as a module, applies user configs as well.
home-manager switch --flake ...:
Applies home environment settings only—dotfiles, user-level packages, shells, etc.—without needing sudo privileges.
You can combine both approaches in a single flake (system + user), but the actual commands you run (nixos-rebuild switch vs home-manager switch) will determine if you apply system-level changes, user-level changes, or both.
Rebuild the entire NixOS system (including Home Manager as a module):
bashsudo nixos-rebuild switch --flake /path/to/flake#hostname
Use the standalone Home Manager command (flake-based approach):
bashnix run github:nix-community/home-manager -- switch --flake /path/to/your/home-flake
bashnix profile install github:nix-community/home-manager home-manager switch --flake /path/to/your/home-flake
Combine Both Approaches:
In your flake.nix, define both NixOS configuration and a standalone Home Manager config. You can apply system changes with nixos-rebuild switch and apply user config changes with home-manager switch, depending on your workflow needs.
Bottom Line:
To use the home-manager command in a flake-based system, either run it directly via nix run "github:nix-community/home-manager" -- switch --flake ... or install it as a user profile command. If you integrate Home Manager as a module in your system’s flake, nixos-rebuild switch automatically applies your home configs, and you may not need the standalone home-manager command.