diff options
Diffstat (limited to '')
-rw-r--r-- | packages/bruh.nix | 25 | ||||
-rw-r--r-- | packages/mpv-autosub.nix | 20 | ||||
-rw-r--r-- | packages/myip.nix | 10 | ||||
-rw-r--r-- | packages/nixfiles.nix | 46 | ||||
-rw-r--r-- | packages/throttled.nix | 36 |
5 files changed, 76 insertions, 61 deletions
diff --git a/packages/bruh.nix b/packages/bruh.nix index 62fe557..2b274f1 100644 --- a/packages/bruh.nix +++ b/packages/bruh.nix @@ -1,18 +1,20 @@ { alsa-utils, fetchFromGitHub, + lib, stdenv, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "bruh"; version = "2.1"; - src = fetchFromGitHub { - owner = "kejpies"; - repo = pname; - rev = version; - hash = "sha256-Uw6Qes0IZkkfBchFnvnX9l1ZG5T5pyExmV7yUJLPOJ0="; - }; + src = with finalAttrs; + fetchFromGitHub { + owner = "kejpies"; + repo = pname; + rev = version; + hash = "sha256-Uw6Qes0IZkkfBchFnvnX9l1ZG5T5pyExmV7yUJLPOJ0="; + }; postPatch = '' substituteInPlace bruh.c \ @@ -20,4 +22,11 @@ stdenv.mkDerivation rec { ''; makeFlags = ["PREFIX=$(out)"]; -} + + meta = with lib; { + description = "Bruh sound, but as a program"; + inherit (finalAttrs.src.meta) homepage; + license = licenses.gpl3Only; + maintainers = with maintainers; [azahi]; + }; +}) diff --git a/packages/mpv-autosub.nix b/packages/mpv-autosub.nix index 3d8171d..e3fc221 100644 --- a/packages/mpv-autosub.nix +++ b/packages/mpv-autosub.nix @@ -1,15 +1,17 @@ { fetchFromGitHub, + lib, + mpv-unwrapped, python3Packages, stdenvNoCC, }: -stdenvNoCC.mkDerivation rec { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "mpv-autosub"; version = "unstable-2021-06-29"; src = fetchFromGitHub { owner = "davidde"; - repo = pname; + repo = finalAttrs.pname; rev = "35115355bd339681f97d067538356c29e5b14afa"; hash = "sha256-BKT/Tzwl5ZA4fbdc/cxz0+CYc1zyY/KOXc58x5GYow0="; }; @@ -25,8 +27,20 @@ stdenvNoCC.mkDerivation rec { ''; installPhase = '' + runHook preInstall + install -Dm644 autosub.lua $out/share/mpv/scripts/autosub.lua + + runHook postInstall ''; passthru.scriptName = "autosub.lua"; -} + + meta = with lib; { + description = "Automatic downloading of subtitles for MPV"; + inherit (finalAttrs.src.meta) homepage; + license = licenses.mit; + inherit (mpv-unwrapped.meta) platforms; + maintainers = with maintainers; [azahi]; + }; +}) diff --git a/packages/myip.nix b/packages/myip.nix index a830139..67ea1ed 100644 --- a/packages/myip.nix +++ b/packages/myip.nix @@ -1,12 +1,22 @@ { dnsutils, + lib, writeShellApplication, }: writeShellApplication { name = "myip"; + runtimeInputs = [dnsutils]; + text = '' dig -4 +short @resolver1.opendns.com myip.opendns.com A dig -6 +short @resolver1.opendns.com myip.opendns.com AAAA ''; + + meta = with lib; { + description = "A dumb tool to get host's current public IP"; + homepage = "https://git.azahi.cc/nixfiles"; + license = licenses.wtfpl; + maintainers = with maintainers; [azahi]; + }; } diff --git a/packages/nixfiles.nix b/packages/nixfiles.nix index 9b16e84..b534e3c 100644 --- a/packages/nixfiles.nix +++ b/packages/nixfiles.nix @@ -1,8 +1,10 @@ { git, jq, + lib, nix, openssh, + stdenv, symlinkJoin, writeShellApplication, writeTextDir, @@ -11,13 +13,14 @@ bin = writeShellApplication { name = "nixfiles"; - runtimeInputs = [ - git - jq - nix - openssh - xdg-utils - ]; + runtimeInputs = + [ + git + jq + nix + openssh + ] + ++ lib.optional (!stdenv.isDarwin) xdg-utils; # Shamelessly appropriated from https://github.com/ncfavier/config. # Hopefully Naïm will not sue me for copyright infrigment. @@ -26,7 +29,7 @@ cmd=$1 shift case $cmd in - repl|eval|build|rev) + repl|eval|nix-build|rev) args=() flakeArgs=() for arg do case $arg in -w|--wip) @@ -39,10 +42,15 @@ set -- "''${args[@]}" ;;& compare) + if command -v xdg-open >/dev/null; then + open="xdg-open" + else + open="open" + fi input=$1 # shellcheck disable=SC1090 - . <(nix flake metadata --json nixfiles | jq -r --arg input "$input" ' - def browse($url): @sh "xdg-open \($url)"; + . <(nix flake metadata --json nixfiles | jq -r --arg open "$open" --arg input "$input" ' + def browse($url): @sh "$open \($url)"; .locks.nodes[$input] | if .locked.type == "github" then browse("https://github.com/\(.locked.owner)/\(.locked.repo)/compare/\(.locked.rev)...\(.original.ref // "master")") @@ -78,13 +86,14 @@ eval) exec nix eval "''${flakeArgs[@]}" -f ~/.nix-defexpr --json "$@" | jq -r . ;; - build) + nix-build) # https://github.com/NixOS/nix/issues/6661 exec nix-build --log-format bar-with-logs "''${flakeArgs[@]}" ~/.nix-defexpr -A "$@" ;; specialise) name=$1 shift + # Assumes that sudo is already configured. Has setuid baked in if needed and etc. exec sudo /run/current-system/specialisation/"$name"/bin/switch-to-configuration switch ;; revert) @@ -96,6 +105,7 @@ exec nix shell -v ".#$attr" "$@" -c home-manager-generation ;; @*) + # Assumes that hosts are configured in the OpenSSH configuration. host=''${cmd#@} hostname=$(ssh -q "$host" 'echo "$HOSTNAME"') exec nixos-rebuild -v --flake ".#$hostname" --target-host "$host" --use-remote-sudo "$@" @@ -130,13 +140,13 @@ if [[ $cur == @* ]]; then _known_hosts_real -a -- "$cur" else - __compreply -W 'compare update repl eval bld specialise revert home build build-vm test switch boot' + __compreply -W 'compare update repl eval nix-build specialise revert home boot build build-vm build-vm-with-bootloader dry-activate dry-build edit switch test' fi else case ''${words[1]} in compare|update|rev) __complete_nix_cmd "$cword" nix flake lock "$nixfiles" --update-input ;; - repl|eval|bld) + repl|eval|nix-build) compreply -W '-w --wip' ;;& repl) @@ -151,7 +161,7 @@ home) __complete_nix_cmd 2 nix shell "$nixfiles" ;; - build|switch) + switch) __complete_nix_cmd 2 nix build "$nixfiles" ;; esac fi @@ -161,5 +171,13 @@ in symlinkJoin { name = "nixfiles"; + paths = [bin bashCompletion]; + + meta = with lib; { + description = "A helper utility to manage NixOS configurations with Nix flakes"; + homepage = "https://git.azahi.cc/nixfiles"; + license = licenses.wtfpl; + maintainers = with maintainers; [azahi]; + }; } diff --git a/packages/throttled.nix b/packages/throttled.nix deleted file mode 100644 index 1c0f853..0000000 --- a/packages/throttled.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - fetchFromGitHub, - kmod, - python3Packages, - stdenv, -}: -stdenv.mkDerivation rec { - pname = "throttled"; - version = "git"; - - src = fetchFromGitHub { - owner = "erpalma"; - repo = pname; - rev = "1dd726672f0b11b813d4c7b63e0157becde7a013"; - hash = "sha256-0MsPp6y4r/uZB2SplKV+SAiJoxIs2jgOQmQoQQ2ZKwI="; - }; - - nativeBuildInputs = with python3Packages; [wrapPython]; - - pythonPath = - [kmod] - ++ (with python3Packages; [configparser dbus-python pygobject3]); - - installPhase = '' - runHook preInstall - - install -Dm755 -t $out/opt/throttled throttled.py - install -Dm644 -t $out/opt/throttled mmio.py - - runHook postInstall - ''; - - postFixup = '' - wrapPythonProgramsIn $out/opt/throttled "$out $pythonPath" - ''; -} |