mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-09 03:55:44 +03:00
nixos/make-disk-image: fix contents dir paths
`make-disk-image` is a tool for creating VM images. It takes an argument `contents` that allows one to specify files and directories that should be copied into the VM image. However, directories end up not at the specified target, but instead at a subdirectory of the target, with a nix-store-like path, e.g. `/target/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-source`. See issue https://github.com/NixOS/nixpkgs/issues/226203 . This change adds a test for make-disk-image's contents directory handling and adds a fix (appending `/` to rsync input directory names). This closes issue https://github.com/NixOS/nixpkgs/issues/226203 .
This commit is contained in:
parent
a711e445cc
commit
15c760d6b8
3 changed files with 28 additions and 10 deletions
|
@ -27,13 +27,19 @@ let
|
|||
inherit pkgs config;
|
||||
lib = pkgs.lib;
|
||||
format = "qcow2";
|
||||
contents = [{
|
||||
source = pkgs.writeText "testFile" "contents";
|
||||
target = "/testFile";
|
||||
user = "1234";
|
||||
group = "5678";
|
||||
mode = "755";
|
||||
}];
|
||||
contents = [
|
||||
{
|
||||
source = pkgs.writeText "testFile" "contents";
|
||||
target = "/testFile";
|
||||
user = "1234";
|
||||
group = "5678";
|
||||
mode = "755";
|
||||
}
|
||||
{
|
||||
source = ./.;
|
||||
target = "/testDir";
|
||||
}
|
||||
];
|
||||
}) + "/nixos.qcow2";
|
||||
|
||||
in makeEc2Test {
|
||||
|
@ -42,10 +48,15 @@ in makeEc2Test {
|
|||
userData = null;
|
||||
script = ''
|
||||
machine.start()
|
||||
# Test that if contents includes a file, it is copied to the target.
|
||||
assert "content" in machine.succeed("cat /testFile")
|
||||
fileDetails = machine.succeed("ls -l /testFile")
|
||||
assert "1234" in fileDetails
|
||||
assert "5678" in fileDetails
|
||||
assert "rwxr-xr-x" in fileDetails
|
||||
|
||||
# Test that if contents includes a directory, it is copied to the target.
|
||||
dirList = machine.succeed("ls /testDir")
|
||||
assert "image-contents.nix" in dirList
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue