diff --git a/boot/boot.sh b/boot/boot.sh index 3f17ea32ac00..191c081c7539 100644 --- a/boot/boot.sh +++ b/boot/boot.sh @@ -1,6 +1,6 @@ #! @bash@/bin/sh -e -export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin +. @out@/bin/env.sh echo "--- Nix ---" @@ -16,4 +16,16 @@ mount -n -o remount,rw /dev/root / echo "mounting /mnt/host..." mount -n -t hostfs none /mnt/host +echo "setting up hostname..." +hostname uml + +echo "enabling loopback interface..." +ifconfig lo 127.0.0.1 + +echo "enabling ethernet interface..." +ifconfig eth0 $(cat /etc/networking/local-ip) up + +echo "setting up routing table..." +route add default gw $(cat /etc/networking/gateway-ip) + echo "boot done." diff --git a/boot/builder.sh b/boot/builder.sh index 902940dc9075..8748d8875e5d 100755 --- a/boot/builder.sh +++ b/boot/builder.sh @@ -5,7 +5,7 @@ mkdir $out mkdir $out/bin -for i in $boot $halt $login; do +for i in $boot $halt $login $env; do dst=$out/bin/$(basename $i | cut -c34-) sed \ -e "s^@bash\@^$bash^g" \ @@ -14,7 +14,9 @@ for i in $boot $halt $login; do -e "s^@utillinux\@^$utillinux^g" \ -e "s^@sysvinit\@^$sysvinit^g" \ -e "s^@e2fsprogs\@^$e2fsprogs^g" \ + -e "s^@nettools\@^$nettools^g" \ -e "s^@nix\@^$nix^g" \ + -e "s^@out\@^$out^g" \ < $i > $dst chmod +x $dst -done \ No newline at end of file +done diff --git a/boot/default.nix b/boot/default.nix index 8f6820c5e4ac..6ecd30758b8a 100644 --- a/boot/default.nix +++ b/boot/default.nix @@ -1,4 +1,5 @@ -{stdenv, bash, coreutils, findutils, utillinux, sysvinit, e2fsprogs, nix}: +{ stdenv, bash, coreutils, findutils, utillinux, sysvinit, e2fsprogs +, nettools, nix}: derivation { name = "boot"; @@ -7,5 +8,7 @@ derivation { boot = ./boot.sh; halt = ./halt.sh; login = ./login.sh; - inherit stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix; + env = ./env.sh; + inherit stdenv bash coreutils findutils utillinux sysvinit + e2fsprogs nettools nix; } diff --git a/boot/env.sh b/boot/env.sh new file mode 100644 index 000000000000..75504da38b7d --- /dev/null +++ b/boot/env.sh @@ -0,0 +1 @@ +export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin:@nettools@/bin:@nettools@/sbin: diff --git a/boot/halt.sh b/boot/halt.sh index 19e890458547..8ec9e64535be 100644 --- a/boot/halt.sh +++ b/boot/halt.sh @@ -1,6 +1,6 @@ #! @bash@/bin/sh -e -export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin +. @out@/bin/env.sh echo "remounting / read-only..." mount -n -o remount,rw /dev/root / || echo "(failed)" # ignore errors diff --git a/boot/login.sh b/boot/login.sh index 74e14b64de6d..9222b2aba132 100644 --- a/boot/login.sh +++ b/boot/login.sh @@ -1,11 +1,11 @@ #! @bash@/bin/sh -e +. @out@/bin/env.sh + tty=$1 exec < $tty > $tty 2>&1 -export PATH=@nix@/bin:@bash@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@sysvinit@/bin:@sysvinit@/sbin:@e2fsprogs@/bin:@e2fsprogs@/sbin - echo echo "=== Welcome to Nix! ===" diff --git a/fill-disk.sh b/fill-disk.sh index b50088e16e08..6dc0449f73e1 100755 --- a/fill-disk.sh +++ b/fill-disk.sh @@ -69,7 +69,16 @@ echo "id:2:initdefault:" >> $root/etc/inittab echo "si::bootwait:$bootPath/bin/boot.sh" >> $root/etc/inittab echo "ht:06:wait:$bootPath/bin/halt.sh" >> $root/etc/inittab echo "1:2345:respawn:$bootPath/bin/login.sh /dev/ttys/0" >> $root/etc/inittab -echo "2:2345:respawn:$bootPath/bin/login.sh /dev/ttys/1" >> $root/etc/inittab +#echo "2:2345:respawn:$bootPath/bin/login.sh /dev/ttys/1" >> $root/etc/inittab + +echo setting up networking information... +make_dir 00755 /etc/networking +echo 192.168.150.1 > $root/etc/networking/local-ip +echo 192.168.150.3 > $root/etc/networking/gateway-ip +cp /etc/resolv.conf $root/etc +rm -f $root/etc/hosts +echo "127.0.0.1 localhost" >> $root/etc/hosts +echo "192.168.150.1 uml" >> $root/etc/hosts echo unmounting... umount $root diff --git a/pkgs.nix b/pkgs.nix index d0df974d9024..3b6fcb7646e1 100644 --- a/pkgs.nix +++ b/pkgs.nix @@ -1,9 +1,10 @@ rec { inherit (import pkgs/system/i686-linux.nix) - stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix; + stdenv bash coreutils findutils utillinux sysvinit e2fsprogs + nettools nix; - boot = (import ./boot) - {inherit stdenv bash coreutils findutils utillinux sysvinit e2fsprogs nix;}; + boot = (import ./boot) {inherit stdenv bash coreutils findutils + utillinux sysvinit e2fsprogs nettools nix;}; everything = [boot sysvinit]; } diff --git a/run.sh b/run.sh index 5f6a9e34fe98..9a51834e0d2f 100755 --- a/run.sh +++ b/run.sh @@ -2,4 +2,6 @@ image=/tmp/disk.img -linux ubd0="$image" mem=256M init="/init" +linux ubd0="$image" mem=256M \ + eth0=tuntap,tap4,,192.168.150.1 \ + init="/init"