summary refs log tree commit diff
path: root/nixos/modules/misc/version.nix
blob: 20a03b44a2ad1431231b6a4e3777d70a0bf23d58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ 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 ../../.version + config.system.nixosVersionSuffix);

    system.nixosVersionSuffix =
      mkDefault (if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix 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";
      };

  };

}