From 722d8497e74b578adae34aeac7aab760988c2c54 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 4 Feb 2013 07:38:54 -0500 Subject: [PATCH] nixos-install: Respect /home/shlevy/src:/nix/var/nix/profiles/per-user/root/channels/nixos:nixpkgs=/etc/nixos/nixpkgs:nixos=/etc/nixos/nixos:nixos-config=/etc/nixos/configuration.nix:services=/etc/nixos/services to find the nixos and nixpkgs sources, only copy the nixos channel if it exists --- modules/installer/tools/nixos-install.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/installer/tools/nixos-install.sh b/modules/installer/tools/nixos-install.sh index 3cf919fc0ed..13335300743 100644 --- a/modules/installer/tools/nixos-install.sh +++ b/modules/installer/tools/nixos-install.sh @@ -149,25 +149,29 @@ done # Get the absolute path to the NixOS/Nixpkgs sources. -srcs=$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path) +nixpkgs_src=$(nix-instantiate --find-file nixpkgs) +nixos_src=$(nix-instantiate --find-file nixos) # Build the specified Nix expression in the target store and install # it into the system configuration profile. echo "building the system configuration..." -NIX_PATH="/mnt$srcs/nixos:nixos-config=$NIXOS_CONFIG" NIXOS_CONFIG= \ +NIX_PATH="nixpkgs=/mnt$nixpkgs_src:nixos=/mnt$nixos_src:nixos-config=$NIXOS_CONFIG" NIXOS_CONFIG= \ chroot $mountPoint @nix@/bin/nix-env \ -p /nix/var/nix/profiles/system -f '' --set -A system --show-trace # Copy the NixOS/Nixpkgs sources to the target as the initial contents # of the NixOS channel. -echo "copying NixOS/Nixpkgs sources..." mkdir -m 0755 -p $mountPoint/nix/var/nix/profiles mkdir -m 1777 -p $mountPoint/nix/var/nix/profiles/per-user mkdir -m 0755 -p $mountPoint/nix/var/nix/profiles/per-user/root -chroot $mountPoint @nix@/bin/nix-env \ - -p /nix/var/nix/profiles/per-user/root/channels -i "$srcs" --quiet +srcs=$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "") +if test -n "$srcs"; then + echo "copying NixOS/Nixpkgs sources..." + chroot $mountPoint @nix@/bin/nix-env \ + -p /nix/var/nix/profiles/per-user/root/channels -i "$srcs" --quiet +fi mkdir -m 0700 -p $mountPoint/root/.nix-defexpr ln -sfn /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels