find modules | fgrep .nix | fgrep -v .svn | fgrep -v nixpkgs.nix | xargs sed -i -e 's|/nix/var|${config.nixpkgs.config.nix.stateDir}|g' -e 's|/nix/store|${config.nixpkgs.config.nix.storeDir}|g'

Don't assume /nix/store or /nix/var in NixOS modules, this is configurable

svn path=/nixos/trunk/; revision=30104
This commit is contained in:
Shea Levy 2011-10-29 21:03:57 +00:00
parent 9d496c77ac
commit 09cf6ce70c
21 changed files with 57 additions and 57 deletions

View File

@ -50,8 +50,8 @@ let
"~/.nix-profile/lib/X11/fonts" "~/.nix-profile/lib/X11/fonts"
"~/.nix-profile/share/fonts" "~/.nix-profile/share/fonts"
# - the default profile # - the default profile
"/nix/var/nix/profiles/default/lib/X11/fonts" "${config.nixpkgs.config.nix.stateDir}/nix/profiles/default/lib/X11/fonts"
"/nix/var/nix/profiles/default/share/fonts" "${config.nixpkgs.config.nix.stateDir}/nix/profiles/default/share/fonts"
]; ];
description = " description = "
List of primary font paths. List of primary font paths.

View File

@ -69,7 +69,7 @@ let
automatically updated every time you rebuild the system automatically updated every time you rebuild the system
configuration. (The latter is the main difference with configuration. (The latter is the main difference with
installing them in the default profile, installing them in the default profile,
<filename>/nix/var/nix/profiles/default</filename>. <filename>${config.nixpkgs.config.nix.stateDir}/nix/profiles/default</filename>.
''; '';
}; };

View File

@ -143,7 +143,7 @@ in
[ { mountPoint = "/"; [ { mountPoint = "/";
device = "/dev/root"; device = "/dev/root";
} }
{ mountPoint = "/nix/store"; { mountPoint = "${config.nixpkgs.config.nix.storeDir}";
fsType = "squashfs"; fsType = "squashfs";
device = "/nix-store.squashfs"; device = "/nix-store.squashfs";
options = "loop"; options = "loop";
@ -169,7 +169,7 @@ in
boot.initrd.kernelModules = [ "loop" ]; boot.initrd.kernelModules = [ "loop" ];
# In stage 1, mount a tmpfs on top of / (the ISO image) and # In stage 1, mount a tmpfs on top of / (the ISO image) and
# /nix/store (the squashfs image) to make this a live CD. # ${config.nixpkgs.config.nix.storeDir} (the squashfs image) to make this a live CD.
boot.initrd.postMountCommands = boot.initrd.postMountCommands =
'' ''
mkdir /mnt-root-tmpfs mkdir /mnt-root-tmpfs
@ -180,8 +180,8 @@ in
mkdir /mnt-store-tmpfs mkdir /mnt-store-tmpfs
mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs
mkdir -p $targetRoot/nix/store mkdir -p $targetRoot${config.nixpkgs.config.nix.storeDir}
mount -t aufs -o dirs=/mnt-store-tmpfs=rw:/mnt-root/nix/store=ro none /mnt-root-union/nix/store mount -t aufs -o dirs=/mnt-store-tmpfs=rw:/mnt-root${config.nixpkgs.config.nix.storeDir}=ro none /mnt-root-union${config.nixpkgs.config.nix.storeDir}
''; '';
# Closures to be copied to the Nix store on the CD, namely the init # Closures to be copied to the Nix store on the CD, namely the init
@ -223,7 +223,7 @@ in
} }
{ # Quick hack: need a mount point for the store. { # Quick hack: need a mount point for the store.
source = pkgs.runCommand "empty" {} "ensureDir $out"; source = pkgs.runCommand "empty" {} "ensureDir $out";
target = "/nix/store"; target = "${config.nixpkgs.config.nix.storeDir}";
} }
]; ];
@ -257,11 +257,11 @@ in
'' ''
# After booting, register the contents of the Nix store on the # After booting, register the contents of the Nix store on the
# CD in the Nix database in the tmpfs. # CD in the Nix database in the tmpfs.
${config.environment.nix}/bin/nix-store --load-db < /nix/store/nix-path-registration ${config.environment.nix}/bin/nix-store --load-db < ${config.nixpkgs.config.nix.storeDir}/nix-path-registration
# nixos-rebuild also requires a "system" profile and an # nixos-rebuild also requires a "system" profile and an
# /etc/NIXOS tag. # /etc/NIXOS tag.
touch /etc/NIXOS touch /etc/NIXOS
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /var/run/current-system ${config.environment.nix}/bin/nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --set /var/run/current-system
''; '';
} }

