nix-helpers: fd08d6c709251d51648aaa1bb14442f74cb2a3af

     1: { die ? import ../die {}, nixpkgs-lib ? import ../nixpkgs-lib {} }:
     2: 
     3: with rec {
     4:   inherit (builtins) attrNames filter listToAttrs map readDir;
     5: 
     6:   inherit (nixpkgs-lib) hasSuffix removeSuffix;
     7: 
     8:   go = suffix: dir:
     9:     with {
    10:       content = filter (hasSuffix suffix) (attrNames (readDir dir));
    11: 
    12:       entry = f: {
    13:         name = removeSuffix suffix f;
    14:         value = dir + "/${f}";
    15:       };
    16:     };
    17:     listToAttrs (map entry content);
    18: 
    19:   testData = go ".nix" ./.;
    20:   thisFile = ./default.nix;
    21: };
    22: assert testData ? default || die {
    23:   inherit testData;
    24:   error = "Expected default to appear in testData";
    25: };
    26: assert testData.default == thisFile || die {
    27:   inherit testData thisFile;
    28:   error = "Expected 'testData.default' to match 'thisFile'";
    29: };
    30: assert dirOf testData.default == ./. || die {
    31:   inherit testData;
    32:   thisDir = ./.;
    33:   error = "Expected 'testData.default' to be a file under 'thisDir'";
    34: };
    35: go

Generated by git2html.