3
0
Fork 0
forked from mirrors/nixpkgs

* 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; 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 # A clue for the kernel loading
kernelParams = pkgs.writeText "kernel-params.txt" '' kernelParams = pkgs.writeText "kernel-params.txt" ''
Kernel Parameters: Kernel Parameters:

View file

@ -29,16 +29,6 @@ let
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l; 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 # A clue for the kernel loading
kernelParams = pkgs.writeText "kernel-params.txt" '' kernelParams = pkgs.writeText "kernel-params.txt" ''
Kernel Parameters: Kernel Parameters:

View file

@ -51,6 +51,12 @@ let
src = ./nixos-option.sh; src = ./nixos-option.sh;
}; };
nixosVersion = makeProg {
name = "nixos-version";
src = ./nixos-version.sh;
inherit (config.system) nixosVersion;
};
nixosGui = pkgs.xulrunnerWrapper { nixosGui = pkgs.xulrunnerWrapper {
launcher = "nixos-gui"; launcher = "nixos-gui";
application = pkgs.stdenv.mkDerivation { application = pkgs.stdenv.mkDerivation {
@ -116,6 +122,7 @@ in
nixosHardwareScan nixosHardwareScan
nixosGenSeccureKeys nixosGenSeccureKeys
nixosOption nixosOption
nixosVersion
] ++ pkgs.lib.optional cfg.enableGraphicalTools nixosGui; ] ++ pkgs.lib.optional cfg.enableGraphicalTools nixosGui;
system.build = { 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/locate.nix
./misc/nixpkgs.nix ./misc/nixpkgs.nix
./misc/passthru.nix ./misc/passthru.nix
./misc/version.nix
./programs/bash/bash.nix ./programs/bash/bash.nix
./programs/blcr.nix ./programs/blcr.nix
./programs/info.nix ./programs/info.nix

View file

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

View file

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