自己实测记录来了,逐步更新,感觉还不错,安装过程简单。
## 系统安装: ##
1. 先分区:可使用镜像里带的gparted,如果下载的镜像没这东西,随便找张linux安装盘,利用里面的工具分区格式化之……然后退出,使用nixos镜像。
2. 挂载和启用swap
代码:
mount /dev/sdx1 /mnt/
swapon /dev/sdx2
3. 生成系统配置文件模板:会生成两个配置文件 configuration.nix(总控) 和 hardware-configuration.nix(分区设定)
代码:
nixos-generate-config --root /mnt
4. 修改配置:行首是`#`的表示不执行,默认大部分都不执行,需要改为可执行(去掉行首的`#`)
需要修改的项:
- boot.loader.grub.device 指定引导器安装位置
- networking.hostName 设定主机名
- i18n 设定语言
- time.timeZone 设定时区
- environment.systemPackages 设定系统级软件,默认只有wget
- services.openssh.enable 启用的守护进程,有一系列,根据需要开启关闭。
- 设置新用户名和预置密码
具体设置可`man configuration.nix` 查看。
[别人的配置示例](
https://nixos.org/repos/nix/configurations/trunk/)
配置完成后,安装系统:
代码:
nixos-install
若因为网络啥的问题安装失败或者更改了configuration.nix,要继续安装或者刷新配置,也是这个命令`nixos-install`
安装到最后一步,会要求设置root密码:修改密码用 `passwd`
代码:
setting root password...
Enter new UNIX password: ***
Retype new UNIX password: ***
全部搞定后,重启
代码:
reboot
看看有啥软件可安装
代码:
nix-env -qa \*
安装
代码:
nix-env -i w3m
我的配置:还比较乱,过阵子再整理。
代码:
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the GRUB 2 boot loader.
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
# Define on which hard drive you want to install Grub.
boot.loader.grub.device = "/dev/sda";
# file system mount point
fileSystems = [
{ mountPoint = "/home";
device = "/dev/disk/by-uuid/4955738b-a555-4e5c-8bc7-a9b42599f777";
fsType = "ext4";
}
{ mountPoint = "/docs";
device = "/dev/disk/by-uuid/b645272f-dad7-40aa-9701-6cd6a1657eb0d";
fsType = "ext4";
}
];
# networking setting
networking = {
# nameservers = [ "8.8.8.8" ];
hostName = "atlas"; # Define your hostname.
extraHosts = "74.125.206.93 dl-ssl.google.com";
# networkmanager.enable = true;
wireless.enable = true; # Enables wireless support via wpa_supplicant.
enableB43Firmware = true; # for my laptop wireless card firmware
};
# Select internationalisation properties.
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_US.UTF-8";
supportedLocales = [ "en_US.UTF-8/UTF-8"
"zh_CN.UTF-8/UTF-8"
"zh_CN/GB2312"
"zh_CN.GBK/GBK"
"zh_CN.GB18030/GB18030"
"zh_TW.UTF-8/UTF-8"
"zh_TW/BIG5" ];
};
# Set your time zone.
time.timeZone = "Asia/Shanghai";
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
wget
openbox
sddm
git
w3m
luakit
firefox fcitx goldendict
calligra emacs libreoffice okular
wqy-zenhei kde-l10n-zh_CN virt-manager
openjdk openjre
android-sdk
gwenview gimp inkscape blender
];
# allow unfree packages
nixpkgs.config.allowUnfree = true;
# nix mirrors
nix.trustedBinaryCaches = [
"http://cache.nixos.org"
];
boot.kernelModules = [ "kvm-amd" "wl" "tun" "virtio" ];
# 虚拟化
virtualisation = {
# qemu
# libvirtd for virt-manager
libvirtd.enable = true;
};
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Enable CUPS to print documents.
# services.printing.enable = true;
# GUI configuration
services.xserver = {
# Enable the X11 windowing system.
enable = true;
layout = "us";
xkbOptions = "eurosign:e";
## for my ati graphics card
# services.xserver.videoDrivers = [ "ati_unfree" ];
# Enable the KDE Desktop Environment.
displayManager.sddm.enable = true;
# displayManager.kdm.enable = true;
desktopManager.kde4.enable = true;
# Enable openbox
windowManager.openbox.enable = true;
};
## hardware acceleration for 32-bit programs
# hardware.opengl.driSupport32Bit = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
# users.extraUsers.guest = {
# isNormalUser = true;
# uid = 1000;
# };
users.extraUsers.atlas = {
uid = 1000;
group = "users";
extraGroups = ["wheel" "audio" "video" "libvirtd"];
home = "/home/atlas";
isSystemUser = false;
useDefaultShell = true;
initialPassword = "1234567890";
};
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "15.09";
}