about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2021-06-23 17:46:46 +0200
committerrnhmjoj <rnhmjoj@inventati.org>2021-09-18 16:58:16 +0200
commitb29c2f97c37f7cb4a1b3411ff9888a49873597d2 (patch)
tree7352ff4d0310afcb03cb1be6ad15745c28d3cd5f /nixos/lib
parentb8bfc81d5b2d88b734a311f712fc0ba2b267f9e0 (diff)
nixos/lib/qemu-flags: rename to qemu-common
The current name is misleading: it doesn't contain cli arguments,
but several constants and utility functions related to qemu.
This commit also removes the use of `with import ...` for clarity.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/build-vms.nix10
-rw-r--r--nixos/lib/qemu-common.nix (renamed from nixos/lib/qemu-flags.nix)8
-rw-r--r--nixos/lib/testing-python.nix3
3 files changed, 10 insertions, 11 deletions
diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix
index b009108e43f9b..0f0bdb4a86cb4 100644
--- a/nixos/lib/build-vms.nix
+++ b/nixos/lib/build-vms.nix
@@ -4,15 +4,14 @@
 , # Ignored
   config ? null
 , # Nixpkgs, for qemu, lib and more
-  pkgs
+  pkgs, lib
 , # !!! See comment about args in lib/modules.nix
   specialArgs ? {}
 , # NixOS configuration to add to the VMs
   extraConfigurations ? []
 }:
 
-with pkgs.lib;
-with import ../lib/qemu-flags.nix { inherit pkgs; };
+with lib;
 
 rec {
 
@@ -93,8 +92,9 @@ rec {
                          "${config.networking.hostName}\n"));
 
                   virtualisation.qemu.options =
-                    flip concatMap interfacesNumbered
-                      ({ fst, snd }: qemuNICFlags snd fst m.snd);
+                    let qemu-common = import ../lib/qemu-common.nix { inherit lib pkgs; };
+                    in flip concatMap interfacesNumbered
+                      ({ fst, snd }: qemu-common.qemuNICFlags snd fst m.snd);
                 };
             }
           )
diff --git a/nixos/lib/qemu-flags.nix b/nixos/lib/qemu-common.nix
index 5f96391d2af8c..84f9060acd631 100644
--- a/nixos/lib/qemu-flags.nix
+++ b/nixos/lib/qemu-common.nix
@@ -1,12 +1,12 @@
-# QEMU flags shared between various Nix expressions.
-{ pkgs }:
+# QEMU-related utilities shared between various Nix expressions.
+{ lib, pkgs }:
 
 let
   zeroPad = n:
-    pkgs.lib.optionalString (n < 16) "0" +
+    lib.optionalString (n < 16) "0" +
       (if n > 255
        then throw "Can't have more than 255 nets or nodes!"
-       else pkgs.lib.toHexString n);
+       else lib.toHexString n);
 in
 
 rec {
diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix
index 7c8c64211f18c..a1c3624d14995 100644
--- a/nixos/lib/testing-python.nix
+++ b/nixos/lib/testing-python.nix
@@ -217,7 +217,7 @@ rec {
       nodes = qemu_pkg:
         let
           build-vms = import ./build-vms.nix {
-            inherit system pkgs minimal specialArgs;
+            inherit system lib pkgs minimal specialArgs;
             extraConfigurations = extraConfigurations ++ [(
               {
                 virtualisation.qemu.package = qemu_pkg;
@@ -257,7 +257,6 @@ rec {
         inherit test driver driverInteractive nodes;
       };
 
-
   abortForFunction = functionName: abort ''The ${functionName} function was
     removed because it is not an essential part of the NixOS testing
     infrastructure. It had no usage in NixOS or Nixpkgs and it had no designated