|
20 | 20 | parted |
21 | 21 | lvm2 |
22 | 22 | coreutils |
| 23 | + systemd |
23 | 24 | ] |
24 | 25 | ++ lib.optionals config.ghaf.storage.encryption.enable [ |
25 | 26 | cryptsetup |
|
93 | 94 | '' |
94 | 95 | # Release mode: prompt user for password |
95 | 96 | echo "LUKS container needs to be resized to use full disk space." |
96 | | - echo "Please enter your disk encryption password:" |
97 | | - cryptsetup resize -v crypted 2>&1 || { |
98 | | - echo "WARNING: LUKS resize failed. You may need to resize manually later." |
99 | | - echo "Run: cryptsetup resize crypted && pvresize /dev/mapper/crypted && lvextend -l +100%FREE /dev/pool/persist" |
100 | | - } |
| 97 | + while true; do |
| 98 | + PASSPHRASE=$(systemd-ask-password --timeout=0 "Enter encryption PIN / password:"); |
| 99 | +
|
| 100 | + if printf '%s' "$PASSPHRASE" | cryptsetup resize -v crypted 2>&1; then |
| 101 | + echo "LUKS resize successful" |
| 102 | + break |
| 103 | + fi |
| 104 | + echo "Resize failed. Retrying in 2 seconds..." |
| 105 | + sleep 2 |
| 106 | + done |
101 | 107 | '' |
102 | 108 | } |
103 | 109 | fi |
|
124 | 130 | config = lib.mkIf enable { |
125 | 131 |
|
126 | 132 | # To debug postBootCommands, one may run |
127 | | - # journalctl -u resize-partitions.service |
| 133 | + # journalctl -u initrd-nixos-activation.service |
128 | 134 | # inside the running Ghaf host. |
129 | | - systemd.services.resize-partitions = { |
130 | | - description = "Resize partitions and filesystems on first boot"; |
131 | | - wantedBy = [ "multi-user.target" ]; |
132 | | - after = [ "local-fs.target" ]; |
133 | | - requires = [ "local-fs.target" ]; |
134 | | - serviceConfig = { |
135 | | - Type = "oneshot"; |
136 | | - RemainAfterExit = true; |
137 | | - ExecStart = "${postBootCmds}/bin/postBootScript"; |
138 | | - }; |
139 | | - }; |
| 135 | + boot.postBootCommands = "${postBootCmds}/bin/postBootScript"; |
140 | 136 |
|
141 | 137 | systemd.services.extendbtrfs = |
142 | 138 | let |
|
153 | 149 | enable = true; |
154 | 150 | description = "Extend the btrfs filesystem"; |
155 | 151 | wantedBy = [ "multi-user.target" ]; |
156 | | - after = [ "resize-partitions.service" ]; |
157 | | - requires = [ "resize-partitions.service" ]; |
| 152 | + after = [ "persist.mount" ]; |
| 153 | + requires = [ "persist.mount" ]; |
158 | 154 | serviceConfig = { |
159 | 155 | Type = "oneshot"; |
160 | 156 | RemainAfterExit = true; |
|
0 commit comments