View File

@ -87,6 +87,6 @@ in
# nixos-rebuild also requires a "system" profile and an # nixos-rebuild also requires a "system" profile and an
# /etc/NIXOS tag. # /etc/NIXOS tag.
touch /etc/NIXOS touch /etc/NIXOS
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /var/run/current-system ${config.environment.nix}/bin/nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --set /var/run/current-system
''; '';
} }

View File

@ -31,7 +31,7 @@ let
default = false; default = false;
description = " description = "
Whether copy the necessary boot files into /boot, so Whether copy the necessary boot files into /boot, so
/nix/store is not needed by the boot loadear. ${config.nixpkgs.config.nix.storeDir} is not needed by the boot loadear.
"; ";
}; };
}; };

View File

@ -22,8 +22,8 @@ let
'' ''
if [ "$rollback" != "$succeeded" ] if [ "$rollback" != "$succeeded" ]
then then
ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p /nix/var/nix/profiles/system --rollback ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --rollback
ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} /nix/var/nix/profiles/system/bin/switch-to-configuration switch ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system/bin/switch-to-configuration switch
rollback=$((rollback + 1)) rollback=$((rollback + 1))
fi fi
@ -50,12 +50,12 @@ let
in in
'' ''
echo "=== activating system configuration on ${getAttr targetProperty (config.deployment)} ===" echo "=== activating system configuration on ${getAttr targetProperty (config.deployment)} ==="
ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p /nix/var/nix/profiles/system --set ${config.system.build.toplevel} || ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --set ${config.system.build.toplevel} ||
(ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p /nix/var/nix/profiles/system --rollback; rollbackSucceeded) (ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --rollback; rollbackSucceeded)
ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} /nix/var/nix/profiles/system/bin/switch-to-configuration switch || ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system/bin/switch-to-configuration switch ||
( ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p /nix/var/nix/profiles/system --rollback ( ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} nix-env -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --rollback
ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} /nix/var/nix/profiles/system/bin/switch-to-configuration switch ssh $NIX_SSHOPTS ${getAttr targetProperty (config.deployment)} ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system/bin/switch-to-configuration switch
rollbackSucceeded rollbackSucceeded
) )

View File

@ -100,7 +100,7 @@ in
if test -z "$source"; then if test -z "$source"; then
# If we can't find the program, fall back to the # If we can't find the program, fall back to the
# system profile. # system profile.
source=/nix/var/nix/profiles/default/bin/${program} source=${config.nixpkgs.config.nix.stateDir}/nix/profiles/default/bin/${program}
fi fi
cp ${setuidWrapper}/bin/setuid-wrapper ${wrapperDir}/${program} cp ${setuidWrapper}/bin/setuid-wrapper ${wrapperDir}/${program}

View File

