From de6dfea61b996c5e52a47842b3b54e1b9a390a91 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Sun, 27 Aug 2023 13:58:26 +0200 Subject: pkgs: gitignore: reorganize --- pkgs/static/gitignore/default.nix | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'pkgs/static/gitignore') diff --git a/pkgs/static/gitignore/default.nix b/pkgs/static/gitignore/default.nix index ac825a5..67dd28a 100644 --- a/pkgs/static/gitignore/default.nix +++ b/pkgs/static/gitignore/default.nix @@ -1,12 +1,28 @@ -{ fetchurl, lib }: +{ + templates ? [], + toUncomment ? [], + stdenvNoCC, + fetchFromGitHub, + lib, +}: +stdenvNoCC.mkDerivation { + name = lib.concatStringsSep "+" templates + ".gitignore"; + version = "2023-06-30"; -let - fetchGitignore = module: sha256: - let - url = "https://www.toptal.com/developers/gitignore/api/" + module; - name = module + ".gitignore"; - in fetchurl { inherit url sha256 name; }; - sources = lib.importJSON ./sources.json; -in { - fetcher = fetchGitignore; -} // builtins.mapAttrs fetchGitignore sources + src = fetchFromGitHub { + owner = "toptal"; + repo = "gitignore"; + rev = "0a7fb01801c62ca53ab2dcd73ab96185e159e864"; + hash = "sha256-tZ+hlpt7T1by3f9BxzakjpQr+Y4top570J58q8VP9YE="; + }; + + buildPhase = '' + cd templates + for file in ${lib.concatStringsSep " " (builtins.map (name: lib.escapeShellArg "${name}.gitignore") templates)} + do + echo "### $(basename "$file" .gitignore)" >> $out + cat "$file" >> $out + done + substituteInPlace $out ${lib.concatStringsSep " " (builtins.map (line: "--replace ${lib.escapeShellArg "# ${line}"} ${lib.escapeShellArg line}") toUncomment)} + ''; +} -- cgit v1.2.3