ceb8ab7ffa
Note that there is a subtle difference in Nix that causes nixos-rebuild to work and NixOps to fail: $ nix-instantiate '<nixos>' -A config.system.nixosVersion --eval-only "13.10pre34915.50f4822" $ nix-instantiate '<nixos/default.nix>' -A config.system.nixosVersion --eval-only error: opening file `/nix/var/nix/profiles/per-user/root/channels/nixos/.version': No such file or directory Fixes NixOS/nixops#145.
57 lines
1.4 KiB
Nix
57 lines
1.4 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
system.nixosVersion = mkOption {
|
|
type = types.uniq types.string;
|
|
description = "NixOS version.";
|
|
};
|
|
|
|
system.nixosVersionSuffix = mkOption {
|
|
type = types.uniq types.string;
|
|
description = "NixOS version suffix.";
|
|
};
|
|
|
|
system.nixosCodeName = mkOption {
|
|
type = types.uniq types.string;
|
|
description = "NixOS release code name.";
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
system.nixosVersion =
|
|
mkDefault (builtins.readFile "${pkgs.path}/.version" + config.system.nixosVersionSuffix);
|
|
|
|
system.nixosVersionSuffix =
|
|
let suffixFile = "${pkgs.path}/.version-suffix"; in
|
|
mkDefault (if builtins.pathExists suffixFile then builtins.readFile suffixFile else "pre-git");
|
|
|
|
# Note: code names must only increase in alphabetical order.
|
|
system.nixosCodeName = "Aardvark";
|
|
|
|
# Generate /etc/os-release. See
|
|
# http://0pointer.de/public/systemd-man/os-release.html for the
|
|
# format.
|
|
environment.etc = singleton
|
|
{ source = pkgs.writeText "os-release"
|
|
''
|
|
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/"
|
|
'';
|
|
target = "os-release";
|
|
};
|
|
|
|
};
|
|
|
|
}
|