@ -308,26 +308,26 @@ in
# Set up Nix. # Set up Nix.
mkdir -p /nix/etc/nix mkdir -p /nix/etc/nix
ln -sfn /etc/nix.conf /nix/etc/nix/nix.conf ln -sfn /etc/nix.conf /nix/etc/nix/nix.conf
chown root.nixbld /nix/store chown root.nixbld ${config.nixpkgs.config.nix.storeDir}
chmod 1775 /nix/store chmod 1775 ${config.nixpkgs.config.nix.storeDir}
# Nix initialisation. # Nix initialisation.
mkdir -m 0755 -p \ mkdir -m 0755 -p \
/nix/var/nix/gcroots \ ${config.nixpkgs.config.nix.stateDir}/nix/gcroots \
/nix/var/nix/temproots \ ${config.nixpkgs.config.nix.stateDir}/nix/temproots \
/nix/var/nix/manifests \ ${config.nixpkgs.config.nix.stateDir}/nix/manifests \
/nix/var/nix/userpool \ ${config.nixpkgs.config.nix.stateDir}/nix/userpool \
/nix/var/nix/profiles \ ${config.nixpkgs.config.nix.stateDir}/nix/profiles \
/nix/var/nix/db \ ${config.nixpkgs.config.nix.stateDir}/nix/db \
/nix/var/log/nix/drvs \ ${config.nixpkgs.config.nix.stateDir}/log/nix/drvs \
/nix/var/nix/channel-cache \ ${config.nixpkgs.config.nix.stateDir}/nix/channel-cache \
/nix/var/nix/chroots ${config.nixpkgs.config.nix.stateDir}/nix/chroots
mkdir -m 1777 -p /nix/var/nix/gcroots/per-user mkdir -m 1777 -p ${config.nixpkgs.config.nix.stateDir}/nix/gcroots/per-user
mkdir -m 1777 -p /nix/var/nix/profiles/per-user mkdir -m 1777 -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/per-user
mkdir -m 1777 -p /nix/var/nix/gcroots/tmp mkdir -m 1777 -p ${config.nixpkgs.config.nix.stateDir}/nix/gcroots/tmp
ln -sf /nix/var/nix/profiles /nix/var/nix/gcroots/ ln -sf ${config.nixpkgs.config.nix.stateDir}/nix/profiles ${config.nixpkgs.config.nix.stateDir}/nix/gcroots/
ln -sf /nix/var/nix/manifests /nix/var/nix/gcroots/ ln -sf ${config.nixpkgs.config.nix.stateDir}/nix/manifests ${config.nixpkgs.config.nix.stateDir}/nix/gcroots/
''; '';
}; };

View File

