]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - libs.nix
Use more up to date version of yarn2nix
[perso/Immae/Config/Nix.git] / libs.nix
index c85808bbada8be51bf884495e2d8495f2eca95b4..0b5e0c1ab8bdbd41331412d768e2b466fd91ed3c 100644 (file)
--- a/libs.nix
+++ b/libs.nix
@@ -7,7 +7,7 @@ let nixpkgs_unstable = import (builtins.fetchTarball {
 }) {};
 in
   with nixpkgs_unstable;
-{
+rec {
   inherit nixpkgs_unstable;
   fetchedGithub = path:
     let
@@ -36,5 +36,23 @@ in
       src = fetchgitPrivate json.git;
     };
 
-  checkEnv = var: builtins.stringLength (builtins.getEnv var) > 0;
+  wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
+    assert file != null || script != null ||
+      abort "wrap needs 'file' or 'script' argument";
+    with rec {
+      set  = n: v: "--set ${pkgs.lib.escapeShellArg n} " +
+                    "${pkgs.lib.escapeShellArg v}";
+      args = (map (p: "--prefix PATH : ${p}/bin") paths) ++
+            (builtins.attrValues (pkgs.lib.mapAttrs set vars));
+    };
+    runCommand name
+      {
+        f           = if file == null then writeScript name script else file;
+        buildInputs = [ makeWrapper ];
+      }
+      ''
+        makeWrapper "$f" "$out" ${toString args}
+      '';
+
+  yarn2nixPackage = callPackage (fetchedGithub ./fetched/yarn2nix.json).src {};
 }