NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.01k stars 13.36k forks source link

virtualbox appliance: make /etc/nixos files mimic a fresh install #38429

Closed rbrewer123 closed 5 years ago

rbrewer123 commented 6 years ago

Issue description

The 17.09 virtualbox appliance /etc/nixos/configuration.nix contains just an import, with no comments and no hardware-configuration.nix at all. As installing the appliance is a common way for new users to try out NixOS, I suggest making /etc/nixos contain a full configuration.nix and hardware-configuration.nix as if a normal install were done. This allows new users to more easily build up a configuration and reuse it in a "real" install.

Further background

As a new user, I installed the 17.09 virtualbox appliance to get a feel for NixOS and start building up a configuration.nix before installing on real hardware. However, I soon realized the /etc/nixos/configuration.nix difference described above. It was difficult to find where the imported files actually lived on the system, and I didn't even have vi available. Eventually, I did a "normal" install inside a virtualbox VM and things made much more sense. The default configuration.nix has nice comments and I was able to find bits of configuration via google to get going. I've now installed on a laptop for further use.

Steps to reproduce

Install 17.09 virtualbox appliance. Look at files in /etc/nixos.

Mic92 commented 6 years ago

Was this fixed by? https://github.com/NixOS/nixpkgs/pull/36357

cc @matthewbauer

matthewbauer commented 6 years ago

Can we confirm that this is still an issue in 18.03? @rbrewer123

I recall something changing here but can’t remember if it’s been included.

rbrewer123 commented 6 years ago

@matthewbauer @Mic92 I checked the 18.03 virtualbox appliance and /etc/nixos/configuration.nix appears the same as for 17.09.

matthewbauer commented 6 years ago

Okay I think I understand what you are wanting. You want there to be some example config and docs on how to edit it? Something like this:

https://github.com/nixos/nixpkgs/blob/master/nixos/modules/installer/tools/nixos-generate-config.pl#L554-L632

We can probably do this although it gets tricky with how this is all setup in https://github.com/NixOS/nixpkgs/blob/1e23a5a6e916ad5992916d7517af7b4fa928c812/nixos/modules/virtualisation/virtualbox-image.nix

rbrewer123 commented 6 years ago

Right. The friendly configuration.nix is only present when you install from scratch. The one in the virtualbox image hides its configuration deep in the repository.

The goal of this issue would be that using the virtualbox image just bypasses doing the various partitioning and install steps. But the end result in /etc/nixos looks like you ran those steps just the same.

I'm not far enough along to know how to implement that or how difficult it would be.

matthewbauer commented 5 years ago

Here's an example configuration that I think might meet most user's needs:

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

# This file is used to generate your NixOS system.

# After editing it, you can run:
# $ nixos-rebuild switch

# To try out the changes and
# $ nixos-rebuild fallback
# To go back to the old version.

# A few example configurations are provided below.
# Try them out by uncommenting those lines.

{
  # Base configuration for VirtualBox image.

  imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];

  # Let demo build as a trusted user.

  # nix.trustedUsers = [ "demo" ];

  # Mount a VirtualBox shared folder.
  # This is configurable in the VirtualBox menu at
  # Machine / Settings / Shared Folders.

  # fileSystems."/mnt" = {
  #   fsType = "vboxsf";
  #   device = "nameofdevicetomount";
  #   options = [ "rw" ];
  # };

  # By default, the NixOS VirtualBox demo image includes SDDM and Plasma.
  # If you prefer another desktop manager or display manager, you may want
  # to disable the default.

  # services.xserver.desktopManager.plasma5.enable = lib.mkForce false;
  # services.xserver.displayManager.sddm.enable = lib.mkForce false;

  # Enable GDM/GNOME by uncommenting above two lines and two lines below.

  # services.xserver.displayManager.gdm.enable = true;
  # services.xserver.desktopManager.gnome3.enable = true;

  # Set your time zone.

  # time.timeZone = "Europe/Amsterdam";

  # List packages installed in system profile. To search, run:
  # \$ nix search wget

  # environment.systemPackages = with pkgs; [
  #   wget vim
  # ];

  # Enable the OpenSSH daemon.

  # services.openssh.enable = true;

}

Contains some basic suggestions for what options to try.