From 3be9d4610f6bd9e62592846a5e4ee2a6ccd25511 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Tue, 30 Jan 2018 11:21:31 +0200 Subject: nixos/tests: Drop unnecessary qemu-flags.nix include None of these files are using anything from there. --- nixos/tests/boot.nix | 1 - nixos/tests/cloud-init.nix | 1 - nixos/tests/ec2.nix | 1 - nixos/tests/installer.nix | 1 - nixos/tests/kubernetes/base.nix | 1 - 5 files changed, 5 deletions(-) (limited to 'nixos') diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix index 69ab4755e444..fc52cd09f209 100644 --- a/nixos/tests/boot.nix +++ b/nixos/tests/boot.nix @@ -1,7 +1,6 @@ { system ? builtins.currentSystem }: with import ../lib/testing.nix { inherit system; }; -with import ../lib/qemu-flags.nix; with pkgs.lib; let diff --git a/nixos/tests/cloud-init.nix b/nixos/tests/cloud-init.nix index c0add7eff360..2a258e4bff54 100644 --- a/nixos/tests/cloud-init.nix +++ b/nixos/tests/cloud-init.nix @@ -1,7 +1,6 @@ { system ? builtins.currentSystem }: with import ../lib/testing.nix { inherit system; }; -with import ../lib/qemu-flags.nix; with pkgs.lib; let diff --git a/nixos/tests/ec2.nix b/nixos/tests/ec2.nix index 4ec7e56cc6cb..f585fa2ec237 100644 --- a/nixos/tests/ec2.nix +++ b/nixos/tests/ec2.nix @@ -1,7 +1,6 @@ { system ? builtins.currentSystem }: with import ../lib/testing.nix { inherit system; }; -with import ../lib/qemu-flags.nix; with pkgs.lib; let diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 90ac5b933f32..637cbb45709d 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -1,7 +1,6 @@ { system ? builtins.currentSystem }: with import ../lib/testing.nix { inherit system; }; -with import ../lib/qemu-flags.nix; with pkgs.lib; let diff --git a/nixos/tests/kubernetes/base.nix b/nixos/tests/kubernetes/base.nix index acf2e0250819..f3b930b630ba 100644 --- a/nixos/tests/kubernetes/base.nix +++ b/nixos/tests/kubernetes/base.nix @@ -1,7 +1,6 @@ { system ? builtins.currentSystem }: with import ../../lib/testing.nix { inherit system; }; -with import ../../lib/qemu-flags.nix; with pkgs.lib; let -- cgit 1.4.1 From 1ce13804978ef361511014d8fc8e4d358de72dfa Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Tue, 30 Jan 2018 11:22:41 +0200 Subject: nixos/qemu-flags: Take a 'pkgs' parameter I'm gonna use it in the next commit. --- nixos/lib/build-vms.nix | 2 +- nixos/lib/qemu-flags.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index 1a17a080ba45..4685fe6914a2 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -3,7 +3,7 @@ let pkgs = import ../.. { inherit system config; }; in with pkgs.lib; -with import ../lib/qemu-flags.nix; +with import ../lib/qemu-flags.nix { inherit pkgs; }; rec { diff --git a/nixos/lib/qemu-flags.nix b/nixos/lib/qemu-flags.nix index de355b08918c..172da555ba7e 100644 --- a/nixos/lib/qemu-flags.nix +++ b/nixos/lib/qemu-flags.nix @@ -1,4 +1,5 @@ # QEMU flags shared between various Nix expressions. +{ pkgs }: { -- cgit 1.4.1 From 8e83158f124f6c8d5583a32102f281bde10769cd Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Tue, 30 Jan 2018 11:28:26 +0200 Subject: nixos/qemu: Deduplicate QEMU serialDevice into qemu-flags.nix --- nixos/lib/qemu-flags.nix | 4 ++++ nixos/modules/testing/test-instrumentation.nix | 19 ++++++++----------- nixos/modules/virtualisation/qemu-vm.nix | 8 ++------ 3 files changed, 14 insertions(+), 17 deletions(-) (limited to 'nixos') diff --git a/nixos/lib/qemu-flags.nix b/nixos/lib/qemu-flags.nix index 172da555ba7e..fb00c3183fbf 100644 --- a/nixos/lib/qemu-flags.nix +++ b/nixos/lib/qemu-flags.nix @@ -8,4 +8,8 @@ "-net vde,vlan=${toString nic},sock=$QEMU_VDE_SOCKET_${toString net}" ]; + qemuSerialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0" + else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0" + else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'"; + } diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 9b4136223c0f..41dec2af9ed4 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -4,13 +4,10 @@ { config, lib, pkgs, ... }: with lib; +with import ../../lib/qemu-flags.nix { inherit pkgs; }; let kernel = config.boot.kernelPackages.kernel; - # FIXME: figure out a common place for this instead of copy pasting - serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0" - else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0" - else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'"; in { @@ -28,8 +25,8 @@ in systemd.services.backdoor = { wantedBy = [ "multi-user.target" ]; - requires = [ "dev-hvc0.device" "dev-${serialDevice}.device" ]; - after = [ "dev-hvc0.device" "dev-${serialDevice}.device" ]; + requires = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ]; + after = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ]; script = '' export USER=root @@ -46,7 +43,7 @@ in cd /tmp exec < /dev/hvc0 > /dev/hvc0 - while ! exec 2> /dev/${serialDevice}; do sleep 0.1; done + while ! exec 2> /dev/${qemuSerialDevice}; do sleep 0.1; done echo "connecting to host..." >&2 stty -F /dev/hvc0 raw -echo # prevent nl -> cr/nl conversion echo @@ -55,10 +52,10 @@ in serviceConfig.KillSignal = "SIGHUP"; }; - # Prevent agetty from being instantiated on ${serialDevice}, since it - # interferes with the backdoor (writes to ${serialDevice} will randomly fail + # Prevent agetty from being instantiated on the serial device, since it + # interferes with the backdoor (writes to it will randomly fail # with EIO). Likewise for hvc0. - systemd.services."serial-getty@${serialDevice}".enable = false; + systemd.services."serial-getty@${qemuSerialDevice}".enable = false; systemd.services."serial-getty@hvc0".enable = false; boot.initrd.preDeviceCommands = @@ -94,7 +91,7 @@ in # Panic if an error occurs in stage 1 (rather than waiting for # user intervention). boot.kernelParams = - [ "console=${serialDevice}" "panic=1" "boot.panic_on_fail" ]; + [ "console=${qemuSerialDevice}" "panic=1" "boot.panic_on_fail" ]; # `xwininfo' is used by the test driver to query open windows. environment.systemPackages = [ pkgs.xorg.xwininfo ]; diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 26f7945a4eda..c52f637604ae 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -10,6 +10,7 @@ { config, lib, pkgs, ... }: with lib; +with import ../../lib/qemu-flags.nix { inherit pkgs; }; let @@ -21,11 +22,6 @@ let "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host"; }.${pkgs.stdenv.system}; - # FIXME: figure out a common place for this instead of copy pasting - serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0" - else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0" - else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'"; - vmName = if config.networking.hostName == "" then "noname" @@ -34,7 +30,7 @@ let cfg = config.virtualisation; qemuGraphics = if cfg.graphics then "" else "-nographic"; - kernelConsole = if cfg.graphics then "" else "console=${serialDevice}"; + kernelConsole = if cfg.graphics then "" else "console=${qemuSerialDevice}"; ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ]; # Shell script to start the VM. -- cgit 1.4.1 From 71631a922b4005497fe3b93fdfe5899e2f6d7a2c Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Wed, 6 Dec 2017 20:26:22 +0200 Subject: runInLinuxVM: Use QEMU command line that works on other architectures ... by moving the existing definition to qemu-flags.nix and reusing that. --- nixos/lib/qemu-flags.nix | 6 ++++++ nixos/modules/virtualisation/qemu-vm.nix | 8 +------- pkgs/build-support/vm/default.nix | 5 +---- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'nixos') diff --git a/nixos/lib/qemu-flags.nix b/nixos/lib/qemu-flags.nix index fb00c3183fbf..fcdcbf1b0077 100644 --- a/nixos/lib/qemu-flags.nix +++ b/nixos/lib/qemu-flags.nix @@ -12,4 +12,10 @@ else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0" else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'"; + qemuBinary = qemuPkg: { + "i686-linux" = "${qemuPkg}/bin/qemu-kvm"; + "x86_64-linux" = "${qemuPkg}/bin/qemu-kvm -cpu kvm64"; + "armv7l-linux" = "${qemuPkg}/bin/qemu-system-arm -enable-kvm -machine virt -cpu host"; + "aarch64-linux" = "${qemuPkg}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host"; + }.${pkgs.stdenv.system} or (throw "Unknown QEMU binary for '${pkgs.stdenv.system}'"); } diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index c52f637604ae..13d0eb7de5c2 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -15,12 +15,6 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; let qemu = config.system.build.qemu or pkgs.qemu_test; - qemuKvm = { - "i686-linux" = "${qemu}/bin/qemu-kvm"; - "x86_64-linux" = "${qemu}/bin/qemu-kvm -cpu kvm64"; - "armv7l-linux" = "${qemu}/bin/qemu-system-arm -enable-kvm -machine virt -cpu host"; - "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host"; - }.${pkgs.stdenv.system}; vmName = if config.networking.hostName == "" @@ -79,7 +73,7 @@ let '')} # Start QEMU. - exec ${qemuKvm} \ + exec ${qemuBinary qemu} \ -name ${vmName} \ -m ${toString config.virtualisation.memorySize} \ -smp ${toString config.virtualisation.cores} \ diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index cf6e7cc1fe4e..d599f9bbb65f 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -23,8 +23,6 @@ rec { patches = [ ../../../nixos/modules/virtualisation/azure-qemu-220-no-etc-install.patch ]; }); - qemuProg = "${qemu}/bin/qemu-kvm"; - modulesClosure = makeModulesClosure { inherit kernel rootModules; @@ -204,8 +202,7 @@ rec { qemuCommandLinux = '' - ${qemuProg} \ - ${lib.optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \ + ${qemuBinary qemu} \ -nographic -no-reboot \ -device virtio-rng-pci \ -virtfs local,path=${storeDir},security_model=none,mount_tag=store \ -- cgit 1.4.1 From dc52fc6dda00c4f3e275e56a5f4f0386260e4063 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Wed, 31 Jan 2018 09:40:15 +0800 Subject: aria2 (nixos): actually load the module Fixes #33991 --- nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/aria2.nix | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 51f9917b192c..1942cca23d6e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -425,6 +425,7 @@ ./services/network-filesystems/yandex-disk.nix ./services/network-filesystems/xtreemfs.nix ./services/networking/amuled.nix + ./services/networking/aria2.nix ./services/networking/asterisk.nix ./services/networking/atftpd.nix ./services/networking/avahi-daemon.nix diff --git a/nixos/modules/services/networking/aria2.nix b/nixos/modules/services/networking/aria2.nix index ad4ac9bf45e3..df9c92db2e54 100644 --- a/nixos/modules/services/networking/aria2.nix +++ b/nixos/modules/services/networking/aria2.nix @@ -10,9 +10,9 @@ let settingsDir = "${homeDir}"; sessionFile = "${homeDir}/aria2.session"; downloadDir = "${homeDir}/Downloads"; - + rangesToStringList = map (x: builtins.toString x.from +"-"+ builtins.toString x.to); - + settingsFile = pkgs.writeText "aria2.conf" '' dir=${cfg.downloadDir} @@ -110,12 +110,12 @@ in mkdir -m 0770 -p "${homeDir}" chown aria2:aria2 "${homeDir}" if [[ ! -d "${config.services.aria2.downloadDir}" ]] - then + then mkdir -m 0770 -p "${config.services.aria2.downloadDir}" chown aria2:aria2 "${config.services.aria2.downloadDir}" fi if [[ ! -e "${sessionFile}" ]] - then + then touch "${sessionFile}" chown aria2:aria2 "${sessionFile}" fi @@ -132,4 +132,4 @@ in }; }; }; -} \ No newline at end of file +} -- cgit 1.4.1 From 700e21d6dac4683ef40f20127a6eb2a74b9bd8c6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 31 Jan 2018 22:20:39 +0100 Subject: nix-daemon.nix: Updates for Nix 2.0 * The environment variables NIX_CONF_DIR, NIX_BUILD_HOOK and NIX_REMOTE are no longer needed. * A /bin/sh (from busybox) is provided by default in sandboxes. * Various options were renamed. --- nixos/modules/services/misc/nix-daemon.nix | 58 ++++++++++++++++-------------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index beca820d2d60..a169b0f2c784 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -8,7 +8,7 @@ let nix = cfg.package.out; - isNix112 = versionAtLeast (getVersion nix) "1.12pre"; + isNix20 = versionAtLeast (getVersion nix) "2.0pre"; makeNixBuildUser = nr: { name = "nixbld${toString nr}"; @@ -26,32 +26,40 @@ let nixConf = let - # If we're using sandbox for builds, then provide /bin/sh in - # the sandbox as a bind-mount to bash. This means we also need to - # include the entire closure of bash. + # In Nix < 2.0, If we're using sandbox for builds, then provide + # /bin/sh in the sandbox as a bind-mount to bash. This means we + # also need to include the entire closure of bash. Nix >= 2.0 + # provides a /bin/sh by default. sh = pkgs.stdenv.shell; binshDeps = pkgs.writeReferencesToFile sh; in - pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } '' - extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done) + pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; inherit binshDeps; } '' + ${optionalString (!isNix20) '' + extraPaths=$(for i in $(cat binshDeps); do if test -d $i; then echo $i; fi; done) + ''} cat > $out <