[Nix-dev] installing nixos change request
Marc Weber
marco-oweber at gmx.de
Fri Sep 25 18:27:54 CEST 2009
Hi,
I think that we can simplify nixos-install a little bit:
What it does:
Always looking at everything from outside of the chroot environment)
It runs nix-env -A system to install the system based on
/mnt/mnt/nixos/* sources. /mnt/mnt is bind mounted from /.
After that has been doen (your system may be up and running) it starts
copying over the /etc/nixos/* sources to /mnt/etc/nixos/* no matter
whether you like it to do so?
I don't think this behaviour is intuitive.
I'd propose:
Split nixos-install into two scripts:
nixos-prepare-install:
if configuration.nix doesn't exist yet run:
nixos-hardware-scan > /mnt/etc/nixos/configuration.nix
if /mnt/etc/nixos/{nixpkgs,nixos} don't exist copy them
If they do skip unless --update-sources was given.
Print a warning in that case "If you want me to update
/etc/nixos/{nixos,nixpkgs} use --update-sources"
nixos-install:
do everything else. Verify that sources exist and install the system
Why is this easier to understand?
nixos-install will use the sources which are present on /mnt to install
the system. So if you want to use custom sources for some reason you put
them in place and are done.
If you just want to rebuild your system because you used the wrong video
driver or whatever.. You can just do that without removing backups
afterwards.
Someone who knows the current way will get a notice:
"No nixos sources found on /mnt. Did you forget to run nixos-prepare-install ?"
How do you like this proposal?
I'd also like to clean up the makeBackupAndCopy sources implementation
so that it looks like this:
# Make a backup of the old NixOS/Nixpkgs sources.
echo "copying NixOS/Nixpkgs sources to /etc/nixos...."
backupTimestamp=$(date "+%Y%m%d%H%M%S")
# if source exists backup target then copy source to target
backupThenCopy(){
source="$1"
target="$2"
[ -e "$source" ] || return
if test -e "$target"; then
mv "$target" "$target.backup-$backupTimestamp"
fi
cp -prd "$source" "target"
}
backupThenCopy "$NIXOS" "$mountPoint/etc/nixos/nixos"
backupThenCopy /etc/nixos/nixpkgs "$mountPoint/etc/nixos/nixpkgs"
backupThenCopy /etc/nixos/services "$targetServices"
Why is this line used ?
NIXOS=$(readlink -f "$NIXOS")
It was used in the past when nixos was passed as arg2 or such.
So I would remove it now.
Marc Weber
More information about the nix-dev
mailing list