2014-04-14 07:26:48 -07:00
|
|
|
{ config, lib, pkgs, ... }:
|
2012-04-10 13:56:38 -07:00
|
|
|
|
2014-04-14 07:26:48 -07:00
|
|
|
with lib;
|
2012-04-10 13:56:38 -07:00
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
let
|
|
|
|
cfg = config.system;
|
|
|
|
|
|
|
|
releaseFile = "${toString pkgs.path}/.version";
|
|
|
|
suffixFile = "${toString pkgs.path}/.version-suffix";
|
|
|
|
revisionFile = "${toString pkgs.path}/.git-revision";
|
|
|
|
in
|
|
|
|
|
2012-04-10 13:56:38 -07:00
|
|
|
{
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
options.system = {
|
2013-01-16 05:40:41 -08:00
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
stateVersion = mkOption {
|
2015-07-27 10:46:36 -07:00
|
|
|
type = types.str;
|
2015-09-18 06:46:47 -07:00
|
|
|
default = cfg.nixosRelease;
|
2015-07-27 10:46:36 -07:00
|
|
|
description = ''
|
|
|
|
Every once in a while, a new NixOS release may change
|
|
|
|
configuration defaults in a way incompatible with stateful
|
|
|
|
data. For instance, if the default version of PostgreSQL
|
|
|
|
changes, the new version will probably be unable to read your
|
|
|
|
existing databases. To prevent such breakage, you can set the
|
|
|
|
value of this option to the NixOS release with which you want
|
|
|
|
to be compatible. The effect is that NixOS will option
|
|
|
|
defaults corresponding to the specified release (such as using
|
|
|
|
an older version of PostgreSQL).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
nixosVersion = mkOption {
|
2013-10-23 07:59:33 -07:00
|
|
|
internal = true;
|
2013-10-30 03:02:04 -07:00
|
|
|
type = types.str;
|
2012-04-10 13:56:38 -07:00
|
|
|
description = "NixOS version.";
|
|
|
|
};
|
2012-05-17 14:10:42 -07:00
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
nixosRelease = mkOption {
|
2015-07-30 04:36:57 -07:00
|
|
|
readOnly = true;
|
2015-07-27 10:46:36 -07:00
|
|
|
type = types.str;
|
2015-09-18 06:46:47 -07:00
|
|
|
default = readFile releaseFile;
|
2015-07-27 10:46:36 -07:00
|
|
|
description = "NixOS release.";
|
|
|
|
};
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
nixosVersionSuffix = mkOption {
|
2013-10-23 07:59:33 -07:00
|
|
|
internal = true;
|
2013-10-30 03:02:04 -07:00
|
|
|
type = types.str;
|
2015-09-18 06:46:47 -07:00
|
|
|
default = if pathExists suffixFile then readFile suffixFile else "pre-git";
|
2013-01-16 05:40:41 -08:00
|
|
|
description = "NixOS version suffix.";
|
|
|
|
};
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
nixosRevision = mkOption {
|
2013-10-24 10:58:34 -07:00
|
|
|
internal = true;
|
2013-10-30 03:02:04 -07:00
|
|
|
type = types.str;
|
2015-09-18 06:46:47 -07:00
|
|
|
default = if pathExists revisionFile then readFile revisionFile else "master";
|
2013-10-24 10:58:34 -07:00
|
|
|
description = "NixOS Git revision hash.";
|
|
|
|
};
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
nixosCodeName = mkOption {
|
2015-07-30 04:36:57 -07:00
|
|
|
readOnly = true;
|
2013-10-30 03:02:04 -07:00
|
|
|
type = types.str;
|
2013-07-17 04:34:40 -07:00
|
|
|
description = "NixOS release code name.";
|
|
|
|
};
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
defaultChannel = mkOption {
|
2013-10-24 06:09:00 -07:00
|
|
|
internal = true;
|
2013-10-30 03:02:04 -07:00
|
|
|
type = types.str;
|
2013-11-11 02:22:41 -08:00
|
|
|
default = https://nixos.org/channels/nixos-unstable;
|
2013-10-24 06:09:00 -07:00
|
|
|
description = "Default NixOS channel to which the root user is subscribed.";
|
|
|
|
};
|
|
|
|
|
2012-05-17 14:10:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
system = {
|
|
|
|
# This is set here rather than up there so that changing this
|
|
|
|
# env variable will not rebuild the manual
|
|
|
|
nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix));
|
2013-01-16 05:40:41 -08:00
|
|
|
|
2015-09-18 06:46:47 -07:00
|
|
|
# Note: code names must only increase in alphabetical order.
|
|
|
|
nixosCodeName = "Emu";
|
|
|
|
};
|
2013-07-17 04:34:40 -07:00
|
|
|
|
2012-05-17 14:10:42 -07:00
|
|
|
# Generate /etc/os-release. See
|
|
|
|
# http://0pointer.de/public/systemd-man/os-release.html for the
|
|
|
|
# format.
|
2013-10-31 15:01:07 -07:00
|
|
|
environment.etc."os-release".text =
|
|
|
|
''
|
|
|
|
NAME=NixOS
|
|
|
|
ID=nixos
|
|
|
|
VERSION="${config.system.nixosVersion} (${config.system.nixosCodeName})"
|
|
|
|
VERSION_ID="${config.system.nixosVersion}"
|
|
|
|
PRETTY_NAME="NixOS ${config.system.nixosVersion} (${config.system.nixosCodeName})"
|
|
|
|
HOME_URL="http://nixos.org/"
|
|
|
|
'';
|
2013-01-16 05:40:41 -08:00
|
|
|
|
2012-04-10 13:56:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|