diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:20 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:20 +0200 |
commit | 5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010 (patch) | |
tree | a6c0f605be6de3f372ae69905b331f9f75452da7 /nixos/modules/profiles | |
parent | 6070bc016bd2fd945b04347e25cfd3738622d2ac (diff) | |
download | nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.gz nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.bz2 nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.lz nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.xz nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.zst nixpkgs-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.zip |
Move all of NixOS to nixos/ in preparation of the repository merge
Diffstat (limited to 'nixos/modules/profiles')
-rw-r--r-- | nixos/modules/profiles/all-hardware.nix | 55 | ||||
-rw-r--r-- | nixos/modules/profiles/base.nix | 55 | ||||
-rw-r--r-- | nixos/modules/profiles/clone-config.nix | 100 | ||||
-rw-r--r-- | nixos/modules/profiles/demo.nix | 16 | ||||
-rw-r--r-- | nixos/modules/profiles/graphical.nix | 14 | ||||
-rw-r--r-- | nixos/modules/profiles/headless.nix | 21 | ||||
-rw-r--r-- | nixos/modules/profiles/installation-device.nix | 56 | ||||
-rw-r--r-- | nixos/modules/profiles/minimal.nix | 11 | ||||
-rw-r--r-- | nixos/modules/profiles/qemu-guest.nix | 9 |
9 files changed, 337 insertions, 0 deletions
diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix new file mode 100644 index 00000000000..511c118e2bf --- /dev/null +++ b/nixos/modules/profiles/all-hardware.nix @@ -0,0 +1,55 @@ +# This module enables all hardware supported by NixOS: i.e., all +# firmware is included, and all devices from which one may boot are +# enabled in the initrd. Its primary use is in the NixOS installation +# CDs. + +{ config, pkgs, ... }: + +{ + + # The initrd has to contain any module that might be necessary for + # mounting the CD/DVD. + boot.initrd.availableKernelModules = + [ # SATA/PATA support. + "ahci" + + "ata_piix" + + "sata_inic162x" "sata_nv" "sata_promise" "sata_qstor" + "sata_sil" "sata_sil24" "sata_sis" "sata_svw" "sata_sx4" + "sata_uli" "sata_via" "sata_vsc" + + "pata_ali" "pata_amd" "pata_artop" "pata_atiixp" + "pata_cs5520" "pata_cs5530" "pata_cs5535" "pata_efar" + "pata_hpt366" "pata_hpt37x" "pata_hpt3x2n" "pata_hpt3x3" + "pata_it8213" "pata_it821x" "pata_jmicron" "pata_marvell" + "pata_mpiix" "pata_netcell" "pata_ns87410" "pata_oldpiix" + "pata_pcmcia" "pata_pdc2027x" "pata_qdi" "pata_rz1000" + "pata_sc1200" "pata_serverworks" "pata_sil680" "pata_sis" + "pata_sl82c105" "pata_triflex" "pata_via" + "pata_winbond" + + # SCSI support (incomplete). + "3w-9xxx" "3w-xxxx" "aic79xx" "aic7xxx" "arcmsr" + + # USB support, especially for booting from USB CD-ROM + # drives. + "usb_storage" + + # Firewire support. Not tested. + "ohci1394" "sbp2" + + # Virtio (QEMU, KVM etc.) support. + "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "virtio_console" + + # Keyboards + "hid_apple" + ]; + + # Include lots of firmware. + hardware.enableAllFirmware = true; + + imports = + [ ../hardware/network/zydas-zd1211.nix ]; + +} diff --git a/nixos/modules/profiles/base.nix b/nixos/modules/profiles/base.nix new file mode 100644 index 00000000000..20b808c29e0 --- /dev/null +++ b/nixos/modules/profiles/base.nix @@ -0,0 +1,55 @@ +# This module defines the software packages included in the "minimal" +# installation CD. It might be useful elsewhere. + +{ config, pkgs, ... }: + +{ + # Include some utilities that are useful for installing or repairing + # the system. + environment.systemPackages = [ + pkgs.subversion # for nixos-checkout + pkgs.w3m # needed for the manual anyway + pkgs.testdisk # useful for repairing boot problems + pkgs.mssys # for writing Microsoft boot sectors / MBRs + pkgs.parted + pkgs.gptfdisk + pkgs.ddrescue + pkgs.ccrypt + pkgs.cryptsetup # needed for dm-crypt volumes + + # Some networking tools. + pkgs.fuse + pkgs.sshfsFuse + pkgs.socat + pkgs.screen + + # Hardware-related tools. + pkgs.sdparm + pkgs.hdparm + pkgs.dmraid + pkgs.smartmontools # for diagnosing hard disks + + # Tools to create / manipulate filesystems. + pkgs.ntfsprogs # for resizing NTFS partitions + pkgs.dosfstools + pkgs.xfsprogs + pkgs.jfsutils + #pkgs.jfsrec # disabled because of Boost dependency + + # Some compression/archiver tools. + pkgs.unrar + pkgs.unzip + pkgs.zip + pkgs.dar # disk archiver + pkgs.cabextract + + # Some editors. + pkgs.vim + pkgs.bvi # binary editor + pkgs.joe + ]; + + # Include support for various filesystems. + boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" ]; + +} diff --git a/nixos/modules/profiles/clone-config.nix b/nixos/modules/profiles/clone-config.nix new file mode 100644 index 00000000000..d7190020e7e --- /dev/null +++ b/nixos/modules/profiles/clone-config.nix @@ -0,0 +1,100 @@ +{ config, pkgs, modules, ... }: + +with pkgs.lib; + +let + + # Location of the repository on the harddrive + nixosPath = toString ../..; + + # Check if the path is from the NixOS repository + isNixOSFile = path: + let s = toString path; in + removePrefix nixosPath s != s; + + # Copy modules given as extra configuration files. Unfortunately, we + # cannot serialized attribute set given in the list of modules (that's why + # you should use files). + moduleFiles = + filter isPath modules; + + # Partition module files because between NixOS and non-NixOS files. NixOS + # files may change if the repository is updated. + partitionedModuleFiles = + let p = partition isNixOSFile moduleFiles; in + { nixos = p.right; others = p.wrong; }; + + # Path transformed to be valid on the installation device. Thus the + # device configuration could be rebuild. + relocatedModuleFiles = + let + relocateNixOS = path: + "<nixos" + removePrefix nixosPath (toString path) + ">"; + relocateOthers = null; + in + { nixos = map relocateNixOS partitionedModuleFiles.nixos; + others = []; # TODO: copy the modules to the install-device repository. + }; + + # A dummy /etc/nixos/configuration.nix in the booted CD that + # rebuilds the CD's configuration (and allows the configuration to + # be modified, of course, providing a true live CD). Problem is + # that we don't really know how the CD was built - the Nix + # expression language doesn't allow us to query the expression being + # evaluated. So we'll just hope for the best. + configClone = pkgs.writeText "configuration.nix" + '' + { config, pkgs, ... }: + + { + imports = [ ${toString config.installer.cloneConfigIncludes} ]; + } + ''; + +in + +{ + + options = { + + installer.cloneConfig = mkOption { + default = true; + description = '' + Try to clone the installation-device configuration by re-using it's + profile from the list of imported modules. + ''; + }; + + installer.cloneConfigIncludes = mkOption { + default = []; + example = [ "./nixos/modules/hardware/network/rt73.nix" ]; + description = '' + List of modules used to re-build this installation device profile. + ''; + }; + + }; + + config = { + + installer.cloneConfigIncludes = + relocatedModuleFiles.nixos ++ relocatedModuleFiles.others; + + boot.postBootCommands = + '' + # Provide a mount point for nixos-install. + mkdir -p /mnt + + ${optionalString config.installer.cloneConfig '' + # Provide a configuration for the CD/DVD itself, to allow users + # to run nixos-rebuild to change the configuration of the + # running system on the CD/DVD. + if ! [ -e /etc/nixos/configuration.nix ]; then + cp ${configClone} /etc/nixos/configuration.nix + fi + ''} + ''; + + }; + +} diff --git a/nixos/modules/profiles/demo.nix b/nixos/modules/profiles/demo.nix new file mode 100644 index 00000000000..396dcf6c5d3 --- /dev/null +++ b/nixos/modules/profiles/demo.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: + +{ + imports = [ ./graphical.nix ]; + + users.extraUsers.demo = + { description = "Demo user account"; + group = "users"; + extraGroups = [ "wheel" ]; + home = "/home/demo"; + createHome = true; + useDefaultShell = true; + password = "demo"; + isSystemUser = false; + }; +} diff --git a/nixos/modules/profiles/graphical.nix b/nixos/modules/profiles/graphical.nix new file mode 100644 index 00000000000..75ac5e41f83 --- /dev/null +++ b/nixos/modules/profiles/graphical.nix @@ -0,0 +1,14 @@ +# This module defines a NixOS configuration that contains X11 and +# KDE 4. It's used by the graphical installation CD. + +{ config, pkgs, ... }: + +{ + services.xserver = { + enable = true; + displayManager.kdm.enable = true; + desktopManager.kde4.enable = true; + }; + + environment.systemPackages = [ pkgs.glxinfo ]; +} diff --git a/nixos/modules/profiles/headless.nix b/nixos/modules/profiles/headless.nix new file mode 100644 index 00000000000..541c46ca50c --- /dev/null +++ b/nixos/modules/profiles/headless.nix @@ -0,0 +1,21 @@ +# Common configuration for headless machines (e.g., Amazon EC2 +# instances). + +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + sound.enable = false; + boot.vesa = false; + + # Don't start a tty on the serial consoles. + systemd.services."serial-getty@ttyS0".enable = false; + systemd.services."serial-getty@hvc0".enable = false; + + # Since we can't manually respond to a panic, just reboot. + boot.kernelParams = [ "panic=1" "boot.panic_on_fail" ]; + + # Don't allow emergency mode, because we don't have a console. + systemd.enableEmergencyMode = false; +} diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix new file mode 100644 index 00000000000..3b058c6e971 --- /dev/null +++ b/nixos/modules/profiles/installation-device.nix @@ -0,0 +1,56 @@ +# Provide a basic configuration for installation devices like CDs. +{ config, pkgs, modules, ... }: + +with pkgs.lib; + +{ + imports = + [ # Enable devices which are usually scanned, because we don't know the + # target system. + ../installer/scan/detected.nix + ../installer/scan/not-detected.nix + + # Allow "nixos-rebuild" to work properly by providing + # /etc/nixos/configuration.nix. + ./clone-config.nix + ]; + + config = { + + # Show the manual. + services.nixosManual.showManual = true; + + # Let the user play Rogue on TTY 8 during the installation. + services.rogue.enable = true; + + # Disable some other stuff we don't need. + security.sudo.enable = false; + + # Include only the en_US locale. This saves 75 MiB or so compared to + # the full glibcLocales package. + i18n.supportedLocales = ["en_US.UTF-8/UTF-8" "en_US/ISO-8859-1"]; + + # Some more help text. + services.mingetty.helpLine = + '' + + Log in as "root" with an empty password. ${ + optionalString config.services.xserver.enable + "Type `start display-manager' to\nstart the graphical user interface."} + ''; + + # Allow sshd to be started manually through "start sshd". + services.openssh.enable = true; + systemd.services.sshd.wantedBy = mkOverride 50 []; + + # Enable wpa_supplicant, but don't start it by default. + networking.wireless.enable = true; + jobs.wpa_supplicant.startOn = pkgs.lib.mkOverride 50 ""; + + # Tell the Nix evaluator to garbage collect more aggressively. + # This is desirable in memory-constrained environments that don't + # (yet) have swap set up. + environment.variables.GC_INITIAL_HEAP_SIZE = "100000"; + + }; +} diff --git a/nixos/modules/profiles/minimal.nix b/nixos/modules/profiles/minimal.nix new file mode 100644 index 00000000000..821b9f93465 --- /dev/null +++ b/nixos/modules/profiles/minimal.nix @@ -0,0 +1,11 @@ +# This module defines a small NixOS configuration. It does not +# contain any graphical stuff. + +{ config, pkgs, ... }: + +{ + # Don't include X libraries. + programs.ssh.setXAuthLocation = false; + fonts.enableFontConfig = false; + fonts.enableCoreFonts = false; +} diff --git a/nixos/modules/profiles/qemu-guest.nix b/nixos/modules/profiles/qemu-guest.nix new file mode 100644 index 00000000000..c8e6fd4aa76 --- /dev/null +++ b/nixos/modules/profiles/qemu-guest.nix @@ -0,0 +1,9 @@ +# Common configuration for virtual machines running under QEMU (using +# virtio). + +{ config, pkgs, ... }: + +{ + boot.initrd.availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_blk" "9p" "9pnet_virtio" ]; + boot.kernelModules = [ "virtio_balloon" "virtio_console" ]; +} |