Merge pull request #34795 from oxij/os/nixosLabel-pt2

nixos: labels part 2
This commit is contained in:
Michael Raskin 2018-02-19 14:45:17 +00:00 committed by GitHub
commit 1e23a5a6e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 198 additions and 115 deletions

View File

@ -84,7 +84,7 @@ let format' = format; in let
nixpkgs = cleanSource pkgs.path; nixpkgs = cleanSource pkgs.path;
channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}" {} '' channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}" {} ''
mkdir -p $out mkdir -p $out
cp -prd ${nixpkgs} $out/nixos cp -prd ${nixpkgs} $out/nixos
chmod -R u+w $out/nixos chmod -R u+w $out/nixos
@ -92,7 +92,7 @@ let format' = format; in let
ln -s . $out/nixos/nixpkgs ln -s . $out/nixos/nixpkgs
fi fi
rm -rf $out/nixos/.git rm -rf $out/nixos/.git
echo -n ${config.system.nixosVersionSuffix} > $out/nixos/.version-suffix echo -n ${config.system.nixos.versionSuffix} > $out/nixos/.version-suffix
''; '';
metaClosure = pkgs.writeText "meta" '' metaClosure = pkgs.writeText "meta" ''

View File

@ -12,7 +12,7 @@ let
# CD. These are installed into the "nixos" channel of the root # CD. These are installed into the "nixos" channel of the root
# user, as expected by nixos-rebuild/nixos-install. FIXME: merge # user, as expected by nixos-rebuild/nixos-install. FIXME: merge
# with make-channel.nix. # with make-channel.nix.
channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}" channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}"
{ } { }
'' ''
mkdir -p $out mkdir -p $out
@ -21,7 +21,7 @@ let
if [ ! -e $out/nixos/nixpkgs ]; then if [ ! -e $out/nixos/nixpkgs ]; then
ln -s . $out/nixos/nixpkgs ln -s . $out/nixos/nixpkgs
fi fi
echo -n ${config.system.nixosVersionSuffix} > $out/nixos/.version-suffix echo -n ${config.system.nixos.versionSuffix} > $out/nixos/.version-suffix
''; '';
in in

View File

@ -16,7 +16,7 @@ with lib;
]; ];
# ISO naming. # ISO naming.
isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixosLabel}-${pkgs.stdenv.system}.iso"; isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.system}.iso";
isoImage.volumeID = substring 0 11 "NIXOS_ISO"; isoImage.volumeID = substring 0 11 "NIXOS_ISO";

View File

