<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Home-Manager on blog.rymcg.tech</title>
    <link>https://blog.rymcg.tech/tags/home-manager/</link>
    <description>Recent content in Home-Manager on blog.rymcg.tech</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <copyright>Copyright © 2020-2026, EnigmaCurry</copyright>
    <lastBuildDate>Thu, 29 Jan 2026 00:00:01 -0600</lastBuildDate><atom:link href="https://blog.rymcg.tech/tags/home-manager/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>NixOS VMs part 4: Managing VMs with home-manager and sway-home</title>
      <link>https://blog.rymcg.tech/blog/linux/nixos-vm-home-manager/</link>
      <pubDate>Thu, 29 Jan 2026 00:00:01 -0600</pubDate>
      
      <guid>https://blog.rymcg.tech/blog/linux/nixos-vm-home-manager/</guid>
      <description>&lt;p&gt;&lt;em&gt;This is part 4 of a series on &lt;a href=&#34;https://github.com/EnigmaCurry/nixos-vm-template&#34;&gt;nixos-vm-template&lt;/a&gt;:&lt;/em&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://blog.rymcg.tech/blog/linux/code-agent-vm/&#34;&gt;Running code agents in an immutable NixOS VM&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://blog.rymcg.tech/blog/linux/nixos-proxmox-vm/&#34;&gt;Bootstrapping a Docker server with immutable NixOS on Proxmox&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;a href=&#34;https://blog.rymcg.tech/blog/linux/mutable-vms/&#34;&gt;Mutable VMs are cool too&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Managing VMs with home-manager and sway-home (this post)&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;The previous posts covered creating and managing VMs with
&lt;a href=&#34;https://github.com/EnigmaCurry/nixos-vm-template&#34;&gt;nixos-vm-template&lt;/a&gt;. But
how do you actually integrate it into your daily workflow on your
workstation? This post covers using
&lt;a href=&#34;https://github.com/nix-community/home-manager&#34;&gt;home-manager&lt;/a&gt; to set up
the VM tooling, create shell aliases with tab completion, and manage
updates through the Nix ecosystem.&lt;/p&gt;
&lt;h2 id=&#34;what-is-home-manager&#34;&gt;What is home-manager?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/nix-community/home-manager&#34;&gt;Home Manager&lt;/a&gt; is a tool
for managing user environments using the Nix package manager. Instead of
manually installing programs and editing dotfiles, you declare what you
want in a Nix configuration file, and home-manager builds and activates
that environment.&lt;/p&gt;
&lt;p&gt;The key benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Declarative&lt;/strong&gt;: Your entire user environment is defined in code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reproducible&lt;/strong&gt;: The same configuration produces the same result on
any machine&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rollback&lt;/strong&gt;: Every configuration change creates a new &amp;ldquo;generation&amp;rdquo;
you can switch back to&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Isolated&lt;/strong&gt;: Packages are installed in the Nix store, not globally&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Home-manager works on any Linux distribution - you don&amp;rsquo;t need NixOS. You
just need the Nix package manager installed.&lt;/p&gt;
&lt;h2 id=&#34;what-is-sway-home&#34;&gt;What is sway-home?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/EnigmaCurry/sway-home&#34;&gt;sway-home&lt;/a&gt; is a home-manager
configuration that sets up a complete development environment. It
includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Shell configuration (bash, with aliases and completions)&lt;/li&gt;
&lt;li&gt;Editor setup (Emacs)&lt;/li&gt;
&lt;li&gt;Development tools (git, ripgrep, just, etc.)&lt;/li&gt;
&lt;li&gt;Window manager config (Sway, if you&amp;rsquo;re on Wayland)&lt;/li&gt;
&lt;li&gt;And relevantly: nixos-vm-template integration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you activate sway-home with home-manager, you get all of this
configured and ready to use. The configuration is modular - you can
enable or disable components as needed.&lt;/p&gt;
&lt;h2 id=&#34;the-hm--commands&#34;&gt;The hm-* commands&lt;/h2&gt;
&lt;p&gt;Sway-home provides shell aliases for common home-manager operations. These
are the commands you&amp;rsquo;ll use to manage your environment:&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Command&lt;/th&gt;
          &lt;th&gt;What it does&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-switch&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Rebuild and activate your home-manager configuration&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-update&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Update flake.lock to fetch latest versions of all inputs&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-upgrade&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Update + switch in one step&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-generations&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;List your configuration history (each activation is a &amp;ldquo;generation&amp;rdquo;)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-rollback&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Revert to the previous generation if something breaks&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-metadata&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Show the git revisions of all flake inputs&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;hm-pull&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Git pull the sway-home repository&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The typical workflow: edit your configuration, run &lt;code&gt;hm-switch&lt;/code&gt; to apply
