Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

7 changed files with 19 additions and 42 deletions

View File

@ -2,16 +2,16 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1685004253,
"narHash": "sha256-AbVL1nN/TDicUQ5wXZ8xdLERxz/eJr7+o8lqkIOVuaE=",
"owner": "NixOS",
"lastModified": 1665449268,
"narHash": "sha256-cw4xrQIAZUyJGj58Dp5VLICI0rscd+uap83afiFzlcA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3e01645c40b92d29f3ae76344a6d654986a91a91",
"rev": "285e77efe87df64105ec14b204de6636fb0a7a27",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -2,7 +2,7 @@
description = "WFVM: Windows Functional Virtual Machine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
@ -12,26 +12,13 @@
pkgs = nixpkgs.legacyPackages.${system};
in rec {
in {
lib = import ./wfvm {
inherit pkgs;
};
packages.${system} = rec {
demoImage = import ./wfvm/demo-image.nix {
inherit self;
};
default = lib.utils.wfvm-run {
name = "demo";
image = demoImage;
script =
''
echo "Windows booted. Press Enter to terminate VM."
read
'';
display = true;
};
packages.${system}.demoImage = import ./wfvm/demo-image.nix {
inherit self;
};
};
}

View File

@ -14,7 +14,6 @@
, services ? {}
, impureShellCommands ? []
, driveLetter ? "D:"
, efi ? true
, imageSelection ? "Windows 11 Pro N"
, enableTpm
, ...
@ -120,8 +119,7 @@ let
# Windows expects a flat list of users while we want to manage them as a set
flatUsers = builtins.attrValues (builtins.mapAttrs (name: s: s // { inherit name; }) users);
diskId =
if efi then 2 else 1;
diskId = 2;
autounattendXML = pkgs.writeText "autounattend.xml" ''
<?xml version="1.0" encoding="utf-8"?>
@ -161,12 +159,12 @@ let
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>${if efi then "EFI" else "Primary"}</Type>
<Type>EFI</Type>
<Size>300</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>${if efi then "MSR" else "Primary"}</Type>
<Type>MSR</Type>
<Size>16</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
@ -178,7 +176,7 @@ let
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<Format>${if efi then "FAT32" else "NTFS"}</Format>
<Format>FAT32</Format>
<Label>System</Label>
<PartitionID>1</PartitionID>
</ModifyPartition>

View File

@ -2,6 +2,6 @@
{
makeWindowsImage = attrs: import ./win.nix ({ inherit pkgs; } // attrs);
layers = import ./layers { inherit pkgs; };
utils = import ./utils.nix { inherit pkgs; };
layers = (import ./layers { inherit pkgs; });
utils = (import ./utils.nix { inherit pkgs; });
}

View File

@ -57,7 +57,7 @@ wfvm.makeWindowsImage {
disable-autolock
disable-firewall
])
anaconda3 msys2
anaconda3 msys2 msvc msvc-ide-unbreak
];
# services = {

View File

@ -2,9 +2,7 @@
, baseRtc ? "2022-10-10T10:10:10"
, cores ? "4"
, qemuMem ? "4G"
, efi ? true
, enableTpm ? false
, ...
}:
rec {
@ -25,7 +23,6 @@ rec {
"-rtc base=${baseRtc}"
"-device qemu-xhci"
"-device virtio-net-pci,netdev=n1"
] ++ pkgs.lib.optionals efi [
"-bios ${OVMF.fd}/FV/OVMF.fd"
] ++ pkgs.lib.optionals enableTpm [
"-chardev" "socket,id=chrtpm,path=tpm.sock"

View File

@ -8,13 +8,12 @@
, enableTpm ? true
# autounattend always installs index 1, so this default is backward-compatible
, imageSelection ? "Windows 11 Pro N"
, efi ? true
, ...
}@attrs:
let
lib = pkgs.lib;
utils = import ./utils.nix ({ inherit pkgs efi enableTpm; } // attrs);
utils = import ./utils.nix { inherit pkgs enableTpm; };
inherit (pkgs) guestfs-tools;
# p7zip on >20.03 has known vulns but we have no better option
@ -96,7 +95,7 @@ let
"usb-storage,drive=virtio-win"
# USB boot
"-drive"
"id=win-install,file=${if efi then "usb" else "cd"}image.img,if=none,format=raw,readonly=on,media=${if efi then "disk" else "cdrom"}"
"id=win-install,file=usbimage.img,if=none,format=raw,readonly=on,media=disk"
"-device"
"usb-storage,drive=win-install"
# Output image
@ -125,11 +124,7 @@ let
cp ${autounattend.autounattendXML} win/autounattend.xml
${if efi then ''
virt-make-fs --partition --type=fat win/ usbimage.img
'' else ''
${pkgs.cdrkit}/bin/mkisofs -iso-level 4 -l -R -udf -D -b boot/etfsboot.com -no-emul-boot -boot-load-size 8 -hide boot.catalog -eltorito-alt-boot -o cdimage.img win/
''}
rm -rf win
${utils.tpmStartCommands}