From bbbaec4e6451ecf49c330a848fea6e4c9ae2a422 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Thu, 9 May 2019 12:43:00 +0200 Subject: [PATCH] Fix sourceByRegex --- default.nix | 20 ++++++++++++++++---- site/niv.svg | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index b33e9ec..59faee8 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,22 @@ { pkgs ? import ./nix {} }: with rec { files = pkgs.callPackage ./nix/files.nix {}; - niv-source = files.sourceByRegex "niv" ./. + sourceByRegex = name: src: regexes: + builtins.path + { filter = (path: type: + let + relPath = pkgs.lib.removePrefix (toString src + "/") (toString path); + accept = pkgs.lib.any (re: builtins.match re relPath != null) regexes; + in accept); + inherit name; + path = src; + }; + niv-source = sourceByRegex "niv" ./. [ "^package.yaml$" - "^app.*$" + "^app$" + "^app.*.hs$" "^README.md$" + "^nix$" "^nix.sources.nix$" ]; haskellPackages = pkgs.haskellPackages.override @@ -76,8 +88,8 @@ rec expected_hash=$(${pkgs.nix}/bin/nix-hash ${niv-svg-gen}) actual_hash=$(grep -oP 'id="\K[^"]+' ${./site/niv.svg} -m 1) - echo expected $expected_hash - echo actuall $actual_hash + echo "expected $expected_hash" + echo "actual $actual_hash" [ $expected_hash == $actual_hash ] && echo dymmy > $out || err ''; diff --git a/site/niv.svg b/site/niv.svg index 0816c11..d6fa881 100644 --- a/site/niv.svg +++ b/site/niv.svg @@ -1,4 +1,4 @@ - + @@ -44,5 +44,5 @@ - $ niv initCreating nix/sources.nixCreating nix/sources.jsonImporting 'niv' ...Reading sources fileunpacking...path is '/nix/store/pj0kr4086wciqn2kwl31sjkbnn8nm2s0-9ef6a381fc157f249f543f1c906c93eb12d1a3a0.tar.gz'Writing new sources fileImporting 'nixpkgs' ...$ niv add stedolan/jqpath is '/nix/store/v7kg3bb5qw70i2p689jz85l4kwrb11lf-571b40d3f50466d3e91c1e609d372de96d782793.tar.gz'path is '/nix/store/yjz2v8kfk2jkzc0w7lh43hfmcafpqs33-ad9fc9f559e78a764aac20f669f23cdd020cd943.tar.gz' + $ niv initCreating nix/sources.nixCreating nix/sources.jsonImporting 'niv' ...Reading sources fileunpacking...path is '/nix/store/xrvnfamz6i3dv28c6fv3ylga280zdhwy-e5e441998ede88dfce5b8b9a7ea99e1e0f1102fa.tar.gz'Writing new sources fileImporting 'nixpkgs' ...$ niv add stedolan/jqpath is '/nix/store/kaighy7gkrxmrlx6qfjk6g1q8iy37n28-7413c884f052e02c7825aa93a1c16649cc3cb29b.tar.gz'path is '/nix/store/yjz2v8kfk2jkzc0w7lh43hfmcafpqs33-ad9fc9f559e78a764aac20f669f23cdd020cd943.tar.gz' \ No newline at end of file