yep, more dotfiles
1targetSystemPkgs:
2
3{ self
4, lib
5
6, writeShellApplication
7, ...
8}@pkgs:
9
10let
11 inherit (self.outputs) flake-lib;
12
13 iso = flake-lib.nixos.createSystem targetSystemPkgs [ ../nixos/profiles/installer.nix ];
14 # Build installer ISO
15 isoPath = "${iso.config.system.build.isoImage}/iso/${iso.config.isoImage.isoName}";
16
17in
18lib.getExe (writeShellApplication {
19 name = "flash-installer";
20 runtimeInputs = with pkgs; [ pv fzf ];
21
22 text = ''
23 # Select disk to flash
24 if [[ -n $"''${1-}" ]]; then
25 dev="/dev/$1"
26 else
27 # —————————————————————————————— ↓↓ ———————————————→ Check disks with removable tag (RM) ↓↓↓↓↓↓↓
28 dev="/dev/$(lsblk -d -n --output RM,NAME,FSTYPE,SIZE,LABEL,TYPE,VENDOR,UUID | awk '{ if ($1 == 1) { print } }' | fzf | awk '{print $2}')"
29 fi
30
31 echo "Flashing to $dev"
32
33 # Format selected disk
34 pv -tpreb "${isoPath}" | sudo dd bs=4M of="$dev" iflag=fullblock conv=notrunc,noerror oflag=sync
35 '';
36})