File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 115
115
imports = [ "${ modulesPath } /profiles/hardened.nix" ] ;
116
116
} ) ] ;
117
117
} ]
118
+
119
+ [ {
120
+ # no
121
+ id = null ;
122
+ } {
123
+ id = "credentials" ;
124
+ modules = [ ( { config , pkgs , ... } : {
125
+ # This is the guest vm config
126
+ microvm . credentialFiles . SECRET_BOOTSRAP_KEY = "/etc/microvm-bootstrap.secret" ;
127
+ microvm . testing . enableTest = builtins . elem config . microvm . hypervisor [
128
+ # Hypervisors that support systemd credentials
129
+ "qemu"
130
+ ] ;
131
+ # TODO: need to somehow have the test harness check for the success or failure of this service.
132
+ systemd . services . test-secret-availability = {
133
+ serviceConfig = {
134
+ ImportCredential = "SECRET_BOOTSRAP_KEY" ;
135
+ Restart = "no" ;
136
+ } ;
137
+ path = [ pkgs . gnugrep pkgs . coreutils ] ;
138
+ script = ''
139
+ cat $CREDENTIALS_DIRECTORY/SECRET_BOOTSRAP_KEY | grep -q "i am super secret"
140
+ if [ $? -ne 0 ]; then
141
+ echo "Secret not found at $CREDENTIALS_DIRECTORY/SECRET_BOOTSRAP_KEY"
142
+ exit 1
143
+ fi
144
+ '' ;
145
+ } ;
146
+ } ) ] ;
147
+ } ]
148
+
118
149
] ;
119
150
120
151
allVariants =
Original file line number Diff line number Diff line change 17
17
# Must be big enough for the store overlay volume
18
18
virtualisation . diskSize = 4096 ;
19
19
20
+ environment . etc . "microvm-bootstrap.secret" . text = "i am super secret" ;
21
+
20
22
microvm . vms . "${ system } -${ hypervisor } -example" . flake = self ;
21
23
} ;
22
24
testScript = ''
Original file line number Diff line number Diff line change 678
678
679
679
credentialFiles = mkOption {
680
680
type = with types ; attrsOf path ;
681
+ default = { } ;
681
682
description = ''
682
683
Key-value pairs of credential files that will be loaded into the vm using systemd's io.systemd.credential feature.
683
684
'' ;
You can’t perform that action at this time.
0 commit comments