X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=libs.nix;h=0b5e0c1ab8bdbd41331412d768e2b466fd91ed3c;hb=7636abc6bfcdca34d4b90a144365235012275339;hp=c85808bbada8be51bf884495e2d8495f2eca95b4;hpb=65fe75439ebcb4e9f065ed7586240357dcca59c1;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/libs.nix b/libs.nix index c85808b..0b5e0c1 100644 --- 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 {}; }