it. If you want the latest upstream changes from sway-home and its
dependencies (including nixos-vm-template), run &lt;code&gt;hm-upgrade&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;the-nixos-vm-template-module&#34;&gt;The nixos-vm-template module&lt;/h2&gt;
&lt;p&gt;One of sway-home&amp;rsquo;s modules, &lt;code&gt;nixos-vm-template.nix&lt;/code&gt;, integrates the VM
tooling directly into your shell. It does three things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Symlinks the nixos-vm-template repository into &lt;code&gt;~/nixos-vm-template&lt;/code&gt;
(bound to the nix store, so it&amp;rsquo;s read-only but versioned)&lt;/li&gt;
&lt;li&gt;Creates a default environment file at
&lt;code&gt;~/.config/nixos-vm-template/env&lt;/code&gt; with XDG-compliant paths&lt;/li&gt;
&lt;li&gt;Sets up the &lt;code&gt;vm&lt;/code&gt; shell alias with tab completion&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After activating home-manager, you get a &lt;code&gt;vm&lt;/code&gt; command that works like
this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm list                    &lt;span style=&#34;color:#75715e&#34;&gt;# List all VMs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm create                  &lt;span style=&#34;color:#75715e&#34;&gt;# Create a VM (interactive wizard)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm ssh myvm                &lt;span style=&#34;color:#75715e&#34;&gt;# SSH in&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm upgrade myvm            &lt;span style=&#34;color:#75715e&#34;&gt;# Upgrade to new image&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;vm create&lt;/code&gt; command runs an interactive configuration wizard that
prompts for the VM name, profiles, memory, CPUs, disk size, and
network mode. After configuration, it builds the image, creates the
VM, and starts it automatically.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;vm&lt;/code&gt; command operates on the local machine&amp;rsquo;s libvirt backend.&lt;/p&gt;
&lt;p&gt;The alias is defined using the &lt;code&gt;_justfile_alias&lt;/code&gt; function, which wraps
&lt;code&gt;just&lt;/code&gt; with a specific Justfile and environment file:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;_justfile_alias vm &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$HOME&lt;span style=&#34;color:#e6db74&#34;&gt;/nixos-vm-template/Justfile&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$HOME&lt;span style=&#34;color:#e6db74&#34;&gt;/.config/nixos-vm-template/env&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This gives you full tab completion for recipes and machine names.
Tab completion works for commands like &lt;code&gt;vm ssh&lt;/code&gt;, &lt;code&gt;vm status&lt;/code&gt;, and
&lt;code&gt;vm upgrade&lt;/code&gt; that take a VM name as an argument.&lt;/p&gt;
&lt;h3 id=&#34;the-nix-store-binding&#34;&gt;The nix store binding&lt;/h3&gt;
&lt;p&gt;Here&amp;rsquo;s an important detail: &lt;code&gt;~/nixos-vm-template&lt;/code&gt; is a symlink into the
nix store, not a regular git clone. The module declares:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;home&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;file&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;nixos-vm-template&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;source &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; inputs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;nixos-vm-template;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This means the repository is read-only. You can&amp;rsquo;t edit files there
directly. The benefit is reproducibility - your VM tooling version is
pinned to a specific commit in the sway-home flake.lock.&lt;/p&gt;
&lt;p&gt;The downside is that changes to nixos-vm-template upstream won&amp;rsquo;t appear
until you update and rebuild. More on that below.&lt;/p&gt;
&lt;h3 id=&#34;where-things-live&#34;&gt;Where things live&lt;/h3&gt;
&lt;p&gt;The environment file sets up XDG-compliant paths:&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Path&lt;/th&gt;
          &lt;th&gt;Purpose&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;~/.config/nixos-vm-template/machines/&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Machine configs (identity files, profiles)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;~/.config/nixos-vm-template/libvirt/&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Libvirt XML templates&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;~/.config/nixos-vm-template/env&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Backend configuration&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;code&gt;~/.local/share/nixos-vm-template/&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Built images and VM disks&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Your machine configs are in &lt;code&gt;~/.config&lt;/code&gt;, so they&amp;rsquo;re easy to back up and
