git.iko.soy/typeable/nixpkgs
on master help sign in
vmTools refactor: don't use huge `with pkgs;`

... especially when scoped over hundreds of lines of code.

commit52b10ee8725e3fde6bb5fc297b997d7c1bc59930 authorVladimír Čunát <v@cunat.cz> dateThu 30 Sep 2021, 20:43 (5 years ago) parent189dabc
1 file changed+13−10
pkgs/build-support/vm/default.nix+13−10
pkgs/build-support/vm/default.nix+13−10
@@ -8,14 +8,17 @@
88 ++ pkgs.lib.optional (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) "rtc_cmos"
99}:
1010
11−with pkgs;
12−
11+let
12+ inherit (pkgs) bash bashInteractive busybox cpio coreutils e2fsprogs fetchurl kmod rpm
13+ stdenv util-linux
14+ buildPackages writeScript writeText runCommand;
15+in
1316rec {
1417 qemu-common = import ../../../nixos/lib/qemu-common.nix { inherit lib pkgs; };
1518
1619 qemu = buildPackages.qemu_kvm;
1720
18− modulesClosure = makeModulesClosure {
21+ modulesClosure = pkgs.makeModulesClosure {
1922 inherit kernel rootModules;
2023 firmware = kernel;
2124 };
@@ -137,7 +140,7 @@ rec {
137140 '';
138141
139142
140− initrd = makeInitrd {
143+ initrd = pkgs.makeInitrd {
141144 contents = [
142145 { object = stage1Init;
143146 symlink = "/init";
@@ -152,7 +155,7 @@ rec {
152155
153156 # Set the system time from the hardware clock. Works around an
154157 # apparent KVM > 1.5.2 bug.
155− ${pkgs.util-linux}/bin/hwclock -s
158+ ${util-linux}/bin/hwclock -s
156159
157160 export NIX_STORE=${storeDir}
158161 export NIX_BUILD_TOP=/tmp
@@ -324,7 +327,7 @@ rec {
324327
325328
326329 extractFs = {file, fs ? null} :
327− with pkgs; runInLinuxVM (
330+ runInLinuxVM (
328331 stdenv.mkDerivation {
329332 name = "extract-file";
330333 buildInputs = [ util-linux ];
@@ -349,10 +352,10 @@ rec {
349352
350353
351354 extractMTDfs = {file, fs ? null} :
352− with pkgs; runInLinuxVM (
355+ runInLinuxVM (
353356 stdenv.mkDerivation {
354357 name = "extract-file-mtd";
355− buildInputs = [ util-linux mtdutils ];
358+ buildInputs = [ pkgs.util-linux pkgs.mtdutils ];
356359 buildCommand = ''
357360 ln -s ${kernel}/lib /lib
358361 ${kmod}/bin/modprobe mtd
@@ -503,7 +506,7 @@ rec {
503506 tarball must contain an RPM specfile. */
504507
505508 buildRPM = attrs: runInLinuxImage (stdenv.mkDerivation ({
506− prePhases = [ prepareImagePhase sysInfoPhase ];
509+ prePhases = [ pkgs.prepareImagePhase pkgs.sysInfoPhase ];
507510 dontUnpack = true;
508511 dontConfigure = true;
509512
@@ -584,7 +587,7 @@ rec {
584587 buildCommand = ''
585588 ${createRootFS}
586589
587− PATH=$PATH:${lib.makeBinPath [ dpkg dpkg glibc xz ]}
590+ PATH=$PATH:${lib.makeBinPath [ pkgs.dpkg pkgs.glibc pkgs.xz ]}
588591
589592 # Unpack the .debs. We do this to prevent pre-install scripts
590593 # (which have lots of circular dependencies) from barfing.