Reformatted rescue-cd-configurable.nix
svn path=/nixos/trunk/; revision=10401
This commit is contained in:
parent
9fd5d70968
commit
b8cc335fbb
@ -1,43 +1,38 @@
|
|||||||
/*
|
{
|
||||||
platform ? __currentSystem
|
lib
|
||||||
lib
|
,platform ? __currentSystem
|
||||||
*/
|
,networkNixpkgs ? ""
|
||||||
args: with args;
|
,nixpkgsMd5 ? ""
|
||||||
|
,manualEnabled ? true
|
||||||
let
|
,rogueEnabled ? true
|
||||||
arg = name: def: lib.getAttr [name] def args;
|
,sshdEnabled ? false
|
||||||
platform = arg "platform" __currentSystem;
|
,fontConfigEnabled ? false
|
||||||
networkNixpkgs = arg "networkNixpkgs" "";
|
,sudoEnable ? false
|
||||||
nixpkgsMd5 = arg "nixpkgsMd5" "";
|
,packages ? (pkgs : [])
|
||||||
manualEnabled = arg "manualEnabled" true;
|
,includeMemtest ? true
|
||||||
rogueEnabled = arg "rogueEnabled" true;
|
,includeStdenv ? true
|
||||||
ttyCount = lib.fold builtins.add 0 [
|
,includeBuildDeps ? false
|
||||||
(if rogueEnabled then 1 else 0)
|
,kernel ? (pkgs : pkgs.kernel)
|
||||||
(if manualEnabled then 1 else 0)
|
,addUsers ? []
|
||||||
];
|
,extraInitrdKernelModules ? []
|
||||||
sshdEnabled = arg "sshdEnabled" false;
|
,bootKernelModules ? []
|
||||||
fontConfigEnabled = arg "fontConfigEnabled" false;
|
,arbitraryOverrides ? (config:{})
|
||||||
sudoEnable = arg "sudoEnable" false;
|
,cleanStart ? false
|
||||||
packages = arg "packages" (pkgs : []);
|
|
||||||
includeMemtest = arg "includeMemtest" true;
|
|
||||||
includeStdenv = arg "includeStdenv" true;
|
|
||||||
includeBuildDeps = arg "includeBuildDeps" false;
|
|
||||||
kernel = arg "kernel" (pkgs : pkgs.kernel);
|
|
||||||
addUsers = arg "addUsers" [];
|
|
||||||
extraInitrdKernelModules = arg "extraInitrdKernelModules" [];
|
|
||||||
bootKernelModules = arg "bootKernelModules" [];
|
|
||||||
arbitraryOverrides = arg "arbitraryOverrides" (config:{});
|
|
||||||
cleanStart = arg "cleanStart" false;
|
|
||||||
|
|
||||||
/* Should return list of {configuration, suffix} attrsets.
|
/* Should return list of {configuration, suffix} attrsets.
|
||||||
{configuration=configuration; suffix=""} is always prepended.
|
{configuration=configuration; suffix=""} is always prepended.
|
||||||
*/
|
*/
|
||||||
configList = arg "configList" (configuration : []);
|
,configList ? (configuration : [])
|
||||||
aufs = arg "aufs" true;
|
,aufs ? true
|
||||||
in
|
}:
|
||||||
let
|
let
|
||||||
|
ttyCount = lib.fold builtins.add 0 [
|
||||||
|
(if rogueEnabled then 1 else 0)
|
||||||
|
(if manualEnabled then 1 else 0)
|
||||||
|
];
|
||||||
|
|
||||||
systemPackBuilder = {suffix, configuration} : {
|
systemPackBuilder = {suffix, configuration} :
|
||||||
|
{
|
||||||
system = (import ../system/system.nix) {
|
system = (import ../system/system.nix) {
|
||||||
inherit configuration platform; /* To refactor later - x86+x86_64 DVD */
|
inherit configuration platform; /* To refactor later - x86+x86_64 DVD */
|
||||||
stage2Init = "/init"+suffix;
|
stage2Init = "/init"+suffix;
|
||||||
@ -45,7 +40,8 @@ let
|
|||||||
inherit suffix configuration;
|
inherit suffix configuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemPackGrubEntry = systemPack : (''
|
systemPackGrubEntry = systemPack :
|
||||||
|
(''
|
||||||
|
|
||||||
title NixOS Installer / Rescue ${systemPack.system.config.boot.configurationName}
|
title NixOS Installer / Rescue ${systemPack.system.config.boot.configurationName}
|
||||||
kernel /boot/vmlinuz${systemPack.suffix} ${toString systemPack.system.config.boot.kernelParams} systemConfig=/system${systemPack.suffix}
|
kernel /boot/vmlinuz${systemPack.suffix} ${toString systemPack.system.config.boot.kernelParams} systemConfig=/system${systemPack.suffix}
|
||||||
@ -53,31 +49,39 @@ let
|
|||||||
|
|
||||||
'');
|
'');
|
||||||
|
|
||||||
systemPackInstallRootList = systemPack : [
|
systemPackInstallRootList = systemPack :
|
||||||
{ source = systemPack.system.kernel + "/vmlinuz";
|
[
|
||||||
|
{
|
||||||
|
source = systemPack.system.kernel + "/vmlinuz";
|
||||||
target = "boot/vmlinuz${systemPack.suffix}";
|
target = "boot/vmlinuz${systemPack.suffix}";
|
||||||
}
|
}
|
||||||
{ source = systemPack.system.initialRamdisk + "/initrd";
|
{
|
||||||
|
source = systemPack.system.initialRamdisk + "/initrd";
|
||||||
target = "boot/initrd${systemPack.suffix}";
|
target = "boot/initrd${systemPack.suffix}";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
systemPackInstallClosures = systemPack : ([
|
systemPackInstallClosures = systemPack :
|
||||||
{ object = systemPack.system.bootStage2;
|
([
|
||||||
|
{
|
||||||
|
object = systemPack.system.bootStage2;
|
||||||
symlink = "/init${systemPack.suffix}";
|
symlink = "/init${systemPack.suffix}";
|
||||||
}
|
}
|
||||||
{ object = systemPack.system.system;
|
{
|
||||||
|
object = systemPack.system.system;
|
||||||
symlink = "/system${systemPack.suffix}";
|
symlink = "/system${systemPack.suffix}";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
++
|
++
|
||||||
(lib.optional includeStdenv
|
(lib.optional includeStdenv
|
||||||
# To speed up the installation, provide the full stdenv.
|
# To speed up the installation, provide the full stdenv.
|
||||||
{ object = systemPack.system.pkgs.stdenv;
|
{
|
||||||
|
object = systemPack.system.pkgs.stdenv;
|
||||||
symlink = "none";
|
symlink = "none";
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
systemPackInstallBuildClosure = systemPack : ([
|
systemPackInstallBuildClosure = systemPack :
|
||||||
|
([
|
||||||
{
|
{
|
||||||
object = systemPack.system.system.drvPath;
|
object = systemPack.system.system.drvPath;
|
||||||
symlink = "none";
|
symlink = "none";
|
||||||
@ -85,7 +89,8 @@ let
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
userEntry = user : {
|
userEntry = user :
|
||||||
|
{
|
||||||
name = user;
|
name = user;
|
||||||
description = "NixOS Live Disk non-root user";
|
description = "NixOS Live Disk non-root user";
|
||||||
home = "/home/${user}";
|
home = "/home/${user}";
|
||||||
@ -97,20 +102,17 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
|
||||||
nixpkgsRel = "nixpkgs" + (if networkNixpkgs != "" then "-" + networkNixpkgs else "");
|
nixpkgsRel = "nixpkgs" + (if networkNixpkgs != "" then "-" + networkNixpkgs else "");
|
||||||
|
|
||||||
|
|
||||||
configuration = let preConfiguration ={
|
configuration = let preConfiguration ={
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
isLiveCD = true;
|
isLiveCD = true;
|
||||||
autoDetectRootDevice = true;
|
autoDetectRootDevice = true;
|
||||||
# The label used to identify the installation CD.
|
# The label used to identify the installation CD.
|
||||||
rootLabel = "NIXOS";
|
rootLabel = "NIXOS";
|
||||||
extraTTYs = [] ++ (lib.optional manualEnabled 7) ++
|
extraTTYs = []
|
||||||
(lib.optional rogueEnabled 8);
|
++ (lib.optional manualEnabled 7)
|
||||||
|
++ (lib.optional rogueEnabled 8);
|
||||||
inherit kernel;
|
inherit kernel;
|
||||||
initrd = {
|
initrd = {
|
||||||
extraKernelModules = extraInitrdKernelModules
|
extraKernelModules = extraInitrdKernelModules
|
||||||
@ -125,56 +127,61 @@ rec {
|
|||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|
||||||
sshd = {
|
sshd = { enable = sshdEnabled; };
|
||||||
enable = sshdEnabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
xserver = {
|
xserver = { enable = false; };
|
||||||
enable = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
extraJobs = [
|
extraJobs = [
|
||||||
# Unpack the NixOS/Nixpkgs sources to /etc/nixos.
|
# Unpack the NixOS/Nixpkgs sources to /etc/nixos.
|
||||||
{ name = "unpack-sources";
|
{
|
||||||
job = "
|
name = "unpack-sources";
|
||||||
|
job = ''
|
||||||
start on startup
|
start on startup
|
||||||
script
|
script
|
||||||
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
|
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
|
||||||
|
|
||||||
|
${system.nix}/bin/nix-store --load-db < /nix-path-registration
|
||||||
|
|
||||||
mkdir -p /etc/nixos/nixos
|
mkdir -p /etc/nixos/nixos
|
||||||
tar xjf /nixos.tar.bz2 -C /etc/nixos/nixos
|
tar xjf /install/nixos.tar.bz2 -C /etc/nixos/nixos
|
||||||
tar xjf /nixpkgs.tar.bz2 -C /etc/nixos
|
tar xjf /install/nixpkgs.tar.bz2 -C /etc/nixos
|
||||||
mv /etc/nixos/nixpkgs-* /etc/nixos/nixpkgs || true
|
mv /etc/nixos/nixpkgs-* /etc/nixos/nixpkgs || true
|
||||||
ln -sfn ../nixpkgs/pkgs /etc/nixos/nixos/pkgs
|
ln -sfn ../nixpkgs/pkgs /etc/nixos/nixos/pkgs
|
||||||
chown -R root.root /etc/nixos
|
chown -R root.root /etc/nixos
|
||||||
touch /etc/resolv.conf
|
touch /etc/resolv.conf
|
||||||
end script
|
end script
|
||||||
";
|
'';
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
++
|
++
|
||||||
|
|
||||||
(lib.optional manualEnabled
|
(lib.optional manualEnabled
|
||||||
# Show the NixOS manual on tty7.
|
# Show the NixOS manual on tty7.
|
||||||
{ name = "manual";
|
{
|
||||||
job = "
|
name = "manual";
|
||||||
|
job = ''
|
||||||
start on udev
|
start on udev
|
||||||
stop on shutdown
|
stop on shutdown
|
||||||
respawn ${pkgs.w3m}/bin/w3m ${manual} < /dev/tty7 > /dev/tty7 2>&1
|
respawn ${pkgs.w3m}/bin/w3m ${manual} < /dev/tty7 > /dev/tty7 2>&1
|
||||||
";
|
'';
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
++
|
++
|
||||||
|
|
||||||
(lib.optional rogueEnabled
|
(lib.optional rogueEnabled
|
||||||
# Allow the user to do something useful on tty8 while waiting
|
# Allow the user to do something useful on tty8 while waiting
|
||||||
# for the installation to finish.
|
# for the installation to finish.
|
||||||
{ name = "rogue";
|
{
|
||||||
job = "
|
name = "rogue";
|
||||||
|
job = ''
|
||||||
start on udev
|
start on udev
|
||||||
stop on shutdown
|
stop on shutdown
|
||||||
respawn ${pkgs.rogue}/bin/rogue < /dev/tty8 > /dev/tty8 2>&1
|
respawn ${pkgs.rogue}/bin/rogue < /dev/tty8 > /dev/tty8 2>&1
|
||||||
";
|
'';
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
++
|
++
|
||||||
|
|
||||||
@ -190,7 +197,8 @@ rec {
|
|||||||
done
|
done
|
||||||
end script
|
end script
|
||||||
'';
|
'';
|
||||||
})
|
}
|
||||||
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
# And a background to go with that.
|
# And a background to go with that.
|
||||||
@ -198,40 +206,43 @@ rec {
|
|||||||
specificThemes = []
|
specificThemes = []
|
||||||
++
|
++
|
||||||
(lib.optional manualEnabled
|
(lib.optional manualEnabled
|
||||||
{ tty = 7;
|
{
|
||||||
|
tty = 7;
|
||||||
# Theme is GPL according to http://kde-look.org/content/show.php/Green?content=58501.
|
# Theme is GPL according to http://kde-look.org/content/show.php/Green?content=58501.
|
||||||
theme = pkgs.fetchurl {
|
theme = pkgs.fetchurl {
|
||||||
url = http://www.kde-look.org/CONTENT/content-files/58501-green.tar.gz;
|
url = http://www.kde-look.org/CONTENT/content-files/58501-green.tar.gz;
|
||||||
sha256 = "0sdykpziij1f3w4braq8r8nqg4lnsd7i7gi1k5d7c31m2q3b9a7r";
|
sha256 = "0sdykpziij1f3w4braq8r8nqg4lnsd7i7gi1k5d7c31m2q3b9a7r";
|
||||||
};
|
};
|
||||||
})
|
}
|
||||||
|
)
|
||||||
++
|
++
|
||||||
(lib.optional rogueEnabled
|
(lib.optional rogueEnabled
|
||||||
{ tty = 8;
|
{
|
||||||
|
tty = 8;
|
||||||
theme = pkgs.fetchurl {
|
theme = pkgs.fetchurl {
|
||||||
url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2;
|
url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2;
|
||||||
md5 = "61969309d23c631e57b0a311102ef034";
|
md5 = "61969309d23c631e57b0a311102ef034";
|
||||||
};
|
};
|
||||||
})
|
}
|
||||||
|
)
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
mingetty = {
|
mingetty = {
|
||||||
helpLine = ''
|
helpLine = ''
|
||||||
|
|
||||||
Log in as "root" with an empty password.
|
Log in as "root" with an empty password.
|
||||||
''
|
''
|
||||||
+(if addUsers != [] then '' These users also have empty passwords:
|
+(if addUsers != [] then
|
||||||
|
'' These users also have empty passwords:
|
||||||
${lib.concatStringsSep " " addUsers }
|
${lib.concatStringsSep " " addUsers }
|
||||||
'' else "")
|
''
|
||||||
|
else "")
|
||||||
+(if manualEnabled then " Press <Alt-F7> for help." else "");
|
+(if manualEnabled then " Press <Alt-F7> for help." else "");
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fonts = {
|
fonts = { enableFontConfig = fontConfigEnabled; };
|
||||||
enableFontConfig = fontConfigEnabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
installer = {
|
installer = {
|
||||||
nixpkgsURL =
|
nixpkgsURL =
|
||||||
@ -240,9 +251,7 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
security = {
|
security = {
|
||||||
sudo = {
|
sudo = { enable = sudoEnable; };
|
||||||
enable = sudoEnable;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
@ -273,37 +282,36 @@ rec {
|
|||||||
|
|
||||||
# The NixOS manual, with a backward compatibility hack for Nix <=
|
# The NixOS manual, with a backward compatibility hack for Nix <=
|
||||||
# 0.11 (you won't get the manual).
|
# 0.11 (you won't get the manual).
|
||||||
manual =
|
manual = if builtins ? unsafeDiscardStringContext
|
||||||
if builtins ? unsafeDiscardStringContext
|
|
||||||
then "${import ../doc/manual}/manual.html"
|
then "${import ../doc/manual}/manual.html"
|
||||||
else pkgs.writeText "dummy-manual" "Manual not included in this build!";
|
else pkgs.writeText "dummy-manual" "Manual not included in this build!";
|
||||||
|
|
||||||
|
|
||||||
# Since the CD is read-only, the mount points must be on disk.
|
# Since the CD is read-only, the mount points must be on disk.
|
||||||
cdMountPoints = pkgs.runCommand "mount-points" {} "
|
cdMountPoints = pkgs.runCommand "mount-points" {} ''
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
cd $out
|
cd $out
|
||||||
mkdir proc sys tmp etc dev var mnt nix nix/var root bin ${if addUsers != "" then "home" else ""}
|
mkdir proc sys tmp etc dev var mnt nix nix/var root bin ${if addUsers != "" then "home" else ""}
|
||||||
touch $out/${configuration.boot.rootLabel}
|
touch $out/${configuration.boot.rootLabel}
|
||||||
";
|
'';
|
||||||
|
|
||||||
|
|
||||||
# We need a copy of the Nix expressions for Nixpkgs and NixOS on the
|
# We need a copy of the Nix expressions for Nixpkgs and NixOS on the
|
||||||
# CD. We put them in a tarball because accessing that many small
|
# CD. We put them in a tarball because accessing that many small
|
||||||
# files from a slow device like a CD-ROM takes too long.
|
# files from a slow device like a CD-ROM takes too long.
|
||||||
makeTarball = tarName: input: pkgs.runCommand "tarball" {inherit tarName;} "
|
makeTarball = tarName: input: pkgs.runCommand "tarball" {inherit tarName;} ''
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
(cd ${input} && tar cvfj $out/${tarName} . \\
|
(cd ${input} && tar cvfj $out/${tarName} . \
|
||||||
--exclude '*~' \\
|
--exclude '*~' \
|
||||||
--exclude 'pkgs' --exclude 'result')
|
--exclude 'pkgs' --exclude 'result')
|
||||||
";
|
'';
|
||||||
|
|
||||||
makeNixPkgsTarball = tarName: input: ((pkgs.runCommand "tarball-nixpkgs" {inherit tarName;} "
|
makeNixPkgsTarball = tarName: input: ((pkgs.runCommand "tarball-nixpkgs" {inherit tarName;} ''
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
(cd ${input}/.. && tar cvfj $out/${tarName} nixpkgs \\
|
(cd ${input}/.. && tar cvfj $out/${tarName} nixpkgs \
|
||||||
--exclude '*~' \\
|
--exclude '*~' \
|
||||||
--exclude 'result')
|
--exclude 'result')
|
||||||
")+"/${tarName}");
|
'')+"/${tarName}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -346,37 +354,47 @@ rec {
|
|||||||
isoName = "nixos-${platform}.iso";
|
isoName = "nixos-${platform}.iso";
|
||||||
|
|
||||||
# Single files to be copied to fixed locations on the CD.
|
# Single files to be copied to fixed locations on the CD.
|
||||||
contents = lib.uniqList {inputList =
|
contents = lib.uniqList {
|
||||||
[
|
inputList = [
|
||||||
{ source = "${pkgs.grub}/lib/grub/i386-pc/stage2_eltorito";
|
{
|
||||||
|
source = "${pkgs.grub}/lib/grub/i386-pc/stage2_eltorito";
|
||||||
target = "boot/grub/stage2_eltorito";
|
target = "boot/grub/stage2_eltorito";
|
||||||
}
|
}
|
||||||
{ source = grubCfg;
|
{
|
||||||
|
source = grubCfg;
|
||||||
target = "boot/grub/menu.lst";
|
target = "boot/grub/menu.lst";
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
++
|
++
|
||||||
(lib.concatLists (map systemPackInstallRootList systemPacks))
|
(lib.concatLists (map systemPackInstallRootList systemPacks))
|
||||||
++
|
++
|
||||||
[{ source = system.config.boot.grubSplashImage;
|
[
|
||||||
|
{
|
||||||
|
source = system.config.boot.grubSplashImage;
|
||||||
target = "boot/background.xpm.gz";
|
target = "boot/background.xpm.gz";
|
||||||
}
|
}
|
||||||
{ source = cdMountPoints;
|
{
|
||||||
|
source = cdMountPoints;
|
||||||
target = "/";
|
target = "/";
|
||||||
}
|
}
|
||||||
{ source = nixosTarball + "/" + nixosTarball.tarName;
|
{
|
||||||
target = "/" + nixosTarball.tarName;
|
source = nixosTarball + "/" + nixosTarball.tarName;
|
||||||
|
target = "/install/" + nixosTarball.tarName;
|
||||||
}
|
}
|
||||||
{ source = nixpkgsTarball;
|
{
|
||||||
target = "/nixpkgs.tar.bz2";
|
source = nixpkgsTarball;
|
||||||
|
target = "/install/nixpkgs.tar.bz2";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
++
|
++
|
||||||
(lib.optional includeMemtest
|
(lib.optional includeMemtest
|
||||||
{ source = pkgs.memtest86 + "/memtest.bin";
|
{
|
||||||
|
source = pkgs.memtest86 + "/memtest.bin";
|
||||||
target = "boot/memtest.bin";
|
target = "boot/memtest.bin";
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
;};
|
;
|
||||||
|
};
|
||||||
|
|
||||||
# Closures to be copied to the Nix store on the CD.
|
# Closures to be copied to the Nix store on the CD.
|
||||||
storeContents = lib.uniqListExt {
|
storeContents = lib.uniqListExt {
|
||||||
@ -386,12 +404,15 @@ rec {
|
|||||||
compare = lib.eqStrings;
|
compare = lib.eqStrings;
|
||||||
};
|
};
|
||||||
|
|
||||||
buildStoreContents = lib.uniqList {inputList=([]
|
buildStoreContents = lib.uniqList
|
||||||
|
{
|
||||||
|
inputList=([]
|
||||||
++
|
++
|
||||||
(if includeBuildDeps then lib.concatLists
|
(if includeBuildDeps then lib.concatLists
|
||||||
(map systemPackInstallBuildClosure systemPacks)
|
(map systemPackInstallBuildClosure systemPacks)
|
||||||
else [])
|
else [])
|
||||||
);};
|
);
|
||||||
|
};
|
||||||
|
|
||||||
bootable = true;
|
bootable = true;
|
||||||
bootImage = "boot/grub/stage2_eltorito";
|
bootImage = "boot/grub/stage2_eltorito";
|
||||||
|
Loading…
Reference in New Issue
Block a user