@ -13,7 +13,7 @@ let
{ {
options = { options = {
# This can be infered from the UPS model by looking at # This can be infered from the UPS model by looking at
# /nix/store/nut/share/driver.list # ${config.nixpkgs.config.nix.storeDir}/nut/share/driver.list
driver = mkOption { driver = mkOption {
type = types.uniq types.string; type = types.uniq types.string;
description = '' description = ''

View File

@ -133,7 +133,7 @@ in
Additionally you can specify the up/ down scripts by setting Additionally you can specify the up/ down scripts by setting
the up down properties. the up down properties.
Config lines up=/nix/store/xxx-up-script down=... Config lines up=${config.nixpkgs.config.nix.storeDir}/xxx-up-script down=...
will be appended to your configuration file automatically will be appended to your configuration file automatically
If you define at least one of up/down "script-security 2" will be If you define at least one of up/down "script-security 2" will be

View File

@ -78,7 +78,7 @@ in
If non-null, override the default login shell with the If non-null, override the default login shell with the
specified value. specified value.
''; '';
example = "/nix/store/xyz-bash-10.0/bin/bash10"; example = "${config.nixpkgs.config.nix.storeDir}/xyz-bash-10.0/bin/bash10";
}; };
srpKeyExchange = mkOption { srpKeyExchange = mkOption {

View File

@ -155,7 +155,7 @@ in
}; };
services.dbus.packages = services.dbus.packages =
[ "/nix/var/nix/profiles/default" [ "${config.nixpkgs.config.nix.stateDir}/nix/profiles/default"
config.system.path config.system.path
]; ];

View File

@ -339,7 +339,7 @@ let
# But do allow access to files in the store so that we don't have # But do allow access to files in the store so that we don't have
# to generate <Directory> clauses for every generated file that we # to generate <Directory> clauses for every generated file that we
# want to serve. # want to serve.
<Directory /nix/store> <Directory ${config.nixpkgs.config.nix.storeDir}>
Order allow,deny Order allow,deny
Allow from all Allow from all
</Directory> </Directory>

View File

@ -45,11 +45,11 @@ in
deployDir = mkOption { deployDir = mkOption {
description = "Location of the deployment files"; description = "Location of the deployment files";
default = "/nix/var/nix/profiles/default/server/default/deploy/"; default = "${config.nixpkgs.config.nix.stateDir}/nix/profiles/default/server/default/deploy/";
}; };
libUrl = mkOption { libUrl = mkOption {
default = "file:///nix/var/nix/profiles/default/server/default/lib"; default = "file://${config.nixpkgs.config.nix.stateDir}/nix/profiles/default/server/default/lib";
description = "Location where the shared library JARs are stored"; description = "Location where the shared library JARs are stored";
}; };

View File

@ -76,7 +76,7 @@ in
ln -sfn "$(readlink -f "$systemConfig")" /var/run/current-system ln -sfn "$(readlink -f "$systemConfig")" /var/run/current-system
# Prevent the current configuration from being garbage-collected. # Prevent the current configuration from being garbage-collected.
ln -sfn /var/run/current-system /nix/var/nix/gcroots/current-system ln -sfn /var/run/current-system ${config.nixpkgs.config.nix.stateDir}/nix/gcroots/current-system
''; '';
}; };

View File

@ -217,7 +217,7 @@ let
# The initrd only has to mount / or any FS marked as necessary for # The initrd only has to mount / or any FS marked as necessary for
# booting (such as the FS containing /nix/store, or an FS needed for # booting (such as the FS containing ${config.nixpkgs.config.nix.storeDir}, or an FS needed for
# mounting /, like / on a loopback). # mounting /, like / on a loopback).
fileSystems = filter fileSystems = filter
(fs: fs.mountPoint == "/" || fs.neededForBoot) (fs: fs.mountPoint == "/" || fs.neededForBoot)

View File

@ -10,7 +10,7 @@ let
environment.etc = mkOption { environment.etc = mkOption {
default = []; default = [];
example = [ example = [
{ source = "/nix/store/.../etc/dir/file.conf.example"; { source = "${config.nixpkgs.config.nix.storeDir}/.../etc/dir/file.conf.example";
target = "dir/file.conf"; target = "dir/file.conf";
mode = "0440"; mode = "0440";
} }

View File

@ -112,7 +112,7 @@ with pkgs.lib;
# (For instance, when applied to a bind-mount it # (For instance, when applied to a bind-mount it
# unmounts the target of the bind-mount.) !!! But # unmounts the target of the bind-mount.) !!! But
# we should use `-f' for NFS. # we should use `-f' for NFS.
if [ "$mp" != / -a "$mp" != /nix -a "$mp" != /nix/store ]; then if [ "$mp" != / -a "$mp" != /nix -a "$mp" != ${config.nixpkgs.config.nix.storeDir} ]; then
if umount -n "$mp"; then success=1; tryAgain=1; fi if umount -n "$mp"; then success=1; tryAgain=1; fi
fi fi

View File

@ -34,9 +34,9 @@ with pkgs.lib;
# Copy all paths in the closure to the filesystem. # Copy all paths in the closure to the filesystem.
storePaths=$(perl ${pkgs.pathsFromGraph} /tmp/xchg/closure) storePaths=$(perl ${pkgs.pathsFromGraph} /tmp/xchg/closure)
mkdir -p /mnt/nix/store mkdir -p /mnt${config.nixpkgs.config.nix.storeDir}
echo "copying everything (will take a while)..." echo "copying everything (will take a while)..."
cp -prd $storePaths /mnt/nix/store/ cp -prd $storePaths /mnt${config.nixpkgs.config.nix.storeDir}/
# Register the paths in the Nix database. # Register the paths in the Nix database.
printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \ printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \
@ -44,7 +44,7 @@ with pkgs.lib;
# Create the system profile to allow nixos-rebuild to work. # Create the system profile to allow nixos-rebuild to work.
chroot /mnt ${config.environment.nix}/bin/nix-env \ chroot /mnt ${config.environment.nix}/bin/nix-env \
-p /nix/var/nix/profiles/system --set ${config.system.build.toplevel} -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --set ${config.system.build.toplevel}
# `nixos-rebuild' requires an /etc/NIXOS. # `nixos-rebuild' requires an /etc/NIXOS.
mkdir -p /mnt/etc mkdir -p /mnt/etc

View File

@ -41,8 +41,8 @@ with pkgs.lib;
# Copy all paths in the closure to the filesystem. # Copy all paths in the closure to the filesystem.
storePaths=$(perl ${pkgs.pathsFromGraph} /tmp/xchg/closure) storePaths=$(perl ${pkgs.pathsFromGraph} /tmp/xchg/closure)
mkdir -p /mnt/nix/store mkdir -p /mnt${config.nixpkgs.config.nix.storeDir}
${pkgs.rsync}/bin/rsync -av $storePaths /mnt/nix/store/ ${pkgs.rsync}/bin/rsync -av $storePaths /mnt${config.nixpkgs.config.nix.storeDir}/
# Register the paths in the Nix database. # Register the paths in the Nix database.
printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \ printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \
@ -50,7 +50,7 @@ with pkgs.lib;
# Create the system profile to allow nixos-rebuild to work. # Create the system profile to allow nixos-rebuild to work.
chroot /mnt ${config.environment.nix}/bin/nix-env \ chroot /mnt ${config.environment.nix}/bin/nix-env \
-p /nix/var/nix/profiles/system --set ${config.system.build.toplevel} -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles/system --set ${config.system.build.toplevel}
# `nixos-rebuild' requires an /etc/NIXOS. # `nixos-rebuild' requires an /etc/NIXOS.
mkdir -p /mnt/etc mkdir -p /mnt/etc

View File

@ -222,7 +222,7 @@ let
# Install GRUB and generate the GRUB boot menu. # Install GRUB and generate the GRUB boot menu.
touch /etc/NIXOS touch /etc/NIXOS
mkdir -p /nix/var/nix/profiles mkdir -p ${config.nixpkgs.config.nix.stateDir}/nix/profiles
${config.system.build.toplevel}/bin/switch-to-configuration boot ${config.system.build.toplevel}/bin/switch-to-configuration boot
umount /boot umount /boot
@ -276,11 +276,11 @@ in
chmod 1777 $targetRoot/tmp chmod 1777 $targetRoot/tmp
mkdir -p $targetRoot/boot mkdir -p $targetRoot/boot
mount -o remount,ro $targetRoot/nix/store mount -o remount,ro $targetRoot${config.nixpkgs.config.nix.storeDir}
${optionalString cfg.writableStore '' ${optionalString cfg.writableStore ''
mkdir /mnt-store-tmpfs mkdir /mnt-store-tmpfs
mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs mount -t tmpfs -o "mode=755" none /mnt-store-tmpfs
mount -t aufs -o dirs=/mnt-store-tmpfs=rw:$targetRoot/nix/store=rr none $targetRoot/nix/store mount -t aufs -o dirs=/mnt-store-tmpfs=rw:$targetRoot${config.nixpkgs.config.nix.storeDir}=rr none $targetRoot${config.nixpkgs.config.nix.storeDir}
''} ''}
''; '';
@ -314,7 +314,7 @@ in
[ { mountPoint = "/"; [ { mountPoint = "/";
device = "/dev/vda"; device = "/dev/vda";
} }
{ mountPoint = "/nix/store"; { mountPoint = "${config.nixpkgs.config.nix.storeDir}";
device = "//10.0.2.4/store"; device = "//10.0.2.4/store";
fsType = "cifs"; fsType = "cifs";
options = "guest,sec=none,noperm,noacl"; options = "guest,sec=none,noperm,noacl";