@ -39,31 +39,31 @@ let
DEFAULT boot DEFAULT boot
LABEL boot LABEL boot
MENU LABEL NixOS ${config.system.nixosLabel}${config.isoImage.appendToMenuLabel} MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
LINUX /boot/bzImage LINUX /boot/${config.system.boot.loader.kernelFile}
APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
INITRD /boot/initrd INITRD /boot/${config.system.boot.loader.initrdFile}
# A variant to boot with 'nomodeset' # A variant to boot with 'nomodeset'
LABEL boot-nomodeset LABEL boot-nomodeset
MENU LABEL NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} (nomodeset) MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (nomodeset)
LINUX /boot/bzImage LINUX /boot/${config.system.boot.loader.kernelFile}
APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} nomodeset APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} nomodeset
INITRD /boot/initrd INITRD /boot/${config.system.boot.loader.initrdFile}
# A variant to boot with 'copytoram' # A variant to boot with 'copytoram'
LABEL boot-copytoram LABEL boot-copytoram
MENU LABEL NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} (copytoram) MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (copytoram)
LINUX /boot/bzImage LINUX /boot/${config.system.boot.loader.kernelFile}
APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} copytoram APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} copytoram
INITRD /boot/initrd INITRD /boot/${config.system.boot.loader.initrdFile}
# A variant to boot with verbose logging to the console # A variant to boot with verbose logging to the console
LABEL boot-nomodeset LABEL boot-nomodeset
MENU LABEL NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} (debug) MENU LABEL NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (debug)
LINUX /boot/bzImage LINUX /boot/${config.system.boot.loader.kernelFile}
APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} loglevel=7 APPEND init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} loglevel=7
INITRD /boot/initrd INITRD /boot/${config.system.boot.loader.initrdFile}
''; '';
isolinuxMemtest86Entry = '' isolinuxMemtest86Entry = ''
@ -82,35 +82,35 @@ let
mkdir -p $out/loader/entries mkdir -p $out/loader/entries
cat << EOF > $out/loader/entries/nixos-iso.conf cat << EOF > $out/loader/entries/nixos-iso.conf
title NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} title NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
linux /boot/bzImage linux /boot/${config.system.boot.loader.kernelFile}
initrd /boot/initrd initrd /boot/${config.system.boot.loader.initrdFile}
options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
EOF EOF
# A variant to boot with 'nomodeset' # A variant to boot with 'nomodeset'
cat << EOF > $out/loader/entries/nixos-iso-nomodeset.conf cat << EOF > $out/loader/entries/nixos-iso-nomodeset.conf
title NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} title NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
version nomodeset version nomodeset
linux /boot/bzImage linux /boot/${config.system.boot.loader.kernelFile}
initrd /boot/initrd initrd /boot/${config.system.boot.loader.initrdFile}
options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} nomodeset options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} nomodeset
EOF EOF
# A variant to boot with 'copytoram' # A variant to boot with 'copytoram'
cat << EOF > $out/loader/entries/nixos-iso-copytoram.conf cat << EOF > $out/loader/entries/nixos-iso-copytoram.conf
title NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} title NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}
version copytoram version copytoram
linux /boot/bzImage linux /boot/${config.system.boot.loader.kernelFile}
initrd /boot/initrd initrd /boot/${config.system.boot.loader.initrdFile}
options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} copytoram options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} copytoram
EOF EOF
# A variant to boot with verbose logging to the console # A variant to boot with verbose logging to the console
cat << EOF > $out/loader/entries/nixos-iso-debug.conf cat << EOF > $out/loader/entries/nixos-iso-debug.conf
title NixOS ${config.system.nixosVersion}${config.isoImage.appendToMenuLabel} (debug) title NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel} (debug)
linux /boot/bzImage linux /boot/${config.system.boot.loader.kernelFile}
initrd /boot/initrd initrd /boot/${config.system.boot.loader.initrdFile}
options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} loglevel=7 options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} loglevel=7
EOF EOF
@ -127,8 +127,8 @@ let
mkdir ./contents && cd ./contents mkdir ./contents && cd ./contents
cp -rp "${efiDir}"/* . cp -rp "${efiDir}"/* .
mkdir ./boot mkdir ./boot
cp -p "${config.boot.kernelPackages.kernel}/bzImage" \ cp -p "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}" \
"${config.system.build.initialRamdisk}/initrd" ./boot/ "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}" ./boot/
touch --date=@0 ./* touch --date=@0 ./*
usage_size=$(du -sb --apparent-size . | tr -cd '[:digit:]') usage_size=$(du -sb --apparent-size . | tr -cd '[:digit:]')
@ -346,11 +346,11 @@ in
}; };
target = "/isolinux/isolinux.cfg"; target = "/isolinux/isolinux.cfg";
} }
{ source = config.boot.kernelPackages.kernel + "/bzImage"; { source = config.boot.kernelPackages.kernel + "/" + config.system.boot.loader.kernelFile;
target = "/boot/bzImage"; target = "/boot/" + config.system.boot.loader.kernelFile;
} }
{ source = config.system.build.initialRamdisk + "/initrd"; { source = config.system.build.initialRamdisk + "/" + config.system.boot.loader.initrdFile;
target = "/boot/initrd"; target = "/boot/" + config.system.boot.loader.initrdFile;
} }
{ source = config.system.build.squashfsStore; { source = config.system.build.squashfsStore;
target = "/nix-store.squashfs"; target = "/nix-store.squashfs";
@ -361,7 +361,7 @@ in
{ source = config.isoImage.splashImage; { source = config.isoImage.splashImage;
target = "/isolinux/background.png"; target = "/isolinux/background.png";
} }
{ source = pkgs.writeText "version" config.system.nixosVersion; { source = pkgs.writeText "version" config.system.nixos.label;
target = "/version.txt"; target = "/version.txt";
} }
] ++ optionals config.isoImage.makeEfiBootable [ ] ++ optionals config.isoImage.makeEfiBootable [

View File

@ -8,7 +8,7 @@ with lib;
let let
versionFile = pkgs.writeText "nixos-version" config.system.nixosVersion; versionFile = pkgs.writeText "nixos-label" config.system.nixos.label;
in in
@ -58,8 +58,8 @@ in
# Individual files to be included on the CD, outside of the Nix # Individual files to be included on the CD, outside of the Nix
# store on the CD. # store on the CD.
tarball.contents = tarball.contents =
[ { source = config.system.build.initialRamdisk + "/initrd"; [ { source = config.system.build.initialRamdisk + "/" + config.system.boot.loader.initrdFile;
target = "/boot/initrd"; target = "/boot/" + config.system.boot.loader.initrdFile;
} }
{ source = versionFile; { source = versionFile;
target = "/nixos-version.txt"; target = "/nixos-version.txt";

View File

@ -625,7 +625,7 @@ $bootLoaderConfig
# compatible, in order to avoid breaking some software such as database # compatible, in order to avoid breaking some software such as database
# servers. You should change this only after NixOS release notes say you # servers. You should change this only after NixOS release notes say you
# should. # should.
system.stateVersion = "${\(qw(@nixosRelease@))}"; # Did you read the comment? system.stateVersion = "${\(qw(@release@))}"; # Did you read the comment?
} }
EOF EOF

View File

@ -6,9 +6,9 @@ case "$1" in
exit 1 exit 1
;; ;;
--hash|--revision) --hash|--revision)
echo "@nixosRevision@" echo "@revision@"
;; ;;
*) *)
echo "@nixosVersion@ (@nixosCodeName@)" echo "@version@ (@codeName@)"
;; ;;
esac esac

View File

@ -55,7 +55,7 @@ let
src = ./nixos-generate-config.pl; src = ./nixos-generate-config.pl;
path = [ pkgs.btrfs-progs ]; path = [ pkgs.btrfs-progs ];
perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl"; perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl";
inherit (config.system) nixosRelease; inherit (config.system.nixos) release;
}; };
nixos-option = makeProg { nixos-option = makeProg {
@ -66,7 +66,7 @@ let
nixos-version = makeProg { nixos-version = makeProg {
name = "nixos-version"; name = "nixos-version";
src = ./nixos-version.sh; src = ./nixos-version.sh;
inherit (config.system) nixosVersion nixosCodeName nixosRevision; inherit (config.system.nixos) version codeName revision;
}; };
in in

View File

@ -0,0 +1,72 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.system.nixos;
in
{
options.system = {
nixos.label = mkOption {
type = types.str;
description = ''
NixOS version name to be used in the names of generated
outputs and boot labels.
If you ever wanted to influence the labels in your GRUB menu,
this is the option for you.
The default is <option>system.nixos.tags</option> separated by
"-" + "-" + <envar>NIXOS_LABEL_VERSION</envar> environment
variable (defaults to the value of
<option>system.nixos.version</option>).
Can be overriden by setting <envar>NIXOS_LABEL</envar>.
Useful for not loosing track of configurations built from different
nixos branches/revisions, e.g.:
<screen>
#!/bin/sh
today=`date +%Y%m%d`
branch=`(cd nixpkgs ; git branch 2>/dev/null | sed -n '/^\* / { s|^\* ||; p; }')`
revision=`(cd nixpkgs ; git rev-parse HEAD)`
export NIXOS_LABEL_VERSION="$today.$branch-''${revision:0:7}"
nixos-rebuild switch</screen>
'';
};
nixos.tags = mkOption {
type = types.listOf types.str;
default = [];
example = [ "with-xen" ];
description = ''
Strings to prefix to the default
<option>system.nixos.label</option>.
Useful for not loosing track of configurations built with
different options, e.g.:
<screen>
{
system.nixos.tags = [ "with-xen" ];
virtualisation.xen.enable = true;
}
</screen>
'';
};
};
config = {
# This is set here rather than up there so that changing it would
# not rebuild the manual
system.nixos.label = mkDefault (maybeEnv "NIXOS_LABEL"
(concatStringsSep "-" (sort (x: y: x < y) cfg.tags)
+ "-" + maybeEnv "NIXOS_LABEL_VERSION" cfg.version));
};
}

View File

@ -3,7 +3,7 @@
with lib; with lib;
let let
cfg = config.system; cfg = config.system.nixos;
releaseFile = "${toString pkgs.path}/.version"; releaseFile = "${toString pkgs.path}/.version";
suffixFile = "${toString pkgs.path}/.version-suffix"; suffixFile = "${toString pkgs.path}/.version-suffix";
@ -16,9 +16,44 @@ in
options.system = { options.system = {
nixos.version = mkOption {
internal = true;
type = types.str;
description = "The full NixOS version (e.g. <literal>16.03.1160.f2d4ee1</literal>).";
};
nixos.release = mkOption {
readOnly = true;
type = types.str;
default = fileContents releaseFile;
description = "The NixOS release (e.g. <literal>16.03</literal>).";
};
nixos.versionSuffix = mkOption {
internal = true;
type = types.str;
default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
};
nixos.revision = mkOption {
internal = true;
type = types.str;
default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo
else if pathExists revisionFile then fileContents revisionFile
else "master";
description = "The Git revision from which this NixOS configuration was built.";
};
nixos.codeName = mkOption {
readOnly = true;
type = types.str;
description = "The NixOS release code name (e.g. <literal>Emu</literal>).";
};
stateVersion = mkOption { stateVersion = mkOption {
type = types.str; type = types.str;
default = cfg.nixosRelease; default = cfg.release;
description = '' description = ''
Every once in a while, a new NixOS release may change Every once in a while, a new NixOS release may change
configuration defaults in a way incompatible with stateful configuration defaults in a way incompatible with stateful
@ -32,49 +67,6 @@ in
''; '';
}; };
nixosLabel = mkOption {
type = types.str;
description = ''
Label to be used in the names of generated outputs and boot
labels.
'';
};
nixosVersion = mkOption {
internal = true;
type = types.str;
description = "The full NixOS version (e.g. <literal>16.03.1160.f2d4ee1</literal>).";
};
nixosRelease = mkOption {
readOnly = true;
type = types.str;
default = fileContents releaseFile;
description = "The NixOS release (e.g. <literal>16.03</literal>).";
};
nixosVersionSuffix = mkOption {
internal = true;
type = types.str;
default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
};
nixosRevision = mkOption {
internal = true;
type = types.str;
default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo
else if pathExists revisionFile then fileContents revisionFile
else "master";
description = "The Git revision from which this NixOS configuration was built.";
};
nixosCodeName = mkOption {
readOnly = true;
type = types.str;
description = "The NixOS release code name (e.g. <literal>Emu</literal>).";
};
defaultChannel = mkOption { defaultChannel = mkOption {
internal = true; internal = true;
type = types.str; type = types.str;
@ -86,16 +78,15 @@ in
config = { config = {
system = { system.nixos = {
# These defaults are set here rather than up there so that # These defaults are set here rather than up there so that
# changing them would not rebuild the manual # changing them would not rebuild the manual
nixosLabel = mkDefault cfg.nixosVersion; version = mkDefault (cfg.release + cfg.versionSuffix);
nixosVersion = mkDefault (cfg.nixosRelease + cfg.nixosVersionSuffix); revision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
nixosRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId); versionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
nixosVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
# Note: code names must only increase in alphabetical order. # Note: code names must only increase in alphabetical order.
nixosCodeName = "Impala"; codeName = "Impala";
}; };
# Generate /etc/os-release. See # Generate /etc/os-release. See
@ -105,10 +96,10 @@ in
'' ''
NAME=NixOS NAME=NixOS
ID=nixos ID=nixos
VERSION="${config.system.nixosVersion} (${config.system.nixosCodeName})" VERSION="${cfg.version} (${cfg.codeName})"
VERSION_CODENAME=${toLower config.system.nixosCodeName} VERSION_CODENAME=${toLower cfg.codeName}
VERSION_ID="${config.system.nixosVersion}" VERSION_ID="${cfg.version}"
PRETTY_NAME="NixOS ${config.system.nixosVersion} (${config.system.nixosCodeName})" PRETTY_NAME="NixOS ${cfg.version} (${cfg.codeName})"
HOME_URL="https://nixos.org/" HOME_URL="https://nixos.org/"
SUPPORT_URL="https://nixos.org/nixos/support.html" SUPPORT_URL="https://nixos.org/nixos/support.html"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues" BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"

View File

@ -60,6 +60,7 @@
./misc/extra-arguments.nix ./misc/extra-arguments.nix
./misc/ids.nix ./misc/ids.nix
./misc/lib.nix ./misc/lib.nix
./misc/label.nix
./misc/locate.nix ./misc/locate.nix
./misc/meta.nix ./misc/meta.nix
./misc/nixpkgs.nix ./misc/nixpkgs.nix

View File

@ -189,6 +189,14 @@ with lib;
# Profile splitting # Profile splitting
(mkRenamedOptionModule [ "virtualization" "growPartition" ] [ "boot" "growPartition" ]) (mkRenamedOptionModule [ "virtualization" "growPartition" ] [ "boot" "growPartition" ])
# misc/version.nix
(mkRenamedOptionModule [ "config" "system" "nixosVersion" ] [ "config" "system" "nixos" "version" ])
(mkRenamedOptionModule [ "config" "system" "nixosRelease" ] [ "config" "system" "nixos" "release" ])
(mkRenamedOptionModule [ "config" "system" "nixosVersionSuffix" ] [ "config" "system" "nixos" "versionSuffix" ])
(mkRenamedOptionModule [ "config" "system" "nixosRevision" ] [ "config" "system" "nixos" "revision" ])
(mkRenamedOptionModule [ "config" "system" "nixosCodeName" ] [ "config" "system" "nixos" "codeName" ])
(mkRenamedOptionModule [ "config" "system" "nixosLabel" ] [ "config" "system" "nixos" "label" ])
# Options that are obsolete and have no replacement. # Options that are obsolete and have no replacement.
(mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "") (mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "")
(mkRemovedOptionModule [ "programs" "bash" "enable" ] "") (mkRemovedOptionModule [ "programs" "bash" "enable" ] "")

View File

@ -16,10 +16,10 @@ let
It isn't perfect, but it seems to cover a vast majority of use cases. It isn't perfect, but it seems to cover a vast majority of use cases.
Caveat: even if the package is reached by a different means, Caveat: even if the package is reached by a different means,
the path above will be shown and not e.g. `${config.services.foo.package}`. */ the path above will be shown and not e.g. `${config.services.foo.package}`. */
manual = import ../../../doc/manual { manual = import ../../../doc/manual rec {
inherit pkgs config; inherit pkgs config;
version = config.system.nixosRelease; version = config.system.nixos.release;
revision = "release-${config.system.nixosRelease}"; revision = "release-${version}";
options = options =
let let
scrubbedEval = evalModules { scrubbedEval = evalModules {

View File

@ -12,7 +12,7 @@ let
case "$1" in case "$1" in
-i) echo "nixos";; -i) echo "nixos";;
-r) echo "${config.system.nixosVersion}";; -r) echo "${config.system.nixos.version}";;
esac esac
''; '';
in { in {

View File

@ -64,8 +64,8 @@ in
config = { config = {
# Note: this is set here rather than up there so that changing # Note: this is set here rather than up there so that changing
# nixosLabel would not rebuild manual pages # nixos.label would not rebuild manual pages
services.mingetty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixosLabel} (\m) - \l >>>''; services.mingetty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>'';
systemd.services."getty@" = systemd.services."getty@" =
{ serviceConfig.ExecStart = [ { serviceConfig.ExecStart = [

View File

@ -30,6 +30,8 @@ let
let let
kernelPath = "${config.boot.kernelPackages.kernel}/" + kernelPath = "${config.boot.kernelPackages.kernel}/" +
"${config.system.boot.loader.kernelFile}"; "${config.system.boot.loader.kernelFile}";
initrdPath = "${config.system.build.initialRamdisk}/" +
"${config.system.boot.loader.initrdFile}";
in '' in ''
mkdir $out mkdir $out
@ -50,7 +52,7 @@ let
echo -n "$kernelParams" > $out/kernel-params echo -n "$kernelParams" > $out/kernel-params
ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd ln -s ${initrdPath} $out/initrd
ln -s ${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets $out ln -s ${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets $out
@ -106,7 +108,7 @@ let
if [] == failed then pkgs.stdenvNoCC.mkDerivation { if [] == failed then pkgs.stdenvNoCC.mkDerivation {
name = let hn = config.networking.hostName; name = let hn = config.networking.hostName;
nn = if (hn != "") then hn else "unnamed"; nn = if (hn != "") then hn else "unnamed";
in "nixos-system-${nn}-${config.system.nixosLabel}"; in "nixos-system-${nn}-${config.system.nixos.label}";
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
buildCommand = systemBuilder; buildCommand = systemBuilder;
@ -120,7 +122,7 @@ let
config.system.build.installBootLoader config.system.build.installBootLoader
or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
activationScript = config.system.activationScripts.script; activationScript = config.system.activationScripts.script;
nixosLabel = config.system.nixosLabel; nixosLabel = config.system.nixos.label;
configurationName = config.boot.loader.grub.configurationName; configurationName = config.boot.loader.grub.configurationName;
@ -179,6 +181,15 @@ in
''; '';
}; };
system.boot.loader.initrdFile = mkOption {
internal = true;
default = "initrd";
type = types.str;
description = ''
Name of the initrd file to be passed to the bootloader.
'';
};
system.copySystemConfiguration = mkOption { system.copySystemConfiguration = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;

View File

@ -26,7 +26,7 @@ in
rm $diskImageBase rm $diskImageBase
popd popd
''; '';
diskImageBase = "nixos-image-${config.system.nixosLabel}-${pkgs.stdenv.system}.raw"; diskImageBase = "nixos-image-${config.system.nixos.label}-${pkgs.stdenv.system}.raw";
buildInputs = [ pkgs.utillinux pkgs.perl ]; buildInputs = [ pkgs.utillinux pkgs.perl ];
exportReferencesGraph = exportReferencesGraph =
[ "closure" config.system.build.toplevel ]; [ "closure" config.system.build.toplevel ];

View File

@ -14,7 +14,7 @@ in
PATH=$PATH:${pkgs.stdenv.lib.makeBinPath [ pkgs.gnutar pkgs.gzip ]} PATH=$PATH:${pkgs.stdenv.lib.makeBinPath [ pkgs.gnutar pkgs.gzip ]}
pushd $out pushd $out
mv $diskImage disk.raw mv $diskImage disk.raw
tar -Szcf nixos-image-${config.system.nixosLabel}-${pkgs.stdenv.system}.raw.tar.gz disk.raw tar -Szcf nixos-image-${config.system.nixos.label}-${pkgs.stdenv.system}.raw.tar.gz disk.raw
rm $out/disk.raw rm $out/disk.raw
popd popd
''; '';

View File

@ -22,7 +22,7 @@ in {
config = { config = {
system.build.virtualBoxOVA = import ../../lib/make-disk-image.nix { system.build.virtualBoxOVA = import ../../lib/make-disk-image.nix {
name = "nixos-ova-${config.system.nixosLabel}-${pkgs.stdenv.system}"; name = "nixos-ova-${config.system.nixos.label}-${pkgs.stdenv.system}";
inherit pkgs lib config; inherit pkgs lib config;
partitionTableType = "legacy"; partitionTableType = "legacy";
@ -37,7 +37,7 @@ in {
VBoxManage internalcommands createrawvmdk -filename disk.vmdk -rawdisk $diskImage VBoxManage internalcommands createrawvmdk -filename disk.vmdk -rawdisk $diskImage
echo "creating VirtualBox VM..." echo "creating VirtualBox VM..."
vmName="NixOS ${config.system.nixosLabel} (${pkgs.stdenv.system})" vmName="NixOS ${config.system.nixos.label} (${pkgs.stdenv.system})"
VBoxManage createvm --name "$vmName" --register \ VBoxManage createvm --name "$vmName" --register \
--ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"} --ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"}
VBoxManage modifyvm "$vmName" \ VBoxManage modifyvm "$vmName" \
@ -53,7 +53,7 @@ in {
echo "exporting VirtualBox VM..." echo "exporting VirtualBox VM..."
mkdir -p $out mkdir -p $out
fn="$out/nixos-${config.system.nixosLabel}-${pkgs.stdenv.system}.ova" fn="$out/nixos-${config.system.nixos.label}-${pkgs.stdenv.system}.ova"
VBoxManage export "$vmName" --output "$fn" VBoxManage export "$vmName" --output "$fn"
rm -v $diskImage rm -v $diskImage

View File

@ -35,8 +35,8 @@ let
versionModule = versionModule =
{ system.nixosVersionSuffix = versionSuffix; { system.nixos.versionSuffix = versionSuffix;
system.nixosRevision = nixpkgs.rev or nixpkgs.shortRev; system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
}; };