nix: improve format app

This commit is contained in:
Harsh Shandilya 2024-01-06 02:03:54 +05:30
parent 58c6f64e14
commit 20e7bb4211
14 changed files with 30 additions and 40 deletions

View File

@ -14,7 +14,7 @@ export SDKMAN_DIR="${HOME}/.sdkman"
[ -d "${HOME}/bin" ] && export PATH="${HOME}/bin:${PATH}"
# Sexy colors in `ls`
if type vivid &>/dev/null; then
if type vivid &> /dev/null; then
LS_COLORS="$(vivid generate snazzy)"
export LS_COLORS
fi
@ -31,7 +31,7 @@ for DIR in "${HOME}"/bash_completion.d "${HOME}"/.nix-profile/share/bash-complet
done
# Enable pass user extensions
if type pass &>/dev/null; then
if type pass &> /dev/null; then
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
fi
@ -53,13 +53,13 @@ if [ -d "${HOME}"/Library/Android/sdk/ ]; then
fi
# Nano love, or is it?
if type micro &>/dev/null; then
if type micro &> /dev/null; then
export EDITOR=micro
export MICRO_TRUECOLOR=1
fi
# Setup zoxide
if type zoxide &>/dev/null; then
if type zoxide &> /dev/null; then
alias cd=z
fi

View File

@ -158,16 +158,6 @@
type = "app";
program = let
pkgs = pkgsFor system;
inherit (pkgs) lib;
getDirFiles = dir:
builtins.map (x: "${dir}/" + x) (builtins.attrNames (builtins.readDir dir));
fmtTargetsStr = lib.concatStringsSep " " ([
"darwin-init"
"shell-init"
"x"
]
++ getDirFiles ./scripts);
script = pkgs.writeShellApplication {
name = "format";
runtimeInputs = with pkgs; [
@ -178,10 +168,10 @@
];
text = ''
set -euo pipefail
shfmt -w -s -i 2 -ci ${fmtTargetsStr};
alejandra --quiet .
shfmt --write --simplify --language-dialect bash --indent 2 --case-indent --space-redirects .;
deadnix --edit
statix check .
alejandra --quiet .
'';
};
in "${script}/bin/format";

View File

@ -143,7 +143,7 @@
};
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
programs.nix-ld.libraries = [
];
services.rucksack = let

View File

