From 096b7723c8c6d913cb42fb0acfa082ab1d34b8a3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 10 Apr 2012 20:56:38 +0000 Subject: [PATCH] * 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 --- VERSION => .version | 0 .../cd-dvd/system-tarball-fuloong2f.nix | 10 ---------- .../cd-dvd/system-tarball-sheevaplug.nix | 10 ---------- modules/installer/tools/tools.nix | 7 +++++++ modules/misc/version.nix | 18 ++++++++++++++++++ modules/module-list.nix | 1 + modules/profiles/installation-device.nix | 9 ++------- release.nix | 12 ++++++++---- 8 files changed, 36 insertions(+), 31 deletions(-) rename VERSION => .version (100%) create mode 100644 modules/misc/version.nix diff --git a/VERSION b/.version similarity index 100% rename from VERSION rename to .version diff --git a/modules/installer/cd-dvd/system-tarball-fuloong2f.nix b/modules/installer/cd-dvd/system-tarball-fuloong2f.nix index 618f5ea9627..5a23a394f7f 100644 --- a/modules/installer/cd-dvd/system-tarball-fuloong2f.nix +++ b/modules/installer/cd-dvd/system-tarball-fuloong2f.nix @@ -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: diff --git a/modules/installer/cd-dvd/system-tarball-sheevaplug.nix b/modules/installer/cd-dvd/system-tarball-sheevaplug.nix index e49bcf3a66a..9052badfe0e 100644 --- a/modules/installer/cd-dvd/system-tarball-sheevaplug.nix +++ b/modules/installer/cd-dvd/system-tarball-sheevaplug.nix @@ -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: diff --git a/modules/installer/tools/tools.nix b/modules/installer/tools/tools.nix index 930be55a0de..ad9ea2d61dc 100644 --- a/modules/installer/tools/tools.nix +++ b/modules/installer/tools/tools.nix @@ -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 = { diff --git a/modules/misc/version.nix b/modules/misc/version.nix new file mode 100644 index 00000000000..32e2e1b1dc0 --- /dev/null +++ b/modules/misc/version.nix @@ -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."; + }; + + }; + +} diff --git a/modules/module-list.nix b/modules/module-list.nix index 684d1ad516e..48171f62150 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -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 diff --git a/modules/profiles/installation-device.nix b/modules/profiles/installation-device.nix index 40daa10c8ce..d56cec64a0c 100644 --- a/modules/profiles/installation-device.nix +++ b/modules/profiles/installation-device.nix @@ -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 = { diff --git a/release.nix b/release.nix index 286e314ac1e..9ec5f9c8761 100644 --- a/release.nix +++ b/release.nix @@ -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 {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 ''; # */ };