diff options
author | sefidel <contact@sefidel.net> | 2023-02-15 01:08:48 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2023-02-15 01:09:13 +0900 |
commit | f699d07c3050d6edf8fc041f62e6eb120340c7cc (patch) | |
tree | d5b07087a9049ef4b9b1dfbc9d6418f363a76883 /home/profiles | |
parent | 6414bd110b8312593919fe3002e94e21a06deae0 (diff) | |
download | nixrc-f699d07c3050d6edf8fc041f62e6eb120340c7cc.tar.gz nixrc-f699d07c3050d6edf8fc041f62e6eb120340c7cc.zip |
feat(home/kompakt): darwin -> linux
Diffstat (limited to 'home/profiles')
-rw-r--r-- | home/profiles/base-darwin/default.nix | 2 | ||||
-rw-r--r-- | home/profiles/base/default.nix | 2 | ||||
-rwxr-xr-x | home/profiles/base/scripts/0x0.nix | 87 |
3 files changed, 89 insertions, 2 deletions
diff --git a/home/profiles/base-darwin/default.nix b/home/profiles/base-darwin/default.nix index 13546b7..332bb2b 100644 --- a/home/profiles/base-darwin/default.nix +++ b/home/profiles/base-darwin/default.nix @@ -1,8 +1,6 @@ { config, lib, inputs, pkgs, self, ... }: let cfg = config.profiles.base-darwin; - - inherit (self.packages.aarch64-darwin) neovim; in { imports = [ diff --git a/home/profiles/base/default.nix b/home/profiles/base/default.nix index dd241ac..98f767f 100644 --- a/home/profiles/base/default.nix +++ b/home/profiles/base/default.nix @@ -100,6 +100,8 @@ in (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)) pkgs.go pkgs.gcc + + (pkgs.writeShellScriptBin "0x0" (import ./scripts/0x0.nix)) ]; diff --git a/home/profiles/base/scripts/0x0.nix b/home/profiles/base/scripts/0x0.nix new file mode 100755 index 0000000..a246b6f --- /dev/null +++ b/home/profiles/base/scripts/0x0.nix @@ -0,0 +1,87 @@ +'' + # Copyright © 2018-2019 Hugo Locurcio and contributors + # + # Permission is hereby granted, free of charge, to any person obtaining a copy + # of this software and associated documentation files (the "Software"), to deal + # in the Software without restriction, including without limitation the rights + # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + # copies of the Software, and to permit persons to whom the Software is + # furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included in all + # copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + # SOFTWARE. + + set -euo pipefail + IFS=$'\n\t' + + if [[ -t 1 ]]; then + # stdout is a TTY, enable colors + STYLE_COMMAND="\\e[0;97m" + STYLE_ARG="\\e[0;96m" + STYLE_ERROR="\\e[91m" + STYLE_BOLD="\\e[1m" + STYLE_NORMAL="\\e[22m" + STYLE_RESET="\\e[0m" + else + # stdout is not a TTY, disable colors + STYLE_COMMAND="" + STYLE_ARG="" + STYLE_ERROR="" + STYLE_BOLD="" + STYLE_NORMAL="" + STYLE_RESET="" + fi + + # Prints an error message to stderr + print_error() { + echo -e "''${STYLE_ERROR}''${STYLE_BOLD}Error:''${STYLE_NORMAL} $1''${STYLE_RESET}" >&2 + exit 1 + } + + print_help() { + base="''${0##*/}" + echo -e "''${STYLE_BOLD}0x0, a wrapper script for https://0x0.st/''${STYLE_RESET}\n" + echo -e " Upload a file:" + echo -e " ''${STYLE_COMMAND}''${base} ''${STYLE_ARG}<file>''${STYLE_RESET}\n" + echo -e " Upload from an URL (the file won't be fetched locally):" + echo -e " ''${STYLE_COMMAND}''${base} ''${STYLE_ARG}<url>''${STYLE_RESET}\n" + echo -e " Upload from standard input:" + echo -e " ''${STYLE_COMMAND}''${base} ''${STYLE_ARG}-''${STYLE_RESET}\n" + echo -e "The uploaded file's URL is printed to standard output when the upload is completed." + } + + case "''${1:-}" in + # Exit with code 0 only if help was explicitly requested + -h|--help) + print_help + exit 0 + ;; + ''') + print_help + exit 1 + ;; + esac + + if [[ -f "$1" || "$1" = '-' ]]; then + # Upload from file or stdin + curl -F "file=@$1" https://0x0.st + + elif [[ "$1" =~ ^https?://.* ]]; then + # Upload from URL + curl -F "url=$1" https://0x0.st + + elif [[ -d "$1" ]]; then + print_error "\"$1\" is a directory." + + else + print_error "\"$1\": no such file." + fi +'' |