anchor.diff:            -initrd ${config.system.build.toplevel}/initrd \
             ${qemuGraphics} \
             $QEMU_OPTS \
  -          -append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.bootStage2} systemConfig=${config.system.build.toplevel} ${kernelConsole} $QEMU_KERNEL_PARAMS"
  +          -append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.bootStage2} systemConfig=${config.system.build.toplevel} regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS"
  +    '';
  +
  +    
  +  regInfo = pkgs.runCommand "reginfo"
  +    { exportReferencesGraph =
  +        map (x: [("closure-" + baseNameOf x) x]) config.virtualisation.pathsInNixDB;
  +      buildInputs = [ pkgs.perl ];
  +    }
  +    ''
  +      printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out
       '';
   
   in
  
positive.code:       fi
      '';
  
    # Mount the host filesystem via CIFS, and bind-mount the Nix store
    # of the host into our own filesystem.  We use mkOverride to allow
    # this module to be applied to "normal" NixOS system configuration,
  
negative.code:         default = true;
          description =
            ''
              Whether to run QEMU with a graphics window, or access
              the guest computer serial port through the host tty.
            '';
        };
  
      virtualisation.pathsInNixDB =
        mkOption {
          default = [];
          description =
            ''
              The list of paths whose closure is registered in the Nix
              database in the VM.  All other paths in the host Nix store
              appear in the guest Nix store as well, but are considered
              garbage (because they are not registered in the Nix
              database in the guest).
            '';
        };
        
    };
  
    cfg = config.virtualisation;
  