mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
* 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
|
||||
|
||||
# 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
|
||||
# files from a slow device like a CD-ROM takes too long. !!! Once
|
||||
# we use squashfs, maybe we won't need this anymore.
|
||||
makeTarball = tarName: input: pkgs.runCommand "tarball" {inherit tarName;}
|
||||
# CD. These are installed into the "nixos" channel of the root
|
||||
# user, as expected by nixos-rebuild/nixos-install.
|
||||
channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}"
|
||||
{ expr = builtins.readFile ../../../lib/channel-expr.nix; }
|
||||
''
|
||||
ensureDir $out
|
||||
(cd ${input} && tar cvfj $out/${tarName} . \
|
||||
--exclude '*~' --exclude 'result')
|
||||
mkdir -p $out/nixos
|
||||
cp -prd ${cleanSource ../../..} $out/nixos/nixos
|
||||
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;
|
||||
|
||||
in
|
||||
@ -48,19 +46,14 @@ in
|
||||
|
||||
boot.postBootCommands =
|
||||
''
|
||||
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
|
||||
|
||||
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
|
||||
# for nixos-install.
|
||||
${optionalString includeSources ''
|
||||
echo "unpacking the NixOS/Nixpkgs sources..."
|
||||
mkdir -p /etc/nixos/nixos
|
||||
tar xjf ${nixosTarball}/nixos.tar.bz2 -C /etc/nixos/nixos
|
||||
mkdir -p /etc/nixos/nixpkgs
|
||||
tar xjf ${nixpkgsTarball}/nixpkgs.tar.bz2 -C /etc/nixos/nixpkgs
|
||||
chown -R root.root /etc/nixos
|
||||
echo -n ${config.system.nixosVersion} > /etc/nixos/nixos/.version
|
||||
echo -n "" > /etc/nixos/nixos/.version-suffix
|
||||
mkdir -p /nix/var/nix/profiles/per-user/root
|
||||
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels -i ${channelSources} --quiet
|
||||
mkdir -m 0700 -p /root/.nix-defexpr
|
||||
ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
|
||||
''}
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
|
||||
@ -141,45 +141,32 @@ for i in /nix/var/nix/manifests/*.nixmanifest; do
|
||||
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
|
||||
# it into the system configuration profile.
|
||||
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 \
|
||||
-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
|
||||
# mount anymore. In fact, below we want to modify the target's /etc.
|
||||
umount $mountPoint/etc/nixos
|
||||
umount $mountPoint/etc
|
||||
|
||||
|
||||
# Make a backup of the old NixOS/Nixpkgs sources.
|
||||
echo "copying NixOS/Nixpkgs sources to /etc/nixos...."
|
||||
|
||||
backupTimestamp=$(date "+%Y%m%d%H%M%S")
|
||||
|
||||
targetNixos=$mountPoint/etc/nixos/nixos
|
||||
if test -e $targetNixos; then
|
||||
mv $targetNixos $targetNixos.backup-$backupTimestamp
|
||||
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
|
||||
# Copy the NixOS/Nixpkgs sources to the target as the initial contents
|
||||
# of the NixOS channel.
|
||||
echo "copying NixOS/Nixpkgs sources..."
|
||||
mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root
|
||||
chroot $mountPoint @nix@/bin/nix-env \
|
||||
-p /nix/var/nix/profiles/per-user/root/channels -i "$srcs" --quiet
|
||||
mkdir -m 0700 -p $mountPoint/root/.nix-defexpr
|
||||
ln -s /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels
|
||||
|
||||
|
||||
# Grub needs an mtab.
|
||||
|
@ -29,7 +29,7 @@ let
|
||||
relocatedModuleFiles =
|
||||
let
|
||||
relocateNixOS = path:
|
||||
"/etc/nixos/nixos" + removePrefix nixosPath (toString path);
|
||||
"<nixos" + removePrefix nixosPath (toString path) + ">";
|
||||
relocateOthers = null;
|
||||
in
|
||||
{ nixos = map relocateNixOS partitionedModuleFiles.nixos;
|
||||
@ -44,16 +44,12 @@ let
|
||||
# evaluated. So we'll just hope for the best.
|
||||
configClone = pkgs.writeText "configuration.nix"
|
||||
''
|
||||
{config, pkgs, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
require = [
|
||||
${toString config.installer.cloneConfigIncludes}
|
||||
];
|
||||
|
||||
# Add your own options below and run "nixos-rebuild switch".
|
||||
# E.g.,
|
||||
# services.openssh.enable = true;
|
||||
}
|
||||
'';
|
||||
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 = {
|
||||
@ -148,5 +132,13 @@ in
|
||||
# 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.shellInit =
|
||||
''
|
||||
export GC_INITIAL_HEAP_SIZE=100000
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
@ -28,11 +28,10 @@ in
|
||||
|
||||
environment.nix = mkOption {
|
||||
default = pkgs.nixUnstable;
|
||||
example = pkgs.nixCustomFun /root/nix.tar.gz;
|
||||
merge = mergeOneOption;
|
||||
description = "
|
||||
description = ''
|
||||
This option specifies the Nix package instance to use throughout the system.
|
||||
";
|
||||
'';
|
||||
};
|
||||
|
||||
nix = {
|
||||
|
@ -114,11 +114,7 @@ let
|
||||
|
||||
buildInputs = [ nixUnstable ];
|
||||
|
||||
expr =
|
||||
''
|
||||
{ system ? builtins.currentSystem }:
|
||||
{ pkgs = (import nixpkgs/default.nix { inherit system; }) // { recurseForDerivations = true; }; }
|
||||
'';
|
||||
expr = builtins.readFile lib/channel-expr.nix;
|
||||
|
||||
distPhase = ''
|
||||
echo -n $VERSION_SUFFIX > .version-suffix
|
||||
@ -128,7 +124,6 @@ let
|
||||
cp -prd . ../$releaseName/nixos
|
||||
cp -prd ${nixpkgs} ../$releaseName/nixpkgs
|
||||
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
|
||||
cd ..
|
||||
chmod -R u+w $releaseName
|
||||
|
@ -131,7 +131,7 @@ let
|
||||
|
||||
# Test nix-env.
|
||||
$machine->mustFail("hello");
|
||||
$machine->mustSucceed("nix-env -f /etc/nixos/nixpkgs -i hello");
|
||||
$machine->mustSucceed("nix-env -i hello");
|
||||
$machine->mustSucceed("hello") =~ /Hello, world/
|
||||
or die "bad `hello' output";
|
||||
''}
|
||||
@ -175,7 +175,7 @@ let
|
||||
# !!! Idem.
|
||||
$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/
|
||||
or die "nix-env failed";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user