2010-02-15 23:27:51 +00:00
|
|
|
# This module creates a bootable ISO image containing the given NixOS
|
|
|
|
# configuration. The derivation for the ISO image will be placed in
|
|
|
|
# config.system.build.tarball.
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-02-15 23:27:51 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-02-15 23:27:51 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2017-04-01 01:00:00 +01:00
|
|
|
versionFile = pkgs.writeText "nixos-label" config.system.nixosLabel;
|
2013-09-04 12:05:09 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2010-02-15 23:27:51 +00:00
|
|
|
options = {
|
|
|
|
tarball.contents = mkOption {
|
2014-08-27 22:41:15 +01:00
|
|
|
example = literalExample ''
|
2010-02-15 23:27:51 +00:00
|
|
|
[ { source = pkgs.memtest86 + "/memtest.bin";
|
|
|
|
target = "boot/memtest.bin";
|
|
|
|
}
|
2014-08-27 22:41:15 +01:00
|
|
|
]
|
|
|
|
'';
|
2010-02-15 23:27:51 +00:00
|
|
|
description = ''
|
|
|
|
This option lists files to be copied to fixed locations in the
|
|
|
|
generated ISO image.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tarball.storeContents = mkOption {
|
2014-08-27 22:41:15 +01:00
|
|
|
example = literalExample "[ pkgs.stdenv ]";
|
2010-02-15 23:27:51 +00:00
|
|
|
description = ''
|
|
|
|
This option lists additional derivations to be included in the
|
|
|
|
Nix store in the generated ISO image.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-09-04 12:05:09 +01:00
|
|
|
config = {
|
2010-02-15 23:27:51 +00:00
|
|
|
|
2013-09-04 12:05:09 +01:00
|
|
|
# In stage 1 of the boot, mount the CD/DVD as the root FS by label
|
|
|
|
# so that we don't need to know its device.
|
|
|
|
fileSystems = [ ];
|
|
|
|
|
2015-10-16 12:20:30 +01:00
|
|
|
# boot.initrd.availableKernelModules = [ "mvsdio" "reiserfs" "ext3" "ext4" ];
|
2013-09-04 12:05:09 +01:00
|
|
|
|
|
|
|
# boot.initrd.kernelModules = [ "rtc_mv" ];
|
|
|
|
|
|
|
|
# Closures to be copied to the Nix store on the CD, namely the init
|
|
|
|
# script and the top-level system configuration directory.
|
|
|
|
tarball.storeContents =
|
|
|
|
[ { object = config.system.build.toplevel;
|
|
|
|
symlink = "/run/current-system";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# Individual files to be included on the CD, outside of the Nix
|
|
|
|
# store on the CD.
|
|
|
|
tarball.contents =
|
2015-11-15 00:00:00 +00:00
|
|
|
[ { source = config.system.build.initialRamdisk + "/" + config.system.boot.loader.initrdFile;
|
|
|
|
target = "/boot/" + config.system.boot.loader.initrdFile;
|
2013-09-04 12:05:09 +01:00
|
|
|
}
|
|
|
|
{ source = versionFile;
|
|
|
|
target = "/nixos-version.txt";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# Create the tarball
|
|
|
|
system.build.tarball = import ../../../lib/make-system-tarball.nix {
|
|
|
|
inherit (pkgs) stdenv perl xz pathsFromGraph;
|
|
|
|
|
|
|
|
inherit (config.tarball) contents storeContents;
|
|
|
|
};
|
|
|
|
|
|
|
|
boot.postBootCommands =
|
|
|
|
''
|
|
|
|
# After booting, register the contents of the Nix store on the
|
|
|
|
# CD in the Nix database in the tmpfs.
|
|
|
|
if [ -f /nix-path-registration ]; then
|
2016-04-24 11:57:19 +01:00
|
|
|
${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration &&
|
2013-09-04 12:05:09 +01:00
|
|
|
rm /nix-path-registration
|
|
|
|
fi
|
|
|
|
|
|
|
|
# nixos-rebuild also requires a "system" profile and an
|
|
|
|
# /etc/NIXOS tag.
|
|
|
|
touch /etc/NIXOS
|
2016-04-24 11:57:19 +01:00
|
|
|
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
|
2013-09-04 12:05:09 +01:00
|
|
|
'';
|
2010-02-15 23:27:51 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|