From 2cd7c1f19888ae73bf7ef0f41a45680cfb86334a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 5 Aug 2015 17:29:08 +0200 Subject: [PATCH] Unify NixOS and Nixpkgs channel structure This is primarily to ensure that -I nixpkgs=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz and -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz and -I nixpkgs=https://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz behave consistently. It also allows installing packages via "nix-env -iA nixos." rather than "nixos.pkgs.". It would be even better to allow "nixpkgs.", but that requires a change to nix-channel. Fixes #7659. --- doc/haskell-users-guide.xml | 8 ++++---- .../manual/configuration/ad-hoc-packages.xml | 2 +- .../configuration/declarative-packages.xml | 4 ++-- nixos/lib/build-vms.nix | 2 +- nixos/lib/channel-expr.nix | 6 ------ nixos/lib/make-channel.nix | 8 ++------ nixos/lib/nixpkgs.nix | 8 -------- nixos/modules/installer/cd-dvd/channel.nix | 17 ++++++++--------- .../modules/installer/tools/nixos-checkout.nix | 2 +- nixos/modules/misc/extra-arguments.nix | 2 +- nixos/modules/misc/nixpkgs.nix | 2 +- nixos/tests/containers.nix | 2 +- 12 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 nixos/lib/channel-expr.nix delete mode 100644 nixos/lib/nixpkgs.nix diff --git a/doc/haskell-users-guide.xml b/doc/haskell-users-guide.xml index e3903ddd411..e0dc89cc7ce 100644 --- a/doc/haskell-users-guide.xml +++ b/doc/haskell-users-guide.xml @@ -92,18 +92,18 @@ error: attribute ‘haskellPackages’ in selection path $ nix-env -qaP coreutils -nixos.pkgs.coreutils coreutils-8.23 +nixos.coreutils coreutils-8.23 If your system responds like that (most NixOS installatios will), then the attribute path to haskellPackages is - nixos.pkgs.haskellPackages. Thus, if you want to + nixos.haskellPackages. Thus, if you want to use nix-env without giving an explicit -f flag, then that's the way to do it: -$ nix-env -qaP -A nixos.pkgs.haskellPackages -$ nix-env -iA nixos.pkgs.haskellPackages.cabal-install +$ nix-env -qaP -A nixos.haskellPackages +$ nix-env -iA nixos.haskellPackages.cabal-install Our current default compiler is GHC 7.10.x and the diff --git a/nixos/doc/manual/configuration/ad-hoc-packages.xml b/nixos/doc/manual/configuration/ad-hoc-packages.xml index e237e20c4ff..a147291c4f3 100644 --- a/nixos/doc/manual/configuration/ad-hoc-packages.xml +++ b/nixos/doc/manual/configuration/ad-hoc-packages.xml @@ -11,7 +11,7 @@ uninstall packages from the command line. For instance, to install Mozilla Thunderbird: -$ nix-env -iA nixos.pkgs.thunderbird +$ nix-env -iA nixos.thunderbird If you invoke this as root, the package is installed in the Nix profile /nix/var/nix/profiles/default and visible diff --git a/nixos/doc/manual/configuration/declarative-packages.xml b/nixos/doc/manual/configuration/declarative-packages.xml index 6de38b452e2..dc2fa715097 100644 --- a/nixos/doc/manual/configuration/declarative-packages.xml +++ b/nixos/doc/manual/configuration/declarative-packages.xml @@ -23,13 +23,13 @@ Nixpkgs will be built or downloaded as part of the system when you run You can get a list of the available packages as follows: $ nix-env -qaP '*' --description -nixos.pkgs.firefox firefox-23.0 Mozilla Firefox - the browser, reloaded +nixos.firefox firefox-23.0 Mozilla Firefox - the browser, reloaded ... The first column in the output is the attribute name, such as -nixos.pkgs.thunderbird. (The +nixos.thunderbird. (The nixos prefix allows distinguishing between different channels that you might have.) diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index 01d6b21bba9..a97bae57d9b 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -1,6 +1,6 @@ { system, minimal ? false }: -let pkgs = import ./nixpkgs.nix { config = {}; inherit system; }; in +let pkgs = import ../.. { config = {}; inherit system; }; in with pkgs.lib; with import ../lib/qemu-flags.nix; diff --git a/nixos/lib/channel-expr.nix b/nixos/lib/channel-expr.nix deleted file mode 100644 index 453bdd506b8..00000000000 --- a/nixos/lib/channel-expr.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ system ? builtins.currentSystem }: - -{ pkgs = - (import nixpkgs/default.nix { inherit system; }) - // { recurseForDerivations = true; }; -} diff --git a/nixos/lib/make-channel.nix b/nixos/lib/make-channel.nix index 1c6bf0897f4..fd805f7f943 100644 --- a/nixos/lib/make-channel.nix +++ b/nixos/lib/make-channel.nix @@ -10,19 +10,15 @@ pkgs.releaseTools.makeSourceTarball { buildInputs = [ pkgs.nix ]; - expr = builtins.readFile ./channel-expr.nix; - distPhase = '' rm -rf .git echo -n $VERSION_SUFFIX > .version-suffix echo -n ${nixpkgs.rev or nixpkgs.shortRev} > .git-revision releaseName=nixos-$VERSION$VERSION_SUFFIX mkdir -p $out/tarballs - mkdir ../$releaseName - cp -prd . ../$releaseName/nixpkgs + cp -prd . ../$releaseName chmod -R u+w ../$releaseName - ln -s nixpkgs/nixos ../$releaseName/nixos - echo "$expr" > ../$releaseName/default.nix + ln -s . ../$releaseName/nixpkgs # hack to make ‘’ work NIX_STATE_DIR=$TMPDIR nix-env -f ../$releaseName/default.nix -qaP --meta --xml \* > /dev/null cd .. chmod -R u+w $releaseName diff --git a/nixos/lib/nixpkgs.nix b/nixos/lib/nixpkgs.nix deleted file mode 100644 index 10096f58c79..00000000000 --- a/nixos/lib/nixpkgs.nix +++ /dev/null @@ -1,8 +0,0 @@ -/* Terrible backward compatibility hack to get the path to Nixpkgs - from here. Usually, that's the relative path ‘../..’. However, - when using the NixOS channel, resolves to a symlink to - nixpkgs/nixos, so ‘../..’ doesn't resolve to the top-level Nixpkgs - directory but one above it. So check for that situation. */ -if builtins.pathExists ../../.version then import ../.. -else if builtins.pathExists ../../nixpkgs then import ../../nixpkgs -else abort "Can't find Nixpkgs, please set ‘NIX_PATH=nixpkgs=/path/to/nixpkgs’." diff --git a/nixos/modules/installer/cd-dvd/channel.nix b/nixos/modules/installer/cd-dvd/channel.nix index ca0e233f9e3..eccb19da5cb 100644 --- a/nixos/modules/installer/cd-dvd/channel.nix +++ b/nixos/modules/installer/cd-dvd/channel.nix @@ -9,18 +9,17 @@ let # We need a copy of the Nix expressions for Nixpkgs and NixOS on the # CD. These are installed into the "nixos" channel of the root - # user, as expected by nixos-rebuild/nixos-install. + # user, as expected by nixos-rebuild/nixos-install. FIXME: merge + # with make-channel.nix. channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}" - { expr = readFile ../../../lib/channel-expr.nix; } + { } '' - mkdir -p $out/nixos - cp -prd ${pkgs.path} $out/nixos/nixpkgs - ln -s nixpkgs/nixos $out/nixos/nixos + mkdir -p $out + cp -prd ${pkgs.path} $out/nixos chmod -R u+w $out/nixos - rm -rf $out/nixos/nixpkgs/.git - echo -n ${config.system.nixosVersion} > $out/nixos/nixpkgs/.version - echo -n "" > $out/nixos/nixpkgs/.version-suffix - echo "$expr" > $out/nixos/default.nix + ln -s . $out/nixos/nixpkgs + rm -rf $out/nixos/.git + echo -n ${config.system.nixosVersionSuffix} > $out/nixos/.version-suffix ''; in diff --git a/nixos/modules/installer/tools/nixos-checkout.nix b/nixos/modules/installer/tools/nixos-checkout.nix index 9cdd8a74a18..07274e139f7 100644 --- a/nixos/modules/installer/tools/nixos-checkout.nix +++ b/nixos/modules/installer/tools/nixos-checkout.nix @@ -27,7 +27,7 @@ let if [ -z "$(type -P git)" ]; then echo "installing Git..." - nix-env -iA nixos.pkgs.git || nix-env -i git + nix-env -iA nixos.git fi # Move any old nixpkgs directories out of the way. diff --git a/nixos/modules/misc/extra-arguments.nix b/nixos/modules/misc/extra-arguments.nix index ff2ff7cd432..02ac6e7a59d 100644 --- a/nixos/modules/misc/extra-arguments.nix +++ b/nixos/modules/misc/extra-arguments.nix @@ -2,7 +2,7 @@ { _module.args = { - pkgs_i686 = import ../../lib/nixpkgs.nix { + pkgs_i686 = import ../../.. { system = "i686-linux"; config.allowUnfree = true; }; diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index fb5516c953c..5eb38c510b4 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -72,7 +72,7 @@ in }; config = { - _module.args.pkgs = import ../../lib/nixpkgs.nix { + _module.args.pkgs = import ../../.. { system = config.nixpkgs.system; inherit (config.nixpkgs) config; diff --git a/nixos/tests/containers.nix b/nixos/tests/containers.nix index c429f9c7b71..ce36a7e0588 100644 --- a/nixos/tests/containers.nix +++ b/nixos/tests/containers.nix @@ -46,7 +46,7 @@ import ./make-test.nix ({ pkgs, ...} : { $machine->fail("curl --fail --connect-timeout 2 http://$ip/ > /dev/null"); # Make sure we have a NixOS tree (required by ‘nixos-container create’). - $machine->succeed("PAGER=cat nix-env -qa -A nixos.pkgs.hello >&2"); + $machine->succeed("PAGER=cat nix-env -qa -A nixos.hello >&2"); # Create some containers imperatively. my $id1 = $machine->succeed("nixos-container create foo --ensure-unique-name");