Commit 64782b05 authored by Madoura's avatar Madoura Committed by Bjørn Forsman
Browse files

bcachefs-tools: add update script

parent 1558b0d6
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
, rustc
, rustPlatform
, makeWrapper
, writeScript
, fuseSupport ? false
}:

@@ -77,11 +78,26 @@ stdenv.mkDerivation (finalAttrs: {
    rm tests/test_fuse.py
  '';

  passthru.tests = {
  passthru = {
    tests = {
      smoke-test = nixosTests.bcachefs;
      inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
    };

    updateScript = writeScript "update-bcachefs-tools-and-cargo-lock.sh" ''
      #!/usr/bin/env nix-shell
      #!nix-shell -i bash -p curl jq common-updater-scripts
      res="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
        -sL "https://api.github.com/repos/${finalAttrs.src.owner}/${finalAttrs.src.repo}/tags?per_page=1")"

      version="$(echo $res | jq '.[0].name | split("v") | .[1]' --raw-output)"
      update-source-version ${finalAttrs.pname} "$version" --ignore-same-hash

      curl "https://raw.githubusercontent.com/${finalAttrs.src.owner}/${finalAttrs.src.repo}/v$version/rust-src/Cargo.lock" > \
        "$(git rev-parse --show-toplevel)/pkgs/tools/filesystems/bcachefs-tools/Cargo.lock"
    '';
  };

  enableParallelBuilding = true;

  meta = with lib; {