forked from tiiuae/ghaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Valentin Kharin <[email protected]>
- Loading branch information
1 parent
f11d937
commit 35859ae
Showing
5 changed files
with
131 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
modules/microvm/virtualization/microvm/common/shared-directory.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
name: | ||
{ lib, config, ... }: | ||
let | ||
cfg = config.ghaf.storagevm; | ||
shared-mountPath = "/tmp/shared/shares"; | ||
inherit (config.ghaf.users.accounts) user; | ||
isGuiVm = builtins.stringLength name == 0; | ||
userDir = "/home/${user}" + (if isGuiVm then "/Shares" else "/Unsafe\ share"); | ||
in | ||
{ | ||
config = lib.mkIf cfg.enable { | ||
fileSystems.${shared-mountPath}.neededForBoot = true; | ||
|
||
microvm.shares = [ | ||
{ | ||
tag = "shared-directory"; | ||
proto = "virtiofs"; | ||
securityModel = "passthrough"; | ||
# We want double dir to keep root permission for `shared` directory and `shares` will be allowed to view and change by user. | ||
source = "/storagevm/shared/shares" + (if !isGuiVm then "/Unsafe\ ${name}\ share/" else ""); | ||
mountPoint = shared-mountPath; | ||
} | ||
]; | ||
|
||
# https://github.com/nix-community/impermanence/blob/master/nixos.nix#L61-L70 | ||
fileSystems.${userDir} = { | ||
depends = [ shared-mountPath ]; | ||
device = shared-mountPath; | ||
noCheck = true; | ||
mountPoint = userDir; | ||
fsType = "none"; | ||
options = [ | ||
"bind" | ||
"X-fstrim.notrim" | ||
"x-gvfs-hide" | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters