* In the installation CD, make the NixOS/Nixpkgs available as if they
were obtained from the NixOS channel. "nixos-install" copies this to the installed system as well. * In the installation CD, set GC_INITIAL_HEAP_SIZE to a low value for the benefit of memory-constrained environments. svn path=/nixos/trunk/; revision=33887
This commit is contained in:
parent
72990dae37
commit
6c1bb54483
6
lib/channel-expr.nix
Normal file
6
lib/channel-expr.nix
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{ system ? builtins.currentSystem }:
|
||||||
|
|
||||||
|
{ pkgs =
|
||||||
|
(import nixpkgs/default.nix { inherit system; })
|
||||||
|
// { recurseForDerivations = true; };
|
||||||
|
}
|
@ -8,22 +8,20 @@ with pkgs.lib;
|
|||||||
let
|
let
|
||||||
|
|
||||||
# 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. These are installed into the "nixos" channel of the root
|
||||||
# files from a slow device like a CD-ROM takes too long. !!! Once
|
# user, as expected by nixos-rebuild/nixos-install.
|
||||||
# we use squashfs, maybe we won't need this anymore.
|
channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}"
|
||||||
makeTarball = tarName: input: pkgs.runCommand "tarball" {inherit tarName;}
|
{ expr = builtins.readFile ../../../lib/channel-expr.nix; }
|
||||||
''
|
''
|
||||||
ensureDir $out
|
mkdir -p $out/nixos
|
||||||
(cd ${input} && tar cvfj $out/${tarName} . \
|
cp -prd ${cleanSource ../../..} $out/nixos/nixos
|
||||||
--exclude '*~' --exclude 'result')
|
cp -prd ${cleanSource <nixpkgs>} $out/nixos/nixpkgs
|
||||||
|
chmod -R u+w $out/nixos/nixos
|
||||||
|
echo -n ${config.system.nixosVersion} > $out/nixos/nixos/.version
|
||||||
|
echo -n "" > $out/nixos/nixos/.version-suffix
|
||||||
|
echo "$expr" > $out/nixos/default.nix
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Put the current directory in a tarball.
|
|
||||||
nixosTarball = makeTarball "nixos.tar.bz2" (cleanSource ../../..);
|
|
||||||
|
|
||||||
# Put Nixpkgs in a tarball.
|
|
||||||
nixpkgsTarball = makeTarball "nixpkgs.tar.bz2" (cleanSource <nixpkgs>);
|
|
||||||
|
|
||||||
includeSources = true;
|
includeSources = true;
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -48,19 +46,14 @@ in
|
|||||||
|
|
||||||
boot.postBootCommands =
|
boot.postBootCommands =
|
||||||
''
|
''
|
||||||
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
|
|
||||||
|
|
||||||
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
|
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
|
||||||
# for nixos-install.
|
# for nixos-install.
|
||||||
${optionalString includeSources ''
|
${optionalString includeSources ''
|
||||||
echo "unpacking the NixOS/Nixpkgs sources..."
|
echo "unpacking the NixOS/Nixpkgs sources..."
|
||||||
mkdir -p /etc/nixos/nixos
|
mkdir -p /nix/var/nix/profiles/per-user/root
|
||||||
tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos
|
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels -i ${channelSources} --quiet
|
||||||
mkdir -p /etc/nixos/nixpkgs
|
mkdir -m 0700 -p /root/.nix-defexpr
|
||||||
tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs
|
ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
|
||||||
chown -R root.root /etc/nixos
|
|
||||||
echo -n ${config.system.nixosVersion} > /etc/nixos/nixos/.version
|
|
||||||
echo -n "" > /etc/nixos/nixos/.version-suffix
|
|
||||||
''}
|
''}
|
||||||
|
|
||||||
# Make the installer more likely to succeed in low memory
|
# Make the installer more likely to succeed in low memory
|
||||||
|
@ -103,7 +103,7 @@ export LC_TIME=
|
|||||||
|
|
||||||
# Create a temporary Nix config file that causes the nixbld users to
|
# Create a temporary Nix config file that causes the nixbld users to
|
||||||
# be used.
|
# be used.
|
||||||
echo "build-users-group = nixbld" > /mnt/tmp/nix.conf
|
echo "build-users-group = nixbld" > $mountPoint/tmp/nix.conf
|
||||||
export NIX_CONF_DIR=/tmp
|
export NIX_CONF_DIR=/tmp
|
||||||
|
|
||||||
|
|
||||||
@ -141,45 +141,32 @@ for i in /nix/var/nix/manifests/*.nixmanifest; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Get the absolute path to the NixOS/Nixpkgs sources.
|
||||||
|
srcs=$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path)
|
||||||
|
|
||||||
|
|
||||||
# Build the specified Nix expression in the target store and install
|
# Build the specified Nix expression in the target store and install
|
||||||
# it into the system configuration profile.
|
# it into the system configuration profile.
|
||||||
echo "building the system configuration..."
|
echo "building the system configuration..."
|
||||||
NIX_PATH=nixpkgs=/mnt/etc/nixos/nixpkgs:nixos=/mnt/etc/nixos/nixos:nixos-config="/mnt$NIXOS_CONFIG" NIXOS_CONFIG= \
|
NIX_PATH="/mnt$srcs/nixos:nixos-config=/mnt$NIXOS_CONFIG" NIXOS_CONFIG= \
|
||||||
chroot $mountPoint @nix@/bin/nix-env \
|
chroot $mountPoint @nix@/bin/nix-env \
|
||||||
-p /nix/var/nix/profiles/system -f '<nixos>' --set -A system --show-trace
|
-p /nix/var/nix/profiles/system -f '<nixos>' --set -A system --show-trace
|
||||||
|
|
||||||
|
|
||||||
# Get rid of the manifests.
|
|
||||||
rm -f $mountPoint/nix/var/nix/manifests/*
|
|
||||||
|
|
||||||
|
|
||||||
# We're done building/downloading, so we don't need the /etc bind
|
# We're done building/downloading, so we don't need the /etc bind
|
||||||
# mount anymore. In fact, below we want to modify the target's /etc.
|
# mount anymore. In fact, below we want to modify the target's /etc.
|
||||||
umount $mountPoint/etc/nixos
|
umount $mountPoint/etc/nixos
|
||||||
umount $mountPoint/etc
|
umount $mountPoint/etc
|
||||||
|
|
||||||
|
|
||||||
# Make a backup of the old NixOS/Nixpkgs sources.
|
# Copy the NixOS/Nixpkgs sources to the target as the initial contents
|
||||||
echo "copying NixOS/Nixpkgs sources to /etc/nixos...."
|
# of the NixOS channel.
|
||||||
|
echo "copying NixOS/Nixpkgs sources..."
|
||||||
backupTimestamp=$(date "+%Y%m%d%H%M%S")
|
mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root
|
||||||
|
chroot $mountPoint @nix@/bin/nix-env \
|
||||||
targetNixos=$mountPoint/etc/nixos/nixos
|
-p /nix/var/nix/profiles/per-user/root/channels -i "$srcs" --quiet
|
||||||
if test -e $targetNixos; then
|
mkdir -m 0700 -p $mountPoint/root/.nix-defexpr
|
||||||
mv $targetNixos $targetNixos.backup-$backupTimestamp
|
ln -s /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels
|
||||||
fi
|
|
||||||
|
|
||||||
targetNixpkgs=$mountPoint/etc/nixos/nixpkgs
|
|
||||||
if test -e $targetNixpkgs; then
|
|
||||||
mv $targetNixpkgs $targetNixpkgs.backup-$backupTimestamp
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Copy the NixOS/Nixpkgs sources to the target.
|
|
||||||
cp -prd /etc/nixos/nixos $targetNixos
|
|
||||||
if [ -e /etc/nixos/nixpkgs ]; then
|
|
||||||
cp -prd /etc/nixos/nixpkgs $targetNixpkgs
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Grub needs an mtab.
|
# Grub needs an mtab.
|
||||||
|
@ -29,7 +29,7 @@ let
|
|||||||
relocatedModuleFiles =
|
relocatedModuleFiles =
|
||||||
let
|
let
|
||||||
relocateNixOS = path:
|
relocateNixOS = path:
|
||||||
"/etc/nixos/nixos" + removePrefix nixosPath (toString path);
|
"<nixos" + removePrefix nixosPath (toString path) + ">";
|
||||||
relocateOthers = null;
|
relocateOthers = null;
|
||||||
in
|
in
|
||||||
{ nixos = map relocateNixOS partitionedModuleFiles.nixos;
|
{ nixos = map relocateNixOS partitionedModuleFiles.nixos;
|
||||||
@ -44,16 +44,12 @@ let
|
|||||||
# evaluated. So we'll just hope for the best.
|
# evaluated. So we'll just hope for the best.
|
||||||
configClone = pkgs.writeText "configuration.nix"
|
configClone = pkgs.writeText "configuration.nix"
|
||||||
''
|
''
|
||||||
{config, pkgs, ...}:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
require = [
|
require = [
|
||||||
${toString config.installer.cloneConfigIncludes}
|
${toString config.installer.cloneConfigIncludes}
|
||||||
];
|
];
|
||||||
|
|
||||||
# Add your own options below and run "nixos-rebuild switch".
|
|
||||||
# E.g.,
|
|
||||||
# services.openssh.enable = true;
|
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
@ -84,18 +80,6 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ignored. Kept for Backward compatibiliy.
|
|
||||||
# you can retrieve the profiles which have been used by looking at the
|
|
||||||
# list of modules use to configure the installation device.
|
|
||||||
installer.configModule = mkOption {
|
|
||||||
example = "./nixos/modules/installer/cd-dvd/installation-cd.nix";
|
|
||||||
description = ''
|
|
||||||
Filename of the configuration module that builds the CD
|
|
||||||
configuration. Must be specified to support reconfiguration
|
|
||||||
in live CDs.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
@ -148,5 +132,13 @@ in
|
|||||||
# Enable wpa_supplicant, but don't start it by default.
|
# Enable wpa_supplicant, but don't start it by default.
|
||||||
networking.wireless.enable = true;
|
networking.wireless.enable = true;
|
||||||
jobs.wpa_supplicant.startOn = pkgs.lib.mkOverride 50 "";
|
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.shellInit =
|
||||||
|
''
|
||||||
|
export GC_INITIAL_HEAP_SIZE=100000
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,10 @@ in
|
|||||||
|
|
||||||
environment.nix = mkOption {
|
environment.nix = mkOption {
|
||||||
default = pkgs.nixUnstable;
|
default = pkgs.nixUnstable;
|
||||||
example = pkgs.nixCustomFun /root/nix.tar.gz;
|
|
||||||
merge = mergeOneOption;
|
merge = mergeOneOption;
|
||||||
description = "
|
description = ''
|
||||||
This option specifies the Nix package instance to use throughout the system.
|
This option specifies the Nix package instance to use throughout the system.
|
||||||
";
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
|
@ -114,11 +114,7 @@ let
|
|||||||
|
|
||||||
buildInputs = [ nixUnstable ];
|
buildInputs = [ nixUnstable ];
|
||||||
|
|
||||||
expr =
|
expr = builtins.readFile lib/channel-expr.nix;
|
||||||
''
|
|
||||||
{ system ? builtins.currentSystem }:
|
|
||||||
{ pkgs = (import nixpkgs/default.nix { inherit system; }) // { recurseForDerivations = true; }; }
|
|
||||||
'';
|
|
||||||
|
|
||||||
distPhase = ''
|
distPhase = ''
|
||||||
echo -n $VERSION_SUFFIX > .version-suffix
|
echo -n $VERSION_SUFFIX > .version-suffix
|
||||||
@ -128,7 +124,6 @@ let
|
|||||||
cp -prd . ../$releaseName/nixos
|
cp -prd . ../$releaseName/nixos
|
||||||
cp -prd ${nixpkgs} ../$releaseName/nixpkgs
|
cp -prd ${nixpkgs} ../$releaseName/nixpkgs
|
||||||
echo "$expr" > ../$releaseName/default.nix
|
echo "$expr" > ../$releaseName/default.nix
|
||||||
echo nixos > ../$releaseName/channel-name
|
|
||||||
NIX_STATE_DIR=$TMPDIR nix-env -f ../$releaseName/default.nix -qaP --meta --xml \* > /dev/null
|
NIX_STATE_DIR=$TMPDIR nix-env -f ../$releaseName/default.nix -qaP --meta --xml \* > /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
chmod -R u+w $releaseName
|
chmod -R u+w $releaseName
|
||||||
|
@ -131,7 +131,7 @@ let
|
|||||||
|
|
||||||
# Test nix-env.
|
# Test nix-env.
|
||||||
$machine->mustFail("hello");
|
$machine->mustFail("hello");
|
||||||
$machine->mustSucceed("nix-env -f /etc/nixos/nixpkgs -i hello");
|
$machine->mustSucceed("nix-env -i hello");
|
||||||
$machine->mustSucceed("hello") =~ /Hello, world/
|
$machine->mustSucceed("hello") =~ /Hello, world/
|
||||||
or die "bad `hello' output";
|
or die "bad `hello' output";
|
||||||
''}
|
''}
|
||||||
@ -175,7 +175,7 @@ let
|
|||||||
# !!! Idem.
|
# !!! Idem.
|
||||||
$machine->waitUntilSucceeds("cat /proc/swaps | grep -q /dev");
|
$machine->waitUntilSucceeds("cat /proc/swaps | grep -q /dev");
|
||||||
|
|
||||||
$machine->mustSucceed("nix-env -f /etc/nixos/nixpkgs -i coreutils >&2");
|
$machine->mustSucceed("nix-env -i coreutils >&2");
|
||||||
$machine->mustSucceed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
|
$machine->mustSucceed("type -tP ls | tee /dev/stderr") =~ /.nix-profile/
|
||||||
or die "nix-env failed";
|
or die "nix-env failed";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user