nix: disable --pure
[sourcephile-nix.git] / pkgs / tools / system / smartmontools / smartctl-tbw / default.nix
index f35db10ae5c75a71b0b626d11bd56df5503bed1e..d8b51072e9eb95c5e5b2eb4a122611a2a50633a4 100644 (file)
@@ -7,58 +7,33 @@
 , writeShellScriptBin
 , utillinux
 }:
-let
-  PATH = stdenv.lib.concatStringsSep ":"
-           [ "${coreutils}/bin"
-             "${gawk}/bin"
-             "${gnused}/bin"
-             "${sudo}/bin"
-             "${utillinux}/bin"
-           ];
-in
-stdenv.mkDerivation rec {
-  pname = "smartctl-tbw";
-  version = "1.0";
-  name = "${pname}-${version}";
-
-  src = writeShellScriptBin "smartctl-tbw" ''
-    export PATH=${PATH}
-    device=''${1:-/dev/sda}
-    sudo ${smartmontools}/bin/smartctl -A $device |
-    awk '
-      $0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n",  $2, $10, $10 / 24, $10 / 24 / 365.25 }
-      $0 ~ /Total_LBAs_Written/ {
-          lbas=$10;
-          bytes=$10 * 512;
-          mb= bytes / 1024^2;
-          gb= bytes / 1024^3;
-          tb= bytes / 1024^4;
-          printf "%s / %s  / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb
-          printf "mean writes per hour:  / %.2f",  mb/poh
-      }
-      $0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10}
-      $0 ~ /Wear_Leveling_Count/ { printf "%s / %d (%% health)\n", $2, int($4) }
-    ' |
-    sed -e 's:/:@:' |
-    sed -e "s\$^\$$device @ \$" |
-    column -ts@
-  '';
-
-  buildInputs = [
-    gawk
-    coreutils
-    gnused
-    smartmontools
-    sudo
-    utillinux
+let PATH = stdenv.lib.concatStringsSep ":"
+  [ "${coreutils}/bin"
+    "${gawk}/bin"
+    "${gnused}/bin"
+    "${sudo}/bin"
+    "${utillinux}/bin"
   ];
-  installPhase = ''
-    cp -r . $out
-  '';
-
-  meta = {
-    description = "Wrapper around smartctl to print the Total-Bytes-Written of disks";
-    license = stdenv.lib.licenses.gpl3Plus;
-    platforms = stdenv.lib.platforms.all;
-  };
-}
+in
+writeShellScriptBin "smartctl-tbw" ''
+  export PATH=${PATH}
+  device=''${1:-/dev/sda}
+  sudo ${smartmontools}/bin/smartctl -A $device |
+  { awk '
+    $0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n",  $2, $10, $10 / 24, $10 / 24 / 365.25 }
+    $0 ~ /Total_LBAs_Written/ {
+        lbas = $10;
+        bytes = $10 * 512;
+        mb = bytes / 1024^2;
+        gb = bytes / 1024^3;
+        tb = bytes / 1024^4;
+        printf "%s / %s  / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb
+        printf "mean writes per hour:  / %.2f",  mb/poh
+    }
+    $0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10}
+    $0 ~ /Wear_Leveling_Count/ { printf "%s / %d (%% health)\n", $2, int($4) }
+  '; echo; } |
+  sed -e 's:/:@:' |
+  sed -e "s\$^\$$device @ \$" |
+  column -ts@
+''