[wip] nix_flakes support #14
32
flake.nix
32
flake.nix
|
@ -4,6 +4,7 @@
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
lib = pkgs.lib;
|
||||||
# common settings
|
# common settings
|
||||||
baseRtc = "2020-04-20T14:21:42";
|
baseRtc = "2020-04-20T14:21:42";
|
||||||
cores = "4";
|
cores = "4";
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
"-rtc base=${baseRtc}"
|
"-rtc base=${baseRtc}"
|
||||||
"-device qemu-xhci"
|
"-device qemu-xhci"
|
||||||
"-device virtio-net-pci,netdev=n1"
|
"-device virtio-net-pci,netdev=n1"
|
||||||
] ++ pkgs.lib.optionals efi [
|
] ++ lib.optionals efi [
|
||||||
"-bios ${pkgs.OVMF.fd}/FV/OVMF.fd"
|
"-bios ${pkgs.OVMF.fd}/FV/OVMF.fd"
|
||||||
] ++ extraFlags;
|
] ++ extraFlags;
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@
|
||||||
(map ({ listenAddr, targetAddr, port }:
|
(map ({ listenAddr, targetAddr, port }:
|
||||||
",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${pkgs.socat}/bin/socat\\ -\\ tcp:${targetAddr}:${toString port}"
|
",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${pkgs.socat}/bin/socat\\ -\\ tcp:${targetAddr}:${toString port}"
|
||||||
) forwardedPorts);
|
) forwardedPorts);
|
||||||
qemuParams = mkQemuFlags (pkgs.lib.optional (!display) "-display none" ++ pkgs.lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
|
qemuParams = mkQemuFlags (lib.optional (!display) "-display none" ++ lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
|
||||||
"-drive"
|
"-drive"
|
||||||
"file=${image},index=0,media=disk,cache=unsafe"
|
"file=${image},index=0,media=disk,cache=unsafe"
|
||||||
"-snapshot"
|
"-snapshot"
|
||||||
|
@ -103,7 +104,7 @@
|
||||||
]);
|
]);
|
||||||
in pkgs.writeShellScriptBin "wfvm-run-${name}" ''
|
in pkgs.writeShellScriptBin "wfvm-run-${name}" ''
|
||||||
set -e -m
|
set -e -m
|
||||||
${qemu}/bin/qemu-system-x86_64 ${pkgs.lib.concatStringsSep " " qemuParams} &
|
${qemu}/bin/qemu-system-x86_64 ${lib.concatStringsSep " " qemuParams} &
|
||||||
|
|
||||||
${win-wait}/bin/win-wait
|
${win-wait}/bin/win-wait
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@
|
||||||
msys2-packages = msys-packages: {
|
msys2-packages = msys-packages: {
|
||||||
name = "MSYS2-packages";
|
name = "MSYS2-packages";
|
||||||
script = let
|
script = let
|
||||||
msys-packages-put = pkgs.lib.strings.concatStringsSep "\n"
|
msys-packages-put = lib.strings.concatStringsSep "\n"
|
||||||
(map (package: ''win-put ${package} 'msyspackages' '') msys-packages);
|
(map (package: ''win-put ${package} 'msyspackages' '') msys-packages);
|
||||||
in
|
in
|
||||||
# Windows command line is so shitty it can't even do glob expansion. Why do people use Windows?
|
# Windows command line is so shitty it can't even do glob expansion. Why do people use Windows?
|
||||||
|
@ -286,7 +287,7 @@
|
||||||
# Chain together layers that are quick to run so that the VM does
|
# Chain together layers that are quick to run so that the VM does
|
||||||
# not have to be started/shutdown for each.
|
# not have to be started/shutdown for each.
|
||||||
collapseLayers = scripts: {
|
collapseLayers = scripts: {
|
||||||
name = pkgs.lib.concatMapStringsSep "-" ({ name, ... }: name) scripts;
|
name = lib.concatMapStringsSep "-" ({ name, ... }: name) scripts;
|
||||||
script = builtins.concatStringsSep "\n" (
|
script = builtins.concatStringsSep "\n" (
|
||||||
map ({ script, ... }: script) scripts
|
map ({ script, ... }: script) scripts
|
||||||
);
|
);
|
||||||
|
@ -305,9 +306,7 @@
|
||||||
, inputLocale ? "en-US"
|
, inputLocale ? "en-US"
|
||||||
, userLocale ? "en-US"
|
, userLocale ? "en-US"
|
||||||
, systemLocale ? "en-US"
|
, systemLocale ? "en-US"
|
||||||
, users ? { wfvm = { password = "1234";
|
, additionalUsers ? {}
|
||||||
description = "WFVM Administrator";
|
|
||||||
groups = [ "Administrators" ]; }; }
|
|
||||||
, productKey ? null
|
, productKey ? null
|
||||||
, defaultUser ? "wfvm"
|
, defaultUser ? "wfvm"
|
||||||
, setupCommands ? []
|
, setupCommands ? []
|
||||||
|
@ -320,7 +319,9 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
users = additionalUsers // { wfvm = { password = "1234";
|
||||||
|
description = "WFVM Administrator";
|
||||||
|
groups = [ "Administrators" ]; }; };
|
||||||
serviceCommands = lib.mapAttrsToList (
|
serviceCommands = lib.mapAttrsToList (
|
||||||
serviceName: attrs: "powershell Set-Service -Name ${serviceName} " + (
|
serviceName: attrs: "powershell Set-Service -Name ${serviceName} " + (
|
||||||
lib.concatStringsSep " " (
|
lib.concatStringsSep " " (
|
||||||
|
@ -644,7 +645,7 @@
|
||||||
, ...
|
, ...
|
||||||
}@attrs:
|
}@attrs:
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
|
||||||
libguestfs = pkgs.libguestfs-with-appliance;
|
libguestfs = pkgs.libguestfs-with-appliance;
|
||||||
|
|
||||||
# p7zip on >20.03 has known vulns but we have no better option
|
# p7zip on >20.03 has known vulns but we have no better option
|
||||||
|
@ -667,7 +668,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
windowsIso = if windowsImage != null then windowsImage else pkgs.requireFile rec {
|
windowsIso = if windowsImage != null then windowsImage else pkgs.requireFile rec {
|
||||||
name = "Win10_21H1_English_x64.iso";
|
name = "Win10_21H2_English_x64.iso";
|
||||||
sha256 = "1sl51lnx4r6ckh5fii7m2hi15zh8fh7cf7rjgjq9kacg8hwyh4b9";
|
sha256 = "1sl51lnx4r6ckh5fii7m2hi15zh8fh7cf7rjgjq9kacg8hwyh4b9";
|
||||||
message = "Get ${name} from https://www.microsoft.com/en-us/software-download/windows10ISO";
|
message = "Get ${name} from https://www.microsoft.com/en-us/software-download/windows10ISO";
|
||||||
};
|
};
|
||||||
|
@ -684,14 +685,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
autounattend = build-autounattend attrs // {
|
autounattend = build-autounattend attrs // {
|
||||||
users = users // { wfvm = {
|
additionalUsers = users;
|
||||||
password = "1234";
|
|
||||||
description = "WFVM Administrator";
|
|
||||||
groups = [
|
|
||||||
"Administrators"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Packages required to drive installation of other packages
|
# Packages required to drive installation of other packages
|
||||||
|
|
Loading…
Reference in New Issue