Help with transition to flakes

Hi all,
I am trying to begin my transition to using flakes and home-manager. I read the online resources, watched several tutorials and used sample configs online. However, I keep getting one of two errors that I cannot figure out how to fix.

I have a flake.nix file, a directory called hosts (where I would in the future have folders for multiple different hosts, but right now have one) that has a default.nix and a configuration.nix file, and subfolder of hosts called proxvm that has a default.nix and a hardware-configuration.nix file.

When I run sudo nixos-rebuild switch --flake .#proxvm it appears to fail but doesn’t generate a specific error, even if I use the --verbose flag. There is no rebuild process and no output at all.

Since I only have one host right now, I also tried to run sudo nixos-rebuild switch --flake . which generated the below error:

error: flake 'path:/home/nixosadmin1/nixcfg' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."hlnixos"', 'legacyPackages.x86_64-linux.nixosConfigurations."hlnixos"' or 'nixosConfigurations."hlnixos"'

Below are my files, as they exist right now (except hardware-configuration.nix since that is pretty basic and I don’t think the source of the problem). Any help would be much appreciated. I can’t figure out what I am doing wrong that won’t let the --flake .#proxvm approach work.
Thanks in advance for the assistance.


  description = "Personal NixOS/Home-Manager Flake Config";

  inputs = {
      nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";  

      home-manager = {                                                      
        url = "github:nix-community/home-manager/release-23.05";
        inputs.nixpkgs.follows = "nixpkgs";

  outputs = inputs @ { self, nixpkgs, home-manager, ... }:  
    system = "x86_64-linux";

    vars = {
      user = "nixosadmin1";

    pkgs = import nixpkgs {
      inherit system;
      config.allowUnfree = true;

    lib = nixpkgs.lib;

      nixosConfigurations = (                                  
        import ./hosts {                                             
          inherit (nixpkgs) lib;
          inherit inputs system home-manager vars;


{ lib, inputs, system, vars, home-manager, ... }:

  proxvm = lib.nixosSystem {                           # Desktop profile
    inherit system;
    specialArgs = {
      inherit inputs lib system vars;
      #host = {
      #  hostName = "hlnixos";
    modules = [                                         # Modules that are used.

      home-manager.nixosModules.home-manager {          # Home-Manager module that is used.
        home-manager.useGlobalPkgs = true;
        home-manager.useUserPackages = true;


{ config, lib, pkgs, vars, system, inputs, ... }:

  imports =                                 # Import window or display manager.

  programs.zsh.enable = true;

  users.users.${user} = {                   # System User
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" ];
    shell = pkgs.zsh;                       # Default shell

  time.timeZone = "America/New_York";        # Time zone and internationalisation

  i18n = {
    defaultLocale = "en_US.UTF-8";
    extraLocaleSettings = {                 # Extra locale settings that need to be overwritten
    	LC_ADDRESS = "en_US.UTF-8";
	LC_NAME = "en_US.UTF-8";
	LC_NUMERIC = "en_US.UTF-8";
	LC_PAPER = "en_US.UTF-8";
	LC_TIME = "en_US.UTF-8";
	LC_ALL = "en_US.UTF-8";
  fonts.packages = with pkgs; [             # Install fonts
    (nerdfonts.override { fonts = [ "JetBrainsMono" ]; })

  environment = {
    variables = {
      TERMINAL = "alacritty";
      EDITOR = "nvim";
      VISUAL = "nvim";

    systemPackages = with pkgs; [           # Default packages installed system-wide
      (neovim.override { withNodeJs = true; })

  # Allow unauthenticated reboot/shutdown
  security.polkit.extraConfig = ''
    polkit.addRule(function(action, subject) {
      if (
          && (
   == "org.freedesktop.login1.reboot" ||
   == "org.freedesktop.login1.reboot-multiple-sessions" ||
   == "org.freedesktop.login1.power-off" ||
   == "org.freedesktop.login1.power-off-multiple-sessions"
        return polkit.Result.YES;

  services = {
    xrdp = {                                # Enable RDP
      enable = true;
      defaultWindowManager = "awesome";

    pipewire = {                            # Sound
      enable = true;
      alsa = {
        enable = true;
        support32Bit = true;
      pulse.enable = true;
      jack.enable = true;
    openssh = {                             
      enable = true;                        # Enable SSH
      extraConfig = ''
        HostKeyAlgorithms +ssh-rsa
      '';                                   # Temporary extra config so ssh will work in guacamole
    flatpak.enable = true;                  # download flatpak file from website - sudo flatpak install <path> - reboot if not showing up
                                            # sudo flatpak uninstall --delete-data <app-id> (> flatpak list --app) - flatpak uninstall --unused
                                            # List:
                                            # com.obsproject.Studio
                                            # com.parsecgaming.parsec
                                            # com.usebottles.bottles

  # Enable RDP
  networking.firewall.allowedTCPPorts = [ 3389 ];

  nix = {                                   # Nix Package Manager settings
    settings ={
      auto-optimise-store = true;           # Optimise syslinks
    gc = {                                  # Automatic garbage collection
      automatic = true;
      dates = "weekly";
      options = "--delete-older-than 7d";
    package = pkgs.nixVersions.unstable;    # Enable nixFlakes on system
    registry.nixpkgs.flake = inputs.nixpkgs;
    extraOptions = ''
      experimental-features = nix-command flakes
      keep-outputs          = true
      keep-derivations      = true
  nixpkgs.config.allowUnfree = true;        # Allow proprietary software.

  system = {                                # NixOS settings
    stateVersion = "23.05";


{ config, pkgs, lib, vars, system, ... }:

  imports =  [                                  # For now, if applying to other system, swap files
    ./hardware-configuration.nix                # Current system hardware config @ /etc/nixos/hardware-configuration.nix

  # Bootloader
  boot.loader.grub = {
    enable = true;
    device = "/dev/sda";
    useOSProber = true;
    configurationLimit = 5;

  # Set desktop, display and window managers
  services.xserver = {
    enable = true;
    videoDrivers = [ "amdgpu" ];
    desktopManager = {
      xterm.enable = false;
      xfce = {
        enable = true;
        noDesktop = true;
        enableXfwm = false;
    displayManager.defaultSession = "xfce+awesome";
    windowManager.awesome = {
      enable = true;
      luaModules = with pkgs.luaPackages; [
        luarocks #pkg manager for lua modules
        luadbi-mysql #database abstraction layer

  # Set greeter theme options
  services.xserver.displayManager.lightdm = {
    greeters.gtk = { = "Nordic-darker"; = "Nordzy-cyan-dark"; = "Nordzy-cursors";
      extraConfig = ''
        user-background = false

  # Picom
  services.picom.enable = true;
  services.picom.fade = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";

  # Enable networking
  networking.networkmanager.enable = true;
  networking.hostName = "hlnixos";
  programs.nm-applet.enable = true;

  # OpenGL drivers
  hardware.opengl.driSupport = true;
  # For 32 bit applications
  hardware.opengl.driSupport32Bit = true;

By default nixos-rebuild swithc --flake . is going to use the current hostname to build the system. Which appears to be hlnixos and you don’t have a nixosConfiguration named that.

When I run sudo nixos-rebuild switch --flake .#proxvm it appears to fail but doesn’t generate a specific error, even if I use the --verbose flag. There is no rebuild process and no output at all.

I think it would be helpful if you can share the results of running that command, fully copy/pasted from terminal, or maybe this:

nix build -v
  --show-trace \

You can add more -vvv for more verbosity but you really shouldn’t generally need it here…

Are all the files tracked by git? Why not try nix repl then :lf . and exploring outputs? You should be able to find the exact contents of nixosConfigurations.

Ok. So this appears to have worked…kinda. It would not work with --show-trace, it kept saying that was an error. But when I removed it and ran the command it appeared to work. It looked like it built the system after a little clean up (needing to remove exa, for example). I then did sudo ./result/activate to activate the build. That also appeared to work after I added sudo.

I rebooted, but I don’t think it switched to the flake, since the versions of chromium between my old nixos config and my curent flake are different, and right now it still loads the old chromium from the traditional nixos config.

I also wanted to make a change (adding a new package). So I updated the configuration file with the new package, then ran nix flake update to generate the new flake.lock file. That appeared to work fine. However, when I tried to use nixos-rebuild switch --flake .#proxvm with and without sudo it failed without displaying an error. I also tried --show-trace and -vvv neither of which worked. I also tried using .#hlnixos instead of .#proxvm.

Additional ideas?

Strangely, even though I am not fully in the flake (see my last post), when I use the nix-repl and look at nixosConfigurations I get: { proxvm = { ... }; }. So it can clearly see proxvm.

Once you get your config fixed, I’d probably recommend switching back to using nixos-rebuild switch .... Though again, really, you should have been seeing those errors with nixos-rebuild switch (maybe the errors were cached?)

While you can activate the built toplevel manually, I recommend just using nixos-rebuild because it switches into the new generation, after linking it as a system profile. Even if you manually switch/activate the toplevel, it won’t be installed properly as a system generation, thus won’t appear in your boot list, etc.

(Also, I do this by-hand for … I’m not sure why I still do, but I run result/bin/switch-to-configuration switch which is why nixos-rebuild does internally.)

However, when I tried to use nixos-rebuild switch --flake .#proxvm with and without sudo it failed without displaying an error.

It’s not that I don’t believe you, but I still kind want to see it in action myself. That command should more or less be running the command I gave you, internally:

nixos-rebuild switch pretty much:

  1. builds nixosConfigurations.<x>
  2. links it as a system profile (/nix/var/nix/profiles/system-*)
  3. calls ./result/bin/switch-to-configuration switch which will then regenerate boot entries, based on system profiles

where would it cache the error?

it would give an error message, something like this:

cached failure of attribute 'nixosConfigurations.<x>'

(edit: changed verbiage, “clear” is subjective :sweat: )

When I run nixos-rebuild switch --flake .#proxvm I don’t get error. It returns an exit code of 1 and takes no action. The exit code appears in my prompt on the next line. No output from the program. Super weird. It clearly built the program and I attempted to activate, but can’t get it to swtich. Is there some other way to get the swtich to happen?

I can’t speak to that, sorry. I do recall some weird behavior of nixos-rebuild, but that was quite a while ago.

As I mentioned a couple posts up (I double-posted, both are relevant), there are ways to manually switch into the built “toplevel”, but with caveats.

If I use: nixos-rebuild switch --flake '' instead of just .#proxvm

I get:

error: flake 'path:/home/nixosadmin1/nixcfg' does not provide attribute 'packages.x86_64-linux.nixosConfigurations.""', 'legacyPackages.x86_64-linux.nixosConfigurations.""' or 'nixosConfigurations.""'

Does that help explain anything?

No, I wouldn’t expect that to work… and the error message is roughly what I’d expect too.

Insted of (in flake.nix)

nixosConfigurations = (

Try with:

nixosConfigurations."hlnixos" = nixpkgs.lib.nixosSystem rec {
   modules = [
   # ...

Well, I think something is missing in my example, if I remember correctly it is specialArgs.