Merge branch 'master' into zfs-multi-device

This commit is contained in:
Jörg Thalheim 2025-04-01 17:47:26 +02:00 committed by GitHub
commit 88416a576e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 9 deletions

View file

@ -4,5 +4,7 @@ set -efux -o pipefail
disk=$(realpath "$1")
lsblk -a -f >&2
# since we currently cannot recursively deactivate swaps on zfs volumes, we need to deactivate all of them.
lsblk --output-all --json | jq -r -f "$(dirname "$0")/zfs-swap-deactivate.jq" | bash -x
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
lsblk -a -f >&2

View file

@ -0,0 +1,10 @@
def turnOffSwaps:
if (.name | test("^zd[0-9]+$")) and .type == "disk" then
"swapoff /dev/" + .name
else
[]
end
;
.blockdevices | map(turnOffSwaps) | flatten | join("\n")

View file

@ -15,6 +15,7 @@
"i686-linux"
"aarch64-linux"
"riscv64-linux"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs supportedSystems;
@ -70,6 +71,7 @@
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/zfs-swap-deactivate.jq}
touch $out
'';

View file

@ -8,6 +8,7 @@
nixos-install-tools,
binlore,
diskoVersion,
stdenv,
}:
let
@ -20,20 +21,28 @@ let
installPhase = ''
mkdir -p $out/bin $out/share/disko
cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko
set -x
for i in disko disko-install; do
scripts=(disko)
${lib.optionalString (!stdenv.isDarwin) ''
scripts+=(disko-install)
''}
for i in "''${scripts[@]}"; do
sed -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" "$i" > "$out/bin/$i"
chmod 755 "$out/bin/$i"
wrapProgram "$out/bin/$i" \
--set DISKO_VERSION "${diskoVersion}" \
--prefix NIX_PATH : "nixpkgs=${path}" \
--prefix PATH : ${
lib.makeBinPath [
nix
coreutils
nixos-install-tools
]
} \
--prefix NIX_PATH : "nixpkgs=${path}"
lib.makeBinPath (
[
nix
coreutils
]
++ lib.optional (!stdenv.isDarwin) nixos-install-tools
)
}
done
'';
# Otherwise resholve thinks that disko and disko-install might be able to execute their arguments
@ -46,7 +55,7 @@ let
homepage = "https://github.com/nix-community/disko";
license = licenses.mit;
maintainers = with maintainers; [ lassulus ];
platforms = platforms.linux;
platforms = platforms.unix;
mainProgram = finalAttrs.name;
};
});