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 115115 imports = [ "${ modulesPath } /profiles/hardened.nix" ] ;
116116 } ) ] ;
117117 } ]
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+
118149 ] ;
119150
120151 allVariants =
Original file line number Diff line number Diff line change 1717 # Must be big enough for the store overlay volume
1818 virtualisation . diskSize = 4096 ;
1919
20+ environment . etc . "microvm-bootstrap.secret" . text = "i am super secret" ;
21+
2022 microvm . vms . "${ system } -${ hypervisor } -example" . flake = self ;
2123 } ;
2224 testScript = ''
Original file line number Diff line number Diff line change 646646
647647 credentialFiles = mkOption {
648648 type = with types ; attrsOf path ;
649+ default = { } ;
649650 description = ''
650651 Key-value pairs of credential files that will be loaded into the vm using systemd's io.systemd.credential feature.
651652 '' ;
You can’t perform that action at this time.
0 commit comments