nix-helpers: bddf0b3f30be81a98b278c9252ede758e79f51ae

     1: # Takes a directory path, returns any immediate children in that directory whose
     2: # name matches '*.nix'. Result is an attrset where names are "basenames" with
     3: # ".nix" suffix removed, e.g. "foo", and values are full paths with directory
     4: # prefix and ".nix" suffix, e.g. "${dir}/foo.nix".
     5: #
     6: # Note that this is used to bootstrap nix-helpers, so it should work standalone.
     7: { die ? import ../die { }, suffixedFilesIn ? import ../suffixedFilesIn { } }:
     8: 
     9: with builtins;
    10: with rec {
    11:   go = suffixedFilesIn ".nix";
    12: 
    13:   testData = go ./.;
    14: 
    15:   thisFile = ./default.nix;
    16: };
    17: 
    18: assert testData ? default || die {
    19:   inherit testData;
    20:   error = "Expected 'default' to appear in 'testData'";
    21: };
    22: assert testData.default == thisFile || die {
    23:   inherit testData thisFile;
    24:   error = "Expected 'testData.default' to match 'thisFile'";
    25: };
    26: assert dirOf testData.default == ./. || die {
    27:   inherit testData;
    28:   thisDir = ./.;
    29:   error = "Expected 'testData.default' to be a file under 'thisDir'";
    30: };
    31: go

Generated by git2html.