-
Notifications
You must be signed in to change notification settings - Fork 63
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
5f3163c
commit cff1b74
Showing
8 changed files
with
101 additions
and
84 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
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
60 changes: 60 additions & 0 deletions
60
modules/microvm/virtualization/microvm/common/storagevm.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,60 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ impermanence }: | ||
{ lib, config, ... }: | ||
let | ||
cfg = config.ghaf.storagevm; | ||
mountPath = "/tmp/storagevm"; | ||
in | ||
{ | ||
imports = [ impermanence.nixosModules.impermanence ]; | ||
|
||
options.ghaf.storagevm = with lib; { | ||
enable = mkEnableOption "StorageVM support"; | ||
|
||
name = mkOption { | ||
description = '' | ||
Name of the corresponding directory on the storage virtual machine. | ||
''; | ||
type = types.str; | ||
}; | ||
|
||
directories = mkOption { | ||
# FIXME: Probably will lead to disgraceful error messages, as we | ||
# put typechecking on nix impermanence option. But other, | ||
# proper, ways are much harder. | ||
type = types.anything; | ||
default = [ ]; | ||
example = [ | ||
"Downloads" | ||
"Music" | ||
"Pictures" | ||
"Documents" | ||
"Videos" | ||
]; | ||
description = '' | ||
Directories to bind mount to persistent storage. | ||
''; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
fileSystems.${mountPath}.neededForBoot = true; | ||
|
||
microvm.shares = [ | ||
{ | ||
tag = "hostshare"; | ||
proto = "virtiofs"; | ||
securityModel = "passthrough"; | ||
source = "/storagevm/${cfg.name}"; | ||
mountPoint = mountPath; | ||
} | ||
]; | ||
|
||
environment.persistence.${mountPath} = { | ||
hideMounts = true; | ||
inherit (cfg) directories; | ||
# inherit (cfg) directories; | ||
}; | ||
}; | ||
} |
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
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