| 11 Feb 2024 |
matthewcroughan | I can't spot the problem directly in your example, because this is one of the larger modules with deeply nested options, so it's quite hard, but I assure you that if you put your code on the left, and the ZFS example on the right, you will spot it | 12:04:52 |
lassulus | Pool should be rpool | 12:06:23 |
matthewcroughan | ah damn :D | 12:06:29 |
lassulus | Not zpool | 12:06:31 |
matthewcroughan | is there no way to have Nix warn you about that, like "Did you mean rpool?" | 12:06:45 |
eyJhb | In reply to @lassulus:lassul.us Pool should be rpool Yeah, that's the thing I'm trying now. I changed it once, but ... I just changed it from zroot to zpool.............. | 12:07:02 |
eyJhb | In reply to @matthewcroughan:defenestrate.it is there no way to have Nix warn you about that, like "Did you mean rpool?" Make it include clippy as well. Disko clippy | 12:07:30 |
eyJhb | Nice, now it doesn't fail while creating the disks! | 12:07:54 |
matthewcroughan | Hopefully zfs goes away and we get all the features in bcachefs | 12:07:59 |
matthewcroughan | less to maintain if that happens | 12:08:13 |
eyJhb | Would it make sense to have a check, that tries to check if there is a key in zpool that is the pool name :) | 12:08:23 |
eyJhb | * Would it make sense to have a check, that tries to check if there is a key in zpool that is the pool name? | 12:08:25 |
matthewcroughan | Well it really should check with regexp and throw a trace if it's anything other than rpool | 12:08:59 |
eyJhb | In reply to @matthewcroughan:defenestrate.it Hopefully zfs goes away and we get all the features in bcachefs Yeah, I think that's the hope. I haven't tried bcachefs at all. I've just heard k900 talking about it a lot. Or generally been spoken a lot about. | 12:09:02 |
matthewcroughan | There are probably a lot of cases that need to be caught manually with Nix code, this is one of them | 12:09:24 |
eyJhb | [root@nixos:~]# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 889M 35.5G 25K /rpool
rpool/local 888M 35.5G 24K /rpool/local
rpool/local/nix 888M 35.5G 888M legacy
rpool/local/stash 24K 35.5G 24K legacy
rpool/root 322K 35.5G 300K legacy
rpool/safe 72K 35.5G 24K /rpool/safe
rpool/safe/home 24K 35.5G 24K legacy
rpool/safe/persistent 24K 35.5G 24K legacy
[root@nixos:~]# df H
df: H: No such file or directory
[root@nixos:~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 192M 0 192M 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 959M 2.8M 957M 1% /run
tmpfs 1.9G 320K 1.9G 1% /run/wrappers
rpool/root 36G 384K 36G 1% /
rpool/local/nix 37G 889M 36G 3% /nix
rpool 36G 128K 36G 1% /rpool
rpool/safe 36G 128K 36G 1% /rpool/safe
rpool/local 36G 128K 36G 1% /rpool/local
rpool/local/stash 36G 128K 36G 1% /state/stash
rpool/safe/home 36G 128K 36G 1% /state/home
/dev/sda2 500M 42M 458M 9% /boot
rpool/safe/persistent 36G 128K 36G 1% /state/root
tmpfs 384M 0 384M 0% /run/user/0
| 12:09:40 |
eyJhb | Works! Awesome :) | 12:09:43 |
eyJhb | I should make an issue for it. | 12:10:04 |
eyJhb | OR even better, a PR for it. | 12:10:11 |
matthewcroughan | this is equivalent to a typo, it should be possible to express a type in lib that catches this, hard though, I can see why there's no code written to catch this failure | 12:14:21 |
eyJhb | Wondering, is there any option for copying over the keyFile to the remote host? E.g. using ssh :) | 12:58:56 |
eyJhb | In reply to @matthewcroughan:defenestrate.it this is equivalent to a typo, it should be possible to express a type in lib that catches this, hard though, I can see why there's no code written to catch this failure Yeah, that's fair | 12:59:08 |
matthewcroughan | In reply to @eyjhb:eyjhb.dk Wondering, is there any option for copying over the keyFile to the remote host? E.g. using ssh :) Why do that when you could bake the secret into the image | 13:59:18 |
matthewcroughan | In reply to @eyjhb:eyjhb.dk Wondering, is there any option for copying over the keyFile to the remote host? E.g. using ssh :) * Why do that when you could bake the secret into the disk image | 13:59:29 |
matthewcroughan | if you're referring to nixos-anywhere, I wonder if they have a postDeploy/preDeploy hook that could be used for this, would be a good idea if not yet implemented | 13:59:54 |
eyJhb | In reply to @matthewcroughan:defenestrate.it Why do that when you could bake the secret into the disk image Bake into the disk image? I might be misunderstanding that | 14:22:31 |
eyJhb | In reply to @matthewcroughan:defenestrate.it if you're referring to nixos-anywhere, I wonder if they have a postDeploy/preDeploy hook that could be used for this, would be a good idea if not yet implemented True, I need to look into if nixos-anywhere has that option :) Not disko thing yeah :) | 14:23:08 |
matthewcroughan | Not 100% sure if it's in disko yet, but I remember some feature I was shown where you can put data into a disk image, without it being in the Nix store. | 14:23:08 |
matthewcroughan | I have an implementation of this which is really simple, and almost equivalent, which just uses a VM to add secrets to an existing disk image by using loopbacks | 14:24:02 |
matthewcroughan | packages.x86_64-linux.secretImage =
let
secretAdderVm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ config, ... }:
let
stateDir = config.services.tor.settings.DataDirectory;
in
{
imports = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./tor-config.nix
];
virtualisation.graphics = false;
services.getty.autologinUser = "root";
programs.bash.interactiveShellInit = ''
if [ "$(tty)" = "/dev/ttyS0" ]; then
mkdir /mnt
unzstd ${self.images.pi}/sd-image/*.zst --output-dir-flat /tmp/shared
chmod 700 /tmp/shared/*.img
losetup -P /dev/loop0 /tmp/shared/*.img
mount /dev/loop0p2 /mnt
mkdir -p /mnt/${stateDir}
cp -r ${stateDir}/onion /mnt/${stateDir}/onion
chown -R ${toString config.ids.uids.tor}:${toString config.ids.gids.tor} /mnt/${stateDir}
chmod -R 700 /mnt/${stateDir}
umount /mnt
losetup -d /dev/loop0
for i in ${stateDir}/onion/*; do echo -e "\nOnion Service: $(basename $i) -> $(cat $i/hostname)" >> /tmp/shared/services; done
shutdown now
fi
'';
})
];
};
in
nixpkgs.legacyPackages.x86_64-linux.writeScriptBin "addSecrets"
''
rm nixos.qcow2
export SHARED_DIR=$(mktemp -d)
${secretAdderVm.config.system.build.vm}/bin/run-nixos-vm
cat $SHARED_DIR/services
mv $SHARED_DIR/*.img .
'';
| 14:24:04 |