about summary refs log tree commit diff stats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hm/soispha/pkgs/scripts.nix58
1 files changed, 41 insertions, 17 deletions
diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix
index 76e8cace..e0b5a086 100644
--- a/hm/soispha/pkgs/scripts.nix
+++ b/hm/soispha/pkgs/scripts.nix
@@ -5,10 +5,10 @@
   config,
   ...
 }: let
-  write_script = {
+  write_shell = {
     name,
     path,
-    dependencies,
+    dependencies ? [],
     keep_path ? false,
   }:
     if keep_path
@@ -24,8 +24,32 @@
         src = ./scripts/${path}/${name};
         dependencies = dependencies ++ [pkgs.dash];
       };
+  write_python = {
+    name,
+    path,
+    dependencies_system ? [],
+    dependencies_python ? _: [],
+    keep_path ? false,
+  }: let
+    src = ./scripts/${path}/${name};
+    dependencies =
+      [(pkgs.python3.withPackages (ps: dependencies_python ps))]
+      ++ dependencies_system;
+    path_setting =
+      if keep_path
+      then "--prefix PATH :"
+      else "--set PATH";
+  in
+    pkgs.runCommandLocal name {
+      nativeBuildInputs = [pkgs.makeWrapper] ++ dependencies;
+    }
+    ''
+      install -m755 ${src} -D "$out/bin/${name}"
+      patchShebangs "$out/bin/${name}"
+      wrapProgram "$out/bin/${name}" ${path_setting} ${pkgs.lib.makeBinPath dependencies};
+    '';
 
-  aumo-scr = write_script {
+  aumo-scr = write_shell {
     name = "aumo";
     path = "apps";
     dependencies = builtins.attrValues {inherit (pkgs) udisks gawk gnused gnugrep sudo;};
@@ -48,7 +72,7 @@
         '';
     };
   };
-  screenshot_persistent-scr = write_script {
+  screenshot_persistent-scr = write_shell {
     name = "screenshot_persistent";
     path = "small_functions";
     keep_path = true;
@@ -64,7 +88,7 @@
         ;
     };
   };
-  screenshot_temporary-scr = write_script {
+  screenshot_temporary-scr = write_shell {
     name = "screenshot_temporary";
     path = "small_functions";
     dependencies = builtins.attrValues {inherit (pkgs) grim slurp wl-clipboard;};
@@ -101,12 +125,12 @@
       TASK_PROJECT_FILE = "/home/soispha/repos/nix/nixos-config/hm/soispha/conf/taskwarrior/projects/default.nix";
     };
   };
-  update-sys-scr = write_script {
+  update-sys-scr = write_shell {
     name = "update-sys";
     path = "small_functions";
     dependencies = builtins.attrValues {inherit (pkgs) git git-crypt nixos-rebuild sudo openssh coreutils mktemp gnugrep gnused;};
   };
-  fupdate-scr = write_script {
+  fupdate-scr = write_shell {
     name = "fupdate";
     path = "apps";
     keep_path = true;
@@ -126,7 +150,7 @@
       inherit (pkgs.bat-extras) batgrep;
     };
   };
-  hibernate-scr = write_script {
+  hibernate-scr = write_shell {
     name = "hibernate";
     path = "wrappers";
     dependencies = builtins.attrValues {
@@ -142,12 +166,12 @@
     src = ./scripts/wrappers/ll;
   };
   # TODO: this need to be replaced with a wayland alternative
-  #  llp-scr = write_script {
+  #  llp-scr = write_shell {
   #     name = "llp";
   #     path = "wrappers";
   #     dependencies = builtins.attrValues {inherit (pkgs) lf ueberzug;};
   #   };
-  lock-scr = write_script {
+  lock-scr = write_shell {
     name = "lock";
     path = "wrappers";
     dependencies = builtins.attrValues {
@@ -158,7 +182,7 @@
         ;
     };
   };
-  lyrics-scr = write_script {
+  lyrics-scr = write_shell {
     name = "lyrics";
     path = "wrappers";
     dependencies = builtins.attrValues {
@@ -172,7 +196,7 @@
         ;
     };
   };
-  mpc-rm-scr = write_script {
+  mpc-rm-scr = write_shell {
     name = "mpc-rm";
     path = "wrappers";
     dependencies = builtins.attrValues {
@@ -183,17 +207,17 @@
         ;
     };
   };
-  spodi-scr = write_script {
+  spodi-scr = write_shell {
     name = "spodi";
     path = "wrappers";
     dependencies = builtins.attrValues {inherit (pkgs) gawk expect spotdl fd coreutils;};
   };
-  virsh-del-scr = write_script {
+  virsh-del-scr = write_shell {
     name = "virsh-del";
     path = "wrappers";
     dependencies = builtins.attrValues {inherit (pkgs) libvirt;};
   };
-  ytc-scr = write_script {
+  ytc-scr = write_shell {
     name = "ytc";
     path = "wrappers";
     dependencies = builtins.attrValues {
@@ -210,12 +234,12 @@
         ;
     };
   };
-  yti-scr = write_script {
+  yti-scr = write_shell {
     name = "yti";
     path = "wrappers";
     dependencies = builtins.attrValues {inherit (pkgs) gawk expect yt-dlp;};
   };
-  yts-scr = write_script {
+  yts-scr = write_shell {
     name = "yts";
     path = "wrappers";
     keep_path = true; # We need neovim