track. The large image files go in &lt;code&gt;~/.local/share&lt;/code&gt; where they won&amp;rsquo;t
clutter your config backups.&lt;/p&gt;
&lt;h2 id=&#34;updating-nixos-vm-template&#34;&gt;Updating nixos-vm-template&lt;/h2&gt;
&lt;p&gt;Since &lt;code&gt;~/nixos-vm-template&lt;/code&gt; is bound to the nix store, you need to update
home-manager to get new versions:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hm-update    &lt;span style=&#34;color:#75715e&#34;&gt;# Update flake.lock (fetches latest nixos-vm-template)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hm-switch    &lt;span style=&#34;color:#75715e&#34;&gt;# Rebuild and activate&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After this, &lt;code&gt;~/nixos-vm-template&lt;/code&gt; points to the new version and all &lt;code&gt;vm&lt;/code&gt;
commands use the updated code.&lt;/p&gt;
&lt;p&gt;To see what version you&amp;rsquo;re running:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hm-metadata
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This shows the git revisions of all flake inputs, including
nixos-vm-template.&lt;/p&gt;
&lt;h2 id=&#34;home-manager-inside-the-vm&#34;&gt;Home-manager inside the VM&lt;/h2&gt;
&lt;p&gt;So far we&amp;rsquo;ve talked about home-manager on your &lt;strong&gt;host workstation&lt;/strong&gt; -
managing your shell, your tools, and the nixos-vm-template integration.
But you can also run home-manager &lt;strong&gt;inside the VM&lt;/strong&gt; to manage the user
environment there.&lt;/p&gt;
&lt;p&gt;To get home-manager inside a VM, include the &lt;code&gt;home-manager&lt;/code&gt; profile when
creating it. Run &lt;code&gt;vm create&lt;/code&gt; and select the &lt;code&gt;home-manager&lt;/code&gt; profile
along with your other desired profiles (e.g., &lt;code&gt;dev&lt;/code&gt;, &lt;code&gt;docker&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;home-manager&lt;/code&gt; profile installs sway-home&amp;rsquo;s configuration inside the
VM, giving you the same shell setup, editor config, and tools. This is
useful for development VMs where you want a consistent environment.&lt;/p&gt;
&lt;p&gt;The profile works in both immutable and mutable VMs, but with slightly
different behavior:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;immutable VMs&lt;/strong&gt;, a custom activation service creates symlinks from
&lt;code&gt;/home/&amp;lt;user&amp;gt;&lt;/code&gt; to the nix store. This handles the complexity of the
read-only root and bind-mounted home directories.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;mutable VMs&lt;/strong&gt;, standard home-manager activation runs. The
filesystem is writable, so home-manager just does its normal thing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that the &lt;code&gt;dev&lt;/code&gt; profile includes basic development tools (neovim,
tmux, etc.) but does &lt;strong&gt;not&lt;/strong&gt; include home-manager. If you want the full
sway-home experience inside the VM, add the &lt;code&gt;home-manager&lt;/code&gt; profile
explicitly.&lt;/p&gt;
&lt;h2 id=&#34;creating-a-proxmox-alias&#34;&gt;Creating a Proxmox alias&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;vm&lt;/code&gt; alias points at libvirt by default. If you also have a Proxmox
server, you can create a separate alias for it.&lt;/p&gt;
&lt;p&gt;First, create an environment file for your Proxmox backend:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;cat &amp;gt; ~/.config/nixos-vm-template/env-pve &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt; &amp;#39;EOF&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;BACKEND=proxmox
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;PVE_HOST=pve
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;PVE_NODE=pve
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;PVE_STORAGE=local-zfs
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;PVE_DISK_FORMAT=raw
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;PVE_BRIDGE=vmbr0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;OUTPUT_DIR=$HOME/.local/share/nixos-vm-template
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;MACHINES_DIR=$HOME/.config/nixos-vm-template/machines-pve
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;LIBVIRT_DIR=$HOME/.config/nixos-vm-template/libvirt
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;EOF&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note the separate &lt;code&gt;MACHINES_DIR&lt;/code&gt; - this keeps Proxmox machine configs
separate from libvirt ones, avoiding confusion.&lt;/p&gt;
&lt;p&gt;Then add the alias to your shell config (e.g., &lt;code&gt;~/.bashrc&lt;/code&gt; or the
sway-home &lt;code&gt;config/bash/alias.sh&lt;/code&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;_justfile_alias pve &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$HOME&lt;span style=&#34;color:#e6db74&#34;&gt;/nixos-vm-template/Justfile&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$HOME&lt;span style=&#34;color:#e6db74&#34;&gt;/.config/nixos-vm-template/env-pve&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you have two aliases:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm create       &lt;span style=&#34;color:#75715e&#34;&gt;# Creates on local libvirt (interactive)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pve create      &lt;span style=&#34;color:#75715e&#34;&gt;# Creates on Proxmox server (interactive)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Both use the same nixos-vm-template codebase and run the same
interactive configuration wizard, but target different backends with
different configurations.&lt;/p&gt;
&lt;h2 id=&#34;disk-space-and-garbage-collection&#34;&gt;Disk space and garbage collection&lt;/h2&gt;
&lt;p&gt;VM images accumulate in &lt;code&gt;~/.local/share/nixos-vm-template/&lt;/code&gt;. Each profile
combination produces an image (typically 3-4 GB), and each VM has its own
&lt;code&gt;/var&lt;/code&gt; disk.&lt;/p&gt;
&lt;p&gt;To see disk usage:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;du -sh ~/.local/share/nixos-vm-template/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To clean up old images (keeping currently-used ones):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm clean
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the nix store itself, home-manager profiles accumulate over time. To
reclaim space:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;nix-collect-garbage --delete-older-than 30d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This removes store paths that aren&amp;rsquo;t referenced by any generation newer
than 30 days. Be careful - this includes home-manager generations, so
you&amp;rsquo;ll lose the ability to roll back to older configs.&lt;/p&gt;
&lt;p&gt;To see how much space you&amp;rsquo;d reclaim:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;nix-store --gc --print-dead
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;the-full-workflow&#34;&gt;The full workflow&lt;/h2&gt;
&lt;p&gt;Here&amp;rsquo;s what a typical session looks like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Update everything&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hm-pull &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; hm-upgrade
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Check what version of nixos-vm-template you&amp;#39;re running&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hm-metadata | grep nixos-vm-template
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Create a VM for a new project (interactive wizard)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm create
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Enter: project-foo, claude/dev/docker/home-manager, 8192, 4, etc.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# The VM starts automatically after creation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Work on the project...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm ssh user@project-foo
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# ... do things ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Later, upgrade the VM to pick up profile changes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm upgrade project-foo
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Deploy to production on Proxmox (interactive wizard)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pve create
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Enter: project-foo, docker, etc.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# The VM starts automatically&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Clean up old images&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vm clean
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;nix-collect-garbage --delete-older-than 7d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The sway-home integration turns nixos-vm-template into a first-class shell
tool. The &lt;code&gt;vm&lt;/code&gt; alias gives you quick access to all VM operations with tab
completion, and the home-manager binding ensures reproducible tooling
versions across machines. Adding backend-specific aliases like &lt;code&gt;pve&lt;/code&gt; lets
you manage VMs across multiple hypervisors from a single workflow.&lt;/p&gt;
&lt;p&gt;The key things to remember:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;~/nixos-vm-template&lt;/code&gt; is read-only; run &lt;code&gt;hm-upgrade&lt;/code&gt; to get updates&lt;/li&gt;
&lt;li&gt;Machine configs live in &lt;code&gt;~/.config/nixos-vm-template/machines/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;nix-collect-garbage&lt;/code&gt; periodically to reclaim disk space&lt;/li&gt;
&lt;li&gt;Create separate aliases and machine directories for each backend&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
