diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-10-10 23:28:45 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-02-26 19:12:42 +0000 |
commit | bdbc835e57c1d287bfb7596b8cfaa61986451d30 (patch) | |
tree | 3c4e1cf41085d448102182206df5cd32ff231cb4 | |
parent | 75b797d934867b0c10b0481bd8719a1b50239bb0 (diff) | |
download | spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar.gz spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar.bz2 spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar.lz spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar.xz spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.tar.zst spectrum-bdbc835e57c1d287bfb7596b8cfaa61986451d30.zip |
vm-lib/make-vm.nix: support shared directories
Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221010232909.1953738-6-hi@alyssa.is>
-rw-r--r-- | vm-lib/make-vm.nix | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/vm-lib/make-vm.nix b/vm-lib/make-vm.nix index 2c50ca5..61e0b2d 100644 --- a/vm-lib/make-vm.nix +++ b/vm-lib/make-vm.nix @@ -13,11 +13,12 @@ pkgs.pkgsStatic.callPackage ( { lib, runCommand, writeReferencesToFile, e2fsprogs, tar2ext4 }: -{ run, providers ? {} }: +{ run, providers ? {}, sharedDirs ? {} }: let inherit (lib) - any attrValues concatLists concatStrings hasInfix mapAttrsToList; + any attrValues concatLists concatStrings concatStringsSep hasInfix + mapAttrsToList; in assert !(any (hasInfix "\n") (concatLists (attrValues providers))); @@ -29,7 +30,7 @@ runCommand "spectrum-vm" { (mapAttrsToList (kind: map (vm: "${kind}/${vm}\n")) providers)); passAsFile = [ "providerDirs" ]; } '' - mkdir -p "$out"/{blk,providers} + mkdir -p "$out"/{blk,providers,shared-dirs} mkdir root cd root @@ -40,11 +41,22 @@ runCommand "spectrum-vm" { tar2ext4 -i ../run.tar -o "$out/blk/run.img" e2label "$out/blk/run.img" ext - pushd "$out/providers" + pushd "$out" + + pushd providers xargs -rd '\n' dirname -- < "$providerDirsPath" | xargs -rd '\n' mkdir -p -- xargs -rd '\n' touch -- < "$providerDirsPath" popd + pushd shared-dirs + ${concatStringsSep "\n" (mapAttrsToList (key: { path }: '' + mkdir ${lib.escapeShellArg key} + ln -s ${lib.escapeShellArgs [ path "${key}/dir" ]} + '') sharedDirs)} + popd + + popd + ln -s /usr/img/appvm/blk/root.img "$out/blk" ln -s /usr/img/appvm/vmlinux "$out" '' |