@ -1,4 +1,4 @@
{lib, ...}: {
{
i18n = let
locale = "en_US.UTF-8";
in {

View File

@ -4,11 +4,11 @@
...
}: let
inherit (lib) filterAttrs;
flakes = filterAttrs (name: value: value ? outputs) inputs;
flakes = filterAttrs (_name: value: value ? outputs) inputs;
nixRegistry =
builtins.mapAttrs
(name: v: {flake = v;})
(_name: v: {flake = v;})
flakes;
in {
nix = {

View File

@ -6,25 +6,25 @@
alias pidcat='pidcat -i ResourceType -i chatty -i AppCompatDelegate -i EGL_emulation'
alias today='date +"%F"'
alias gi=git
if type hub &>/dev/null; then
if type hub &> /dev/null; then
alias git=hub
fi
if type bat &>/dev/null; then
if type bat &> /dev/null; then
alias cat='bat --style=grid,header --theme="zenburn"'
fi
if type micro &>/dev/null; then
if type micro &> /dev/null; then
alias nano=micro
fi
if type aria2c &>/dev/null; then
if type aria2c &> /dev/null; then
alias batch="aria2c --conditional-get true --continue true --auto-file-renaming=false --input-file"
fi
if type fd &>/dev/null; then
if type fd &> /dev/null; then
alias findjars="fd -Itf jar$ build"
alias findapks="fd -Itf apk$"
fi
if type yt-dlp &>/dev/null; then
if type yt-dlp &> /dev/null; then
alias ytdl="yt-dlp --downloader aria2c --downloader-args aria2c:'-c -j 3 -x 3 -s 3 -k 1M' -N 5"
fi
if type nix &>/dev/null; then
if type nix &> /dev/null; then
alias nix="nix --print-build-logs"
fi

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT
# shellcheck disable=SC1090
source ~/.env 2>/dev/null
source ~/.env 2> /dev/null
CL_BOLD="\033[1m"
CL_INV="\033[7m"

View File

@ -14,6 +14,6 @@ function mkexecjar() {
if [ -z "${EXEC_FILE}" ]; then
EXEC_FILE="${JAR_FILE%.*}"
fi
printf "#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n" >"${EXEC_FILE}"
cat "${JAR_FILE}" >>"${EXEC_FILE}"
printf "#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n" > "${EXEC_FILE}"
cat "${JAR_FILE}" >> "${EXEC_FILE}"
}

View File

@ -165,7 +165,7 @@ function imgur() {
FILE="${1}"
USE_CLIPBOARD="$(display_exists)"
LINK="$(curl --request POST --url https://api.imgur.com/3/image --header "authorization: Client-ID $(pass api/imgur)" \
--header 'content-type: multipart/form-data;' -F "image=@${FILE:?}" 2>/dev/null | jq .data.link | sed 's/"//g')"
--header 'content-type: multipart/form-data;' -F "image=@${FILE:?}" 2> /dev/null | jq .data.link | sed 's/"//g')"
if [ -z "${USE_CLIPBOARD}" ]; then
echo "${LINK}"
else

View File

@ -30,7 +30,7 @@ function get_release_assets() {
RELEASE_ID=$(curl --silent "https://api.github.com/repos/${1:?}/releases/latest" | jq -r .id)
else
# Get all releases from the v3 API, get the id and tag_name fields (called name in the slice) for each item, and write it to a temporary file
curl --silent "https://api.github.com/repos/${REPOSITORY}/releases" | jq '.[] | {id: .id, name: .tag_name}' >"${TMP_FILE}"
curl --silent "https://api.github.com/repos/${REPOSITORY}/releases" | jq '.[] | {id: .id, name: .tag_name}' > "${TMP_FILE}"
# Stream across the data we sliced earlier, printing the id and name as space separated values, then cleanly filter the one we need using grep and awk
RELEASE_ID=$(jq -r '"\(.id) \(.name)"' "${TMP_FILE}" | grep "${RELEASE_TAG}" | awk '{print $1}') # Get the ID of the latest release
fi
@ -57,7 +57,7 @@ function gcp() {
OG_COMMITISH="HEAD"
fi
COMMITISH="$(git rev-parse --short "${OG_COMMITISH}" 2>/dev/null)"
COMMITISH="$(git rev-parse --short "${OG_COMMITISH}" 2> /dev/null)"
if [ -z "${COMMITISH}" ]; then
reportWarning "Failed to find a commit for '${OG_COMMITISH}'"

View File

@ -33,7 +33,7 @@ function buildmod() {
else
fd "$(basename "$(pwd)")" "${DEST_DIR}" -X rm -v
fi
done <gradle.properties
done < gradle.properties
findjars | rg -v '\-(sources|dev|api)\.jar' | xargs -I {} mv -v {} "${DEST_DIR}"
}

View File

@ -42,7 +42,7 @@ function pkgdiff() {
}
function endtask() {
for pid in $(pgrep "${1:?}"); do kill -9 "${pid}" 2>/dev/null; done
for pid in $(pgrep "${1:?}"); do kill -9 "${pid}" 2> /dev/null; done
}
function cpuinfo() {

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT
function clip() {
pbcopy <"${1:-/dev/stdin}"
pbcopy < "${1:-/dev/stdin}"
}
function clrclip() {

View File

@ -44,7 +44,7 @@ if [ -n "${ANDROID_HOME}" ]; then
fi
# Sexy colors in `ls`
if type vivid &>/dev/null; then
if type vivid &> /dev/null; then
LS_COLORS="$(vivid generate snazzy)"
export LS_COLORS
fi
@ -61,18 +61,18 @@ for DIR in "${HOME}"/bash_completion.d "${HOME}"/.nix-profile/share/bash-complet
done
# Enable pass user extensions
if type pass &>/dev/null; then
if type pass &> /dev/null; then
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
fi
# Nano love, or is it?
if type micro &>/dev/null; then
if type micro &> /dev/null; then
export EDITOR=micro
export MICRO_TRUECOLOR=1
fi
# Setup zoxide
if type zoxide &>/dev/null; then
if type zoxide &> /dev/null; then
alias cd=z
fi