New Nixos install using flakes - nothing is installed

I’m just now trying to dive into Flakes. I have a system installed using

HOSTNAME='myhost'
nixos-install -v --show-trace --no-root-passwd --root /mnt --flake /mnt/etc/nixos#${HOSTNAME} --impure

Everything seems to install fine. However, when I reboot into the machine, no packages are installed. Nothing else from the flake.nix seems to be taking effect. No log in screen. Not even vim is installed.

Here’s the flake file

{
  inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05;
  inputs.home-manager.url = github:nix-community/home-manager;
  
  outputs = { self, nixpkgs, ... }@attrs: {

    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";

      # force git commit before running
      # https://www.tweag.io/blog/2020-07-31-nixos-flakes/
      system.configurationRevision =
        if self ? rev
        then self.rev
        else throw "Refusing to build from a dirty Git tree!";

      specialArgs = attrs;

      # pin all packages to this flake's nixpkgs
      # https://www.tweag.io/blog/2020-07-31-nixos-flakes/
      nix.registry.nixpkgs.flake = nixpkgs;

      modules = [ 
        ./configuration.nix 


        [ ({ pkgs, ... }: {
            #----------------------------------------
            #  Network configuration.
            #----------------------------------------
            # Set your time zone.
            time.timeZone = "America/Los_Angeles";

            networking.useDHCP = false;

            networking.firewall.allowedTCPPorts = [ 
              22 
            ];

            networking.networkmanager.enable = true;

            #----------------------------------------
            # Enable the X11 windowing system.
            #----------------------------------------
            services.xserver.enable = true;

            #----------------------------------------
            # Enable the Plasma 5 Desktop Environment.
            #----------------------------------------
            services.xserver.displayManager.sddm.enable = true;
            services.xserver.desktopManager.plasma5.enable = true;
            
            # sound
            hardware.pulseaudio.enable = true;
            hardware.pulseaudio.support32Bit = true;    ## If compatibility with 32-bit applications is desired.
            

            # -----------------
            # install packages
            # -----------------
            nixpkgs.config.allowUnfree = true;
            
            hardware.bluetooth.enable = true;
            services.blueman.enable = true;
          
            environment.systemPackages = with pkgs; [
              #-----------------
              # cli 
              #-----------------
              #vim
              vimHugeX # includes vim, gvim etc.
              emacs
              htop
              tmux
              rsync
            ];
          
            #----------------------------------------
            # ssh
            #----------------------------------------
            services.openssh.enable = true;
            services.fail2ban = {
              enable = true;
              maxretry = 5;
              ignoreIP = [
                "127.0.0.0/8"
              ];
            };


          })
        ];

      ];
    };
  };
}

There were a few typos in the syntax that for some reason weren’t coming up in the nixos-install command, but did once I hardwired the machine to have an internet connection to rerun nixos-rebuild switch:

  • Removing the at
[ ({ pkgs, ... }: {
...
]
  • a couple of extra parens.

nixos-install would definitely choke on those problems just as much as nixos-rebuild. I suspect you actually ran the install off a slightly different config than you think you did.

Regardless, I’m glad you’ve got it worked out.

That’s possible although I copied the flake.nix over a usb stick, although I definitely changed things dozens of times trying to get meaningful error messages. I actually ended up reinstalling completely around 7 times. I’m glad I finally figured out there were better error messages from nixos-rebuild pointing to obviously simple syntax issues.