From bb73865b3ebf54e7325b63b44a24e9f5f65d2ea2 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Fri, 11 Jun 2021 22:41:50 -0400 Subject: [PATCH] add format-luks script --- flake.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/flake.nix b/flake.nix index 383edef..bc3806d 100644 --- a/flake.nix +++ b/flake.nix @@ -29,5 +29,25 @@ { binaryninja = callPackage ./pkgs/binary-ninja-personal { }; }; + + apps."x86_64-linux" = + with (import nixpkgs { system = "x86_64-linux"; }); + { + format-luks = writeShellScriptBin "format-luks" '' + set -e + read -p "Path to new LUKS device: " blkdev + set -x + cryptsetup -y -v luksFormat "$blkdev" + cryptsetup --allow-discards open "$blkdev" cryptroot + mkfs.btrfs /dev/mapper/cryptroot + mount /dev/mapper/cryptroot /mnt -o discard,compress=zstd + btrfs subvolume create /mnt/os + btrfs subvolume create /mnt/home + umount /mnt + mount /dev/mapper/cryptroot /mnt -o discard,compress=zstd,subvol=/os + mkdir /mnt/home + mount /dev/mapper/cryptroot /mnt/home -o discard,compress=zstd,subvol=/home + ''; + }; }; }