From 36614ff3e290a9330dd8e29bdc6cc38ede1e7001 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 31 Aug 2014 09:18:13 -0700 Subject: Revert "Revert "Merge pull request #2449 from wkennington/master.grub"" This reverts commit 94205f5f21c4d9942bb4205c06229438051b6853. Conflicts: nixos/modules/system/boot/loader/grub/install-grub.pl --- .../installer/tools/nixos-generate-config.pl | 21 +++++++++++++++++++++ nixos/modules/installer/tools/tools.nix | 1 + nixos/modules/installer/virtualbox-demo.nix | 3 +++ 3 files changed, 25 insertions(+) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 66a8152a3a6c..73dd87cef5cf 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -20,6 +20,13 @@ sub uniq { return @res; } +sub runCommand { + my ($cmd) = @_; + open FILE, "$cmd 2>/dev/null |" or die "Failed to execute: $cmd\n"; + my @ret = ; + close FILE; + return ($?, @ret); +} # Process the command line. my $outDir = "/etc/nixos"; @@ -337,6 +344,20 @@ EOF } } + # Is this a btrfs filesystem? + if ($fsType eq "btrfs") { + my ($status, @info) = runCommand("btrfs subvol show $rootDir$mountPoint"); + if ($status != 0) { + die "Failed to retreive subvolume info for $mountPoint"; + } + my @subvols = join("", @info) =~ m/Name:[ \t\n]*([^ \t\n]*)/; + if ($#subvols > 0) { + die "Btrfs subvol name for $mountPoint listed multiple times in mount\n" + } elsif ($#subvols == 0) { + push @extraOptions, "subvol=$subvols[0]"; + } + } + # Emit the filesystem. $fileSystems .= < Date: Sat, 30 Aug 2014 15:33:44 -0700 Subject: nixos/generate-config: Support detecting nested subvolumes --- .../installer/tools/nixos-generate-config.pl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 73dd87cef5cf..ab5b2954f6b5 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -346,15 +346,25 @@ EOF # Is this a btrfs filesystem? if ($fsType eq "btrfs") { - my ($status, @info) = runCommand("btrfs subvol show $rootDir$mountPoint"); + my ($status, @id_info) = runCommand("btrfs subvol show $rootDir$mountPoint"); if ($status != 0) { - die "Failed to retreive subvolume info for $mountPoint"; + die "Failed to retreive subvolume info for $mountPoint\n"; } - my @subvols = join("", @info) =~ m/Name:[ \t\n]*([^ \t\n]*)/; - if ($#subvols > 0) { + my @ids = join("", @id_info) =~ m/Object ID:[ \t\n]*([^ \t\n]*)/; + if ($#ids > 0) { die "Btrfs subvol name for $mountPoint listed multiple times in mount\n" - } elsif ($#subvols == 0) { - push @extraOptions, "subvol=$subvols[0]"; + } elsif ($#ids == 0) { + my ($status, @path_info) = runCommand("btrfs subvol list $rootDir$mountPoint"); + if ($status != 0) { + die "Failed to find $mountPoint subvolume id from btrfs\n"; + } + my @paths = join("", @path_info) =~ m/ID $ids[0] [^\n]* path ([^\n]*)/; + if ($#paths > 0) { + die "Btrfs returned multiple paths for a single subvolume id, mountpoint $mountPoint\n"; + } elsif ($#paths != 0) { + die "Btrfs did not return a path for the subvolume at $mountPoint\n"; + } + push @extraOptions, "subvol=$paths[0]"; } } -- cgit 1.4.1 From 87b6232f3a4c9903a432fffd8bc627f2c445a10d Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 30 Aug 2014 16:30:56 -0700 Subject: nixos/generate-config: Don't interpret btrfs subvols as bind mounts --- nixos/modules/installer/tools/nixos-generate-config.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index ab5b2954f6b5..c6f499b82506 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -22,7 +22,7 @@ sub uniq { sub runCommand { my ($cmd) = @_; - open FILE, "$cmd 2>/dev/null |" or die "Failed to execute: $cmd\n"; + open FILE, "$cmd 2>&1 |" or die "Failed to execute: $cmd\n"; my @ret = ; close FILE; return ($?, @ret); @@ -311,10 +311,13 @@ foreach my $fs (read_file("/proc/self/mountinfo")) { # Maybe this is a bind-mount of a filesystem we saw earlier? if (defined $fsByDev{$fields[2]}) { - my $path = $fields[3]; $path = "" if $path eq "/"; - my $base = $fsByDev{$fields[2]}; - $base = "" if $base eq "/"; - $fileSystems .= < Date: Wed, 3 Sep 2014 09:26:44 -0700 Subject: nixos/iso-image: Fix grub-mkimage requiring a prefix --- nixos/modules/installer/cd-dvd/iso-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 623cfdedd269..22f31c460802 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -11,7 +11,7 @@ let # The Grub image. grubImage = pkgs.runCommand "grub_eltorito" {} '' - ${pkgs.grub2}/bin/grub-mkimage -O i386-pc -o tmp biosdisk iso9660 help linux linux16 chain png jpeg echo gfxmenu reboot + ${pkgs.grub2}/bin/grub-mkimage -p /boot/grub -O i386-pc -o tmp biosdisk iso9660 help linux linux16 chain png jpeg echo gfxmenu reboot cat ${pkgs.grub2}/lib/grub/*/cdboot.img tmp > $out ''; # */ -- cgit 1.4.1 From 2e97c06999db2a5dd56b3e105d8f57ad2013ff51 Mon Sep 17 00:00:00 2001 From: Domen Kožar Date: Wed, 3 Sep 2014 22:06:54 +0200 Subject: nixos-option: enable all flags by default and make output a bit readable cc @nbp --- nixos/doc/manual/man-nixos-option.xml | 66 ++++-------------------- nixos/modules/installer/tools/nixos-option.sh | 74 ++++++++++----------------- 2 files changed, 36 insertions(+), 104 deletions(-) (limited to 'nixos/modules/installer') diff --git a/nixos/doc/manual/man-nixos-option.xml b/nixos/doc/manual/man-nixos-option.xml index 7952847d4db5..554b29691805 100644 --- a/nixos/doc/manual/man-nixos-option.xml +++ b/nixos/doc/manual/man-nixos-option.xml @@ -17,11 +17,6 @@ nixos-option - - - - - option.name @@ -31,50 +26,13 @@ This command evaluates the configuration specified in /etc/nixos/configuration.nix and returns the properties -of the option name given as argument. By default, it returns the value of -the option. +of the option name given as argument. When the option name is not an option, the command prints the list of attributes contained in the attribute set. -Options - -This command accepts the following options: - - - - - , - - Returns the value of the option. This is the default operation - if no other options are defined. - - - - - , - - Return the default value, the example and the description of the - option when available. - - - - - , - - Return the locations where the option is declared and where it - is defined. This is extremely useful to find sources of errors in - your configuration. - - - - - - - - Environment @@ -103,27 +61,21 @@ grub initScript $ nixos-option boot.loader.grub.enable -true +Value: +true -Prints option information: +Default: +true -$ nixos-option -d networking.hostName -Default: "nixos" Description: -The name of the machine. Leave it empty if you want to obtain -it from a DHCP server (if using DHCP). - -Find the locations which are declaring and defining an option: +Whether to enable the GNU GRUB boot loader. -$ nixos-option -l hardware.firmware Declared by: - /mnt/data/nix-sources/nixos/modules/services/hardware/udev.nix + "/path/to/nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix" Defined by: - /path/to/nixpkgs/nixos/modules/system/boot/kernel.nix - /path/to/nixpkgs/nixos/modules/hardware/network/rt73.nix - /path/to/nixpkgs/nixos/modules/hardware/network/intel-3945abg.nix - /path/to/nixpkgs/nixos/modules/hardware/network/intel-2200bg.nix + "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix" + diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index edc94d732084..d995787c76fe 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -11,9 +11,6 @@ usage () { # Process Arguments # ##################### -desc=false -defs=false -value=false xml=false verbose=false @@ -24,14 +21,11 @@ for arg; do if test -z "$argfun"; then case $arg in -*) - longarg="" sarg="$arg" + longarg="" while test "$sarg" != "-"; do case $sarg in --*) longarg=$arg; sarg="--";; - -d*) longarg="$longarg --description";; - -v*) longarg="$longarg --value";; - -l*) longarg="$longarg --lookup";; -*) usage;; esac # remove the first letter option @@ -42,9 +36,6 @@ for arg; do esac for larg in $longarg; do case $larg in - --description) desc=true;; - --value) value=true;; - --lookup) defs=true;; --xml) xml=true;; --verbose) verbose=true;; --help) usage;; @@ -67,16 +58,6 @@ for arg; do fi done -if $xml; then - value=true - desc=true - defs=true -fi - -if ! $defs && ! $desc; then - value=true -fi - if $verbose; then set -x else @@ -95,8 +76,7 @@ evalAttr(){ local prefix="$1" local strict="$2" local suffix="$3" - echo "(import {}).$prefix${option:+.$option}${suffix:+.$suffix}" | - evalNix ${strict:+--strict} + echo "(import {}).$prefix${option:+.$option}${suffix:+.$suffix}" | evalNix ${strict:+--strict} } evalOpt(){ @@ -189,35 +169,35 @@ EOF fi if test "$(evalOpt "_type" 2> /dev/null)" = '"option"'; then - $value && evalCfg 1 - - if $desc; then - $value && echo; - - if default=$(evalOpt "default" - 2> /dev/null); then - echo "Default: $default" - else - echo "Default: " - fi - if example=$(evalOpt "example" - 2> /dev/null); then - echo "Example: $example" - fi - echo "Description:" - eval printf $(evalOpt "description") + echo "Value:" + evalCfg 1 + + echo + + echo "Default:" + if default=$(evalOpt "default" - 2> /dev/null); then + echo "$default" + else + echo "" + fi + echo + if example=$(evalOpt "example" - 2> /dev/null); then + echo "Example: $example" fi + echo "Description:" + echo + eval printf $(evalOpt "description") - if $defs; then - $desc || $value && echo; + echo $desc; - printPath () { echo " $1"; } + printPath () { echo " $1"; } - echo "Declared by:" - nixMap printPath "$(findSources "declarations")" - echo "" - echo "Defined by:" - nixMap printPath "$(findSources "files")" - echo "" - fi + echo "Declared by:" + nixMap printPath "$(findSources "declarations")" + echo + echo "Defined by:" + nixMap printPath "$(findSources "files")" + echo else # echo 1>&2 "Warning: This value is not an option." -- cgit 1.4.1 From 59ad713288134ba5441edfa941792a6652a1e5c2 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 3 Sep 2014 23:10:40 +0200 Subject: nixos-install: set umask 0022 --- nixos/modules/installer/tools/nixos-install.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh index 86952486ade0..c633cf4a839e 100644 --- a/nixos/modules/installer/tools/nixos-install.sh +++ b/nixos/modules/installer/tools/nixos-install.sh @@ -7,6 +7,9 @@ # * nix-env -p /nix/var/nix/profiles/system -i # * install the boot loader +# Ensure a consistent umask. +umask 0022 + # Re-exec ourselves in a private mount namespace so that our bind # mounts get cleaned up automatically. if [ "$(id -u)" = 0 ]; then -- cgit 1.4.1 From a1ded5c20e42c463686aa39ed8f0a3e7de8858d9 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 3 Sep 2014 23:11:37 +0200 Subject: nixos-install: use absolute path when running passwd in chroot --- nixos/modules/installer/tools/nixos-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh index c633cf4a839e..bd334c2a3cb4 100644 --- a/nixos/modules/installer/tools/nixos-install.sh +++ b/nixos/modules/installer/tools/nixos-install.sh @@ -246,7 +246,7 @@ chroot $mountPoint /nix/var/nix/profiles/system/activate # Ask the user to set a root password. if [ -t 0 ] ; then echo "setting root password..." - chroot $mountPoint passwd + chroot $mountPoint /var/setuid-wrappers/passwd fi -- cgit 1.4.1