mirror of
https://github.com/ItsDrike/nixdots
synced 2025-06-29 10:40:43 +00:00
Add bitcoin script
This commit is contained in:
parent
41cd22ea33
commit
42155645b0
7 changed files with 45 additions and 2 deletions
|
@ -3,5 +3,6 @@ _: {
|
|||
./shared.nix
|
||||
./desktop.nix
|
||||
./wayland.nix
|
||||
./scripts
|
||||
];
|
||||
}
|
||||
|
|
11
home/packages/cli/scripts/default.nix
Normal file
11
home/packages/cli/scripts/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
|
||||
scriptPkgs = (import ./packages {inherit pkgs;});
|
||||
in {
|
||||
home.packages = with scriptPkgs; [
|
||||
bitcoin
|
||||
];
|
||||
}
|
18
home/packages/cli/scripts/packages/bitcoin.nix
Normal file
18
home/packages/cli/scripts/packages/bitcoin.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{pkgs, ...}:
|
||||
(pkgs.writeShellApplication {
|
||||
name = "bitcoin";
|
||||
runtimeInputs = with pkgs; [coreutils curl jq];
|
||||
text = ''
|
||||
#!/bin/sh
|
||||
|
||||
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR')
|
||||
|
||||
if [ "$BTC_DATA" != "ERR" ]; then
|
||||
BTC_PRICE=$(echo "$BTC_DATA" | jq -r ".bpi.USD.rate_float")
|
||||
BTC_PRICE=$(printf "%.0f" "$BTC_PRICE")
|
||||
echo \$"$BTC_PRICE"
|
||||
else
|
||||
echo "N/A"
|
||||
fi
|
||||
'';
|
||||
})
|
10
home/packages/cli/scripts/packages/default.nix
Normal file
10
home/packages/cli/scripts/packages/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
packages = {
|
||||
bitcoin = pkgs.callPackage ./bitcoin.nix {};
|
||||
};
|
||||
in
|
||||
packages
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue