From 29f294cae0b48735402a88797a3c3169000372fb Mon Sep 17 00:00:00 2001 From: Thorn Avery Date: Sat, 3 Oct 2020 21:37:21 +1300 Subject: [PATCH] initial commit --- .gitignore | 3 +++ README.md | 21 +++++++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 29 +++++++++++++++++++++++++++++ swatch.sh | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100755 swatch.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09b71b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/old +/result +/init.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ae44af --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Swatch +Swatch Internet Time + +## Requirements +* `getopts` +* `gawk` + +## Usage +`swatch` returns current swatch beats in format @XXX.YYY +`swatch -s` returns in format @XXX +`swatch -h` displays help + +## Installation +`swatch.sh` contains the script, and can be added to your path. + +### Nix Flake + +`flake.nix` and `flake.lock` define a working nix flake for installing the script. + +## Author +Shaun Kerr - [s@p7.co.nz](mailto:s@p7.co.nz) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..95b5441 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1601475821, + "narHash": "sha256-7AI8j/xq5slauMGwC3Dp2K9TKDyDtBXBebeyWsE9euE=", + "owner": "Nixos", + "repo": "nixpkgs", + "rev": "b4db68ff563895eea6aab4ff24fa04ef403dfe14", + "type": "github" + }, + "original": { + "owner": "Nixos", + "ref": "nixos-20.03", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1ff9b35 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + description = "swatch beat internet time"; + inputs.nixpkgs.url = github:Nixos/nixpkgs/nixos-20.03; + outputs = { self, nixpkgs }: { + defaultPackage.x86_64-linux = + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation rec { + name = "swatch-${version}"; + version = "1.0.0"; + meta = { + description = "Display the current swatch beats"; + longDescription = '' + Prints the current Swatch Internet Time. + Optional short form. + ''; + homepage = https://github.com/techieAgnostic/swatch; + maintainers = [ "Shaun Kerr - s@p7.co.nz" ]; + platforms = stdenv.lib.platforms.all; + }; + src = self; + buildInputs = [ + gawk + utillinux + ]; + buildPhase = "cp ./swatch.sh ./swatch"; + installPhase = "mkdir -p $out/bin; install -t $out/bin swatch"; + }; + }; +} diff --git a/swatch.sh b/swatch.sh new file mode 100755 index 0000000..ab91bb6 --- /dev/null +++ b/swatch.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +## +# Displays the current Swatch Internet Time +# +# -shaun kerr. +## + +set -e + +function usage { + cat <