* Add a command "nixos-version" that prints the version of the

currently activated NixOS.  This is "0.1pre-svn" when built from a
  SVN tree, but contains the actual revision when installed from the
  NixOS channel or from the ISO.

svn path=/nixos/trunk/; revision=33730
This commit is contained in:
Eelco Dolstra 2012-04-10 20:56:38 +00:00
parent 871b4bd43a
commit 096b7723c8
8 changed files with 36 additions and 31 deletions

View File

View File

@ -28,16 +28,6 @@ let
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
options = {
system.nixosVersion = mkOption {
default = "${builtins.readFile ../../../VERSION}";
description = ''
NixOS version number.
'';
};
};
# A clue for the kernel loading
kernelParams = pkgs.writeText "kernel-params.txt" ''
Kernel Parameters:

View File

@ -29,16 +29,6 @@ let
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
options = {
system.nixosVersion = mkOption {
default = "${builtins.readFile ../../../VERSION}";
description = ''
NixOS version number.
'';
};
};
# A clue for the kernel loading
kernelParams = pkgs.writeText "kernel-params.txt" ''
Kernel Parameters:

View File

@ -51,6 +51,12 @@ let
src = ./nixos-option.sh;
};
nixosVersion = makeProg {
name = "nixos-version";
src = ./nixos-version.sh;
inherit (config.system) nixosVersion;
};
nixosGui = pkgs.xulrunnerWrapper {
launcher = "nixos-gui";
application = pkgs.stdenv.mkDerivation {
@ -116,6 +122,7 @@ in
nixosHardwareScan
nixosGenSeccureKeys
nixosOption
nixosVersion
] ++ pkgs.lib.optional cfg.enableGraphicalTools nixosGui;
system.build = {

18
modules/misc/version.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, ... }:
with pkgs.lib;
{
options = {
system.nixosVersion = mkOption {
default =
builtins.readFile ../../.version
+ (if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix else "pre-svn");
description = "NixOS version.";
};
};
}

View File

@ -36,6 +36,7 @@
./misc/locate.nix
./misc/nixpkgs.nix
./misc/passthru.nix
./misc/version.nix
./programs/bash/bash.nix
./programs/blcr.nix
./programs/info.nix

View File

@ -67,13 +67,7 @@ in
];
options = {
system.nixosVersion = mkOption {
default = "${builtins.readFile ../../VERSION}";
description = ''
NixOS version number.
'';
};
installer.cloneConfig = mkOption {
default = true;
description = ''
@ -101,6 +95,7 @@ in
in live CDs.
'';
};
};
config = {

View File

@ -17,7 +17,7 @@ let
let
version = builtins.readFile ./VERSION + (lib.optionalString (!officialRelease) versionSuffix);
version = builtins.readFile ./.version + (lib.optionalString (!officialRelease) versionSuffix);
versionModule =
{ system.nixosVersion = version;
@ -55,7 +55,7 @@ let
with import <nixpkgs> {inherit system;};
let
version = builtins.readFile ./VERSION + (lib.optionalString (!officialRelease) versionSuffix);
version = builtins.readFile ./.version + (lib.optionalString (!officialRelease) versionSuffix);
versionModule = { system.nixosVersion = version; };
@ -86,18 +86,20 @@ let
releaseTools.makeSourceTarball {
name = "nixos-tarball";
version = builtins.readFile ./VERSION;
version = builtins.readFile ./.version;
src = nixosSrc;
inherit officialRelease;
distPhase = ''
echo -n $VERSION_SUFFIX > .version-suffix
releaseName=nixos-$VERSION$VERSION_SUFFIX
ensureDir "$out/tarballs"
mkdir ../$releaseName
cp -prd . ../$releaseName
cd ..
chmod -R u+w $releaseName
tar cfvj $out/tarballs/$releaseName.tar.bz2 $releaseName
''; # */
};
@ -111,7 +113,7 @@ let
releaseTools.makeSourceTarball {
name = "nixos-channel";
version = builtins.readFile ./VERSION;
version = builtins.readFile ./.version;
src = nixosSrc;
@ -126,6 +128,7 @@ let
'';
distPhase = ''
echo -n $VERSION_SUFFIX > .version-suffix
releaseName=nixos-$VERSION$VERSION_SUFFIX
ensureDir "$out/tarballs"
mkdir ../$releaseName
@ -134,6 +137,7 @@ let
echo "$expr" > ../$releaseName/default.nix
NIX_STATE_DIR=$TMPDIR nix-env -f ../$releaseName/default.nix -qaP --meta --xml \* > /dev/null
cd ..
chmod -R u+w $releaseName
tar cfj $out/tarballs/$releaseName.tar.bz2 $releaseName
''; # */
};