2014-04-14 18:26:48 +04:00
|
|
|
{ config, lib, pkgs, ... }:
|
2012-04-11 00:56:38 +04:00
|
|
|
|
2014-04-14 18:26:48 +04:00
|
|
|
with lib;
|
2012-04-11 00:56:38 +04:00
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
let
|
|
|
|
cfg = config.system;
|
|
|
|
|
2016-05-25 01:34:28 +03:00
|
|
|
releaseFile = "${toString pkgs.path}/.version";
|
|
|
|
suffixFile = "${toString pkgs.path}/.version-suffix";
|
2015-09-18 16:46:47 +03:00
|
|
|
revisionFile = "${toString pkgs.path}/.git-revision";
|
2016-05-25 01:34:28 +03:00
|
|
|
gitRepo = "${toString pkgs.path}/.git";
|
|
|
|
gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo);
|
2015-09-18 16:46:47 +03:00
|
|
|
in
|
|
|
|
|
2012-04-11 00:56:38 +04:00
|
|
|
{
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
options.system = {
|
2013-01-16 17:40:41 +04:00
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
stateVersion = mkOption {
|
2015-07-27 20:46:36 +03:00
|
|
|
type = types.str;
|
2015-09-18 16:46:47 +03:00
|
|
|
default = cfg.nixosRelease;
|
2015-07-27 20:46:36 +03: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 19:50:48 +03:00
|
|
|
nixosLabel = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
2016-07-28 19:10:17 +03:00
|
|
|
Label to be used in the names of generated outputs and boot
|
|
|
|
labels.
|
2015-09-18 19:50:48 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
nixosVersion = mkOption {
|
2013-10-23 18:59:33 +04:00
|
|
|
internal = true;
|
2013-10-30 14:02:04 +04:00
|
|
|
type = types.str;
|
2016-07-28 19:27:03 +03:00
|
|
|
description = "The full NixOS version (e.g. <literal>16.03.1160.f2d4ee1</literal>).";
|
2012-04-11 00:56:38 +04:00
|
|
|
};
|
2012-05-18 01:10:42 +04:00
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
nixosRelease = mkOption {
|
2015-07-30 14:36:57 +03:00
|
|
|
readOnly = true;
|
2015-07-27 20:46:36 +03:00
|
|
|
type = types.str;
|
2016-07-31 16:08:29 +03:00
|
|
|
default = fileContents releaseFile;
|
2016-07-28 19:27:03 +03:00
|
|
|
description = "The NixOS release (e.g. <literal>16.03</literal>).";
|
2015-07-27 20:46:36 +03:00
|
|
|
};
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
nixosVersionSuffix = mkOption {
|
2013-10-23 18:59:33 +04:00
|
|
|
internal = true;
|
2013-10-30 14:02:04 +04:00
|
|
|
type = types.str;
|
2016-07-31 16:08:29 +03:00
|
|
|
default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
|
2016-07-28 19:27:03 +03:00
|
|
|
description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
|
2013-01-16 17:40:41 +04:00
|
|
|
};
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
nixosRevision = mkOption {
|
2013-10-24 21:58:34 +04:00
|
|
|
internal = true;
|
2013-10-30 14:02:04 +04:00
|
|
|
type = types.str;
|
2016-08-09 15:15:53 +03:00
|
|
|
default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo
|
|
|
|
else if pathExists revisionFile then fileContents revisionFile
|
|
|
|
else "master";
|
2016-07-28 19:27:03 +03:00
|
|
|
description = "The Git revision from which this NixOS configuration was built.";
|
2013-10-24 21:58:34 +04:00
|
|
|
};
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
nixosCodeName = mkOption {
|
2015-07-30 14:36:57 +03:00
|
|
|
readOnly = true;
|
2013-10-30 14:02:04 +04:00
|
|
|
type = types.str;
|
2016-07-28 19:27:03 +03:00
|
|
|
description = "The NixOS release code name (e.g. <literal>Emu</literal>).";
|
2013-07-17 15:34:40 +04:00
|
|
|
};
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
defaultChannel = mkOption {
|
2013-10-24 17:09:00 +04:00
|
|
|
internal = true;
|
2013-10-30 14:02:04 +04:00
|
|
|
type = types.str;
|
2013-11-11 14:22:41 +04:00
|
|
|
default = https://nixos.org/channels/nixos-unstable;
|
2013-10-24 17:09:00 +04:00
|
|
|
description = "Default NixOS channel to which the root user is subscribed.";
|
|
|
|
};
|
|
|
|
|
2012-05-18 01:10:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
system = {
|
2015-09-18 19:50:48 +03:00
|
|
|
# These defaults are set here rather than up there so that
|
|
|
|
# changing them would not rebuild the manual
|
2016-07-28 19:10:17 +03:00
|
|
|
nixosLabel = mkDefault cfg.nixosVersion;
|
|
|
|
nixosVersion = mkDefault (cfg.nixosRelease + cfg.nixosVersionSuffix);
|
2016-06-02 18:03:35 +03:00
|
|
|
nixosRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
|
|
|
|
nixosVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
|
2013-01-16 17:40:41 +04:00
|
|
|
|
2015-09-18 16:46:47 +03:00
|
|
|
# Note: code names must only increase in alphabetical order.
|
2017-02-27 22:21:13 +03:00
|
|
|
nixosCodeName = "Hummingbird";
|
2015-09-18 16:46:47 +03:00
|
|
|
};
|
2013-07-17 15:34:40 +04:00
|
|
|
|
2012-05-18 01:10:42 +04:00
|
|
|
# Generate /etc/os-release. See
|
2017-01-07 19:28:11 +03:00
|
|
|
# https://www.freedesktop.org/software/systemd/man/os-release.html for the
|
2012-05-18 01:10:42 +04:00
|
|
|
# format.
|
2013-11-01 02:01:07 +04:00
|
|
|
environment.etc."os-release".text =
|
|
|
|
''
|
|
|
|
NAME=NixOS
|
|
|
|
ID=nixos
|
|
|
|
VERSION="${config.system.nixosVersion} (${config.system.nixosCodeName})"
|
2017-02-26 00:15:45 +03:00
|
|
|
VERSION_CODENAME=${toLower config.system.nixosCodeName}
|
2013-11-01 02:01:07 +04:00
|
|
|
VERSION_ID="${config.system.nixosVersion}"
|
|
|
|
PRETTY_NAME="NixOS ${config.system.nixosVersion} (${config.system.nixosCodeName})"
|
2017-02-26 00:15:45 +03:00
|
|
|
HOME_URL="https://nixos.org/"
|
|
|
|
SUPPORT_URL="https://nixos.org/nixos/support.html"
|
|
|
|
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
|
2013-11-01 02:01:07 +04:00
|
|
|
'';
|
2013-01-16 17:40:41 +04:00
|
|
|
|
2012-04-11 00:56:38 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|