From 5e59462491fe5cb2f88aa87623c7fff4b597f4d2 Mon Sep 17 00:00:00 2001
From: Lukas Wurzinger <lukas@wrz.one>
Date: Sun, 19 Jan 2025 00:59:05 +0100
Subject: [PATCH] weirdness

---
 hosts/headful/work/envfs.nix |  3 ---
 hosts/headful/work/phps.nix  | 45 ++++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 5 deletions(-)
 delete mode 100644 hosts/headful/work/envfs.nix

diff --git a/hosts/headful/work/envfs.nix b/hosts/headful/work/envfs.nix
deleted file mode 100644
index 2a2382e..0000000
--- a/hosts/headful/work/envfs.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  services.envfs.enable = true;
-}
diff --git a/hosts/headful/work/phps.nix b/hosts/headful/work/phps.nix
index bfa9ed4..dadb8ae 100644
--- a/hosts/headful/work/phps.nix
+++ b/hosts/headful/work/phps.nix
@@ -15,6 +15,8 @@
     "php84"
   ];
 
+  selectedPhp = "php84";
+
   extraConfig = ''
     memory_limit = -1
 
@@ -34,15 +36,54 @@
         inherit extraConfig;
       }
   );
+
+  prefix = "/var/lib/phps";
+  /*
+  phpHomeLink = ".local/bin/php";
+
+  usephp = pkgs.writeShellApplication {
+    name = "usephp";
+    text = ''
+      if (( $# != 1 )); then
+        echo incorrect number of arguments >&2
+        exit 1
+      fi
+      ln --symbolic --force -- ${lib.escapeShellArg prefix}/"$1"/bin/php ~/${lib.escapeShellArg phpHomeLink}
+    '';
+  };
+
+  composer = pkgs.writeShellApplication {
+    name = "composer";
+    text = ''
+      php=~/${lib.escapeShellArg phpHomeLink}
+      if [[ ! -x $php ]]; then
+        echo php has not been linked >&2
+        exit 1
+      fi
+      exec -- "$php" ${pkgs.phpPackages.composer}/bin/.composer-wrapped
+    '';
+  };
+  */
 in {
   nix.settings = {
     substituters = ["https://fossar.cachix.org/"];
     trusted-public-keys = ["fossar.cachix.org-1:Zv6FuqIboeHPWQS7ysLCJ7UT7xExb4OE8c4LyGb5AsE="];
   };
 
-  systemd.tmpfiles.settings.php =
+  systemd.tmpfiles.settings =
     builtins.mapAttrs (name: drv: {
-      "/var/lib/phps/${name}"."L+".argument = drv.outPath;
+      "${prefix}/${name}"."L+".argument = drv.outPath;
     })
     phps;
+
+  environment.systemPackages = [
+    phps.${selectedPhp}.packages.composer
+  ];
+
+  /*
+  environment.systemPackages = [
+    usephp
+    composer
+  ];
+  */
 }