mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 01:20:40 +00:00
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
74 lines
1.9 KiB
Nix
74 lines
1.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
system.nixosVersion = mkOption {
|
|
internal = true;
|
|
type = types.str;
|
|
description = "NixOS version.";
|
|
};
|
|
|
|
system.nixosVersionSuffix = mkOption {
|
|
internal = true;
|
|
type = types.str;
|
|
description = "NixOS version suffix.";
|
|
};
|
|
|
|
system.nixosRevision = mkOption {
|
|
internal = true;
|
|
type = types.str;
|
|
description = "NixOS Git revision hash.";
|
|
};
|
|
|
|
system.nixosCodeName = mkOption {
|
|
internal = true;
|
|
type = types.str;
|
|
description = "NixOS release code name.";
|
|
};
|
|
|
|
system.defaultChannel = mkOption {
|
|
internal = true;
|
|
type = types.str;
|
|
default = https://nixos.org/channels/nixos-unstable;
|
|
description = "Default NixOS channel to which the root user is subscribed.";
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
system.nixosVersion =
|
|
mkDefault (readFile "${toString pkgs.path}/.version" + config.system.nixosVersionSuffix);
|
|
|
|
system.nixosVersionSuffix =
|
|
let suffixFile = "${toString pkgs.path}/.version-suffix"; in
|
|
mkDefault (if pathExists suffixFile then readFile suffixFile else "pre-git");
|
|
|
|
system.nixosRevision =
|
|
let fn = "${toString pkgs.path}/.git-revision"; in
|
|
mkDefault (if pathExists fn then readFile fn else "master");
|
|
|
|
# Note: code names must only increase in alphabetical order.
|
|
system.nixosCodeName = "Baboon";
|
|
|
|
# Generate /etc/os-release. See
|
|
# http://0pointer.de/public/systemd-man/os-release.html for the
|
|
# format.
|
|
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/"
|
|
'';
|
|
|
|
};
|
|
|
|
}
|