about summary refs log tree commit diff
path: root/packages
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
committerAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
commit61b94f0dd06cac0f7dcd38cce80f2a7ab8376098 (patch)
treeb703a9fe11eae6c4cae4e4682f02caf0caa171d0 /packages
2022-08-12
Diffstat (limited to 'packages')
-rw-r--r--packages/bruh.nix17
-rw-r--r--packages/mpv-autosub.nix28
-rw-r--r--packages/myip.nix12
-rw-r--r--packages/nixfiles.nix82
-rw-r--r--packages/throttled.nix36
-rw-r--r--packages/ultimmc.nix63
6 files changed, 238 insertions, 0 deletions
diff --git a/packages/bruh.nix b/packages/bruh.nix
new file mode 100644
index 0000000..a555fcc
--- /dev/null
+++ b/packages/bruh.nix
@@ -0,0 +1,17 @@
+{
+  fetchFromGitHub,
+  stdenv,
+}:
+stdenv.mkDerivation rec {
+  pname = "bruh";
+  version = "2.1";
+
+  src = fetchFromGitHub {
+    owner = "kejpies";
+    repo = pname;
+    rev = version;
+    hash = "sha256-Uw6Qes0IZkkfBchFnvnX9l1ZG5T5pyExmV7yUJLPOJ0=";
+  };
+
+  makeFlags = ["PREFIX=$(out)"];
+}
diff --git a/packages/mpv-autosub.nix b/packages/mpv-autosub.nix
new file mode 100644
index 0000000..cebab76
--- /dev/null
+++ b/packages/mpv-autosub.nix
@@ -0,0 +1,28 @@
+{
+  fetchFromGitHub,
+  python3Packages,
+  stdenvNoCC,
+}:
+stdenvNoCC.mkDerivation rec {
+  pname = "mpv-autosub";
+  version = "unstable-";
+
+  src = fetchFromGitHub {
+    owner = "davidde";
+    repo = pname;
+    rev = "35115355bd339681f97d067538356c29e5b14afa";
+    hash = "sha256-BKT/Tzwl5ZA4fbdc/cxz0+CYc1zyY/KOXc58x5GYow0=";
+  };
+
+  postPatch = ''
+    substituteInPlace autosub.lua \
+      --replace '/home/david/.local/bin/subliminal' \
+      '${python3Packages.subliminal}/bin/subliminal'
+  '';
+
+  installPhase = ''
+    install -Dm644 autosub.lua $out/share/mpv/scripts/autosub.lua
+  '';
+
+  passthru.scriptName = "autosub.lua";
+}
diff --git a/packages/myip.nix b/packages/myip.nix
new file mode 100644
index 0000000..a830139
--- /dev/null
+++ b/packages/myip.nix
@@ -0,0 +1,12 @@
+{
+  dnsutils,
+  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
+  '';
+}
diff --git a/packages/nixfiles.nix b/packages/nixfiles.nix
new file mode 100644
index 0000000..90a5865
--- /dev/null
+++ b/packages/nixfiles.nix
@@ -0,0 +1,82 @@
+{
+  git,
+  jq,
+  lib,
+  nix,
+  nixfilesSrc ? "$HOME/src/nixfiles",
+  openssh,
+  writeShellApplication,
+}:
+writeShellApplication {
+  name = "nixfiles";
+  runtimeInputs = [git jq nix openssh];
+  text = ''
+    nixfiles=${lib.escapeShellArg nixfilesSrc}
+    cmd="$1"
+    shift
+    case $cmd in
+    update)
+      if (( $# )); then
+        args=()
+        for input do args+=(--update-input "$input"); done
+        exec nix flake lock "$nixfiles" "''${args[@]}"
+      else
+        exec nix flake update -v "$nixfiles"
+      fi
+      ;;
+    rev)
+      nix flake metadata --json nixfiles |
+        if (( $# )); then
+          jq -r --arg input "$1" '.locks.nodes[$input].locked.rev'
+        else
+          jq -r '.revision // "dirty"'
+        fi
+      ;;
+    repl|eval|build)
+      args=()
+      for arg do case $arg in
+        -w|--wip) args+=(--override-flake config "$nixfiles")
+        ;;
+        *) args+=("$arg")
+      esac done
+      set -- "''${args[@]}"
+      ;;&
+    repl)
+      exec nix repl ~/.nix-defexpr "$@"
+      ;;
+    eval)
+      exec nix eval -f ~/.nix-defexpr --json "$@" | jq -r .
+      ;;
+    build)
+      exec nix build -f ~/.nix-defexpr --json "$@" | jq -r .
+      ;;
+    home)
+      attr="nixosConfigurations.$HOSTNAME.config.hm.home.activationPackage"
+      export VERBOSE=1
+      exec nix shell --verbose "$nixfiles#$attr" "$@" --command home-manager-generation
+      ;;
+    specialise)
+      name=$1
+      shift
+      exec sudo /run/current-system/specialisation/"$name"/bin/switch-to-configuration switch
+      ;;
+    revert)
+      exec sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
+      ;;
+    test-headless)
+      exec nixos-rebuild build-vm --verbose --print-build-logs --flake "$nixfiles#test-headless" "$@"
+      ;;
+    test-headful)
+      exec nixos-rebuild build-vm --verbose --print-build-logs --flake "$nixfiles#test-headful" "$@"
+      ;;
+    @*)
+      host="''${cmd#@}"
+      hostname="$(ssh -q "$host" 'echo "$HOSTNAME"')"
+      exec nixos-rebuild -v --flake "$nixfiles#$hostname" --target-host "$host" --use-remote-sudo "$@"
+      ;;
+    *)
+      exec nixos-rebuild -v --flake "$nixfiles" --use-remote-sudo "$cmd" "$@"
+      ;;
+    esac
+  '';
+}
diff --git a/packages/throttled.nix b/packages/throttled.nix
new file mode 100644
index 0000000..ff896cf
--- /dev/null
+++ b/packages/throttled.nix
@@ -0,0 +1,36 @@
+{
+  fetchFromGitHub,
+  kmod,
+  python3,
+  stdenv,
+}:
+stdenv.mkDerivation rec {
+  pname = "throttled";
+  version = "unstable-2022-06-30";
+
+  src = fetchFromGitHub {
+    owner = "erpalma";
+    repo = pname;
+    rev = "ab9641a93a409bdc7fca6889ff23ca5a685e5a77";
+    hash = "sha256-Zd+rTsVDkw9mq6k2OkMy+HxyYsl3ADy1fEM/1e/jxAs=";
+  };
+
+  nativeBuildInputs = with python3.pkgs; [wrapPython];
+
+  pythonPath =
+    (with python3.pkgs; [configparser dbus-python pygobject3])
+    ++ [kmod];
+
+  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"
+  '';
+}
diff --git a/packages/ultimmc.nix b/packages/ultimmc.nix
new file mode 100644
index 0000000..e90d5bd
--- /dev/null
+++ b/packages/ultimmc.nix
@@ -0,0 +1,63 @@
+{
+  cmake,
+  fetchFromGitHub,
+  jdk,
+  makeDesktopItem,
+  qtbase,
+  stdenv,
+  wrapQtAppsHook,
+  zlib,
+}:
+stdenv.mkDerivation rec {
+  pname = "UltimMC";
+  version = "unstable-2022-06-09";
+
+  src = fetchFromGitHub {
+    owner = "UltimMC";
+    repo = "Launcher";
+    rev = "b7c9b27ed6fb047da7fab5e4cee99b298b9e9811";
+    hash = "sha256-xmkflvtOSLMTuzAKovgOLjgpbR8j53bkGV3QZRsQItw=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [cmake jdk wrapQtAppsHook];
+
+  buildInputs = [qtbase zlib];
+
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace 'LIBRARY_DEST_DIR "bin"' 'LIBRARY_DEST_DIR "lib"' \
+      --replace 'JARS_DEST_DIR "bin/jars"' 'JARS_DEST_DIR "share/${pname}/jar"'
+
+    substituteInPlace launcher/Application.cpp \
+      --replace '"jars"' '"../share/${pname}/jar"';
+  '';
+
+  cmakeFlags = ["-DCMAKE_BUILD_TYPE=Release"];
+
+  desktopItem = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    icon = pname;
+    desktopName = pname;
+    genericName = "Custom Minecraft launcher";
+    categories = ["Game"];
+  };
+
+  dontWrapQtApps = true;
+
+  postInstall = ''
+    rm $out/${pname}
+
+    wrapProgram $out/bin/${pname} \
+      --add-flags "--dir \''${XDG_DATA_HOME:-~/.local/share}/${pname}" \
+      "''${qtWrapperArgs[@]}"
+
+    install -Dm644 \
+      ${desktopItem}/share/applications/${pname}.desktop \
+      $out/share/applications/${pname}.desktop
+    install -Dm644 \
+      $src/notsecrets/logo.svg \
+      $out/share/icons/hicolor/scalable/apps/${pname}.svg
+  '';
+}

Consider giving Nix/NixOS a try! <3