nix-helpers: 4aba305d20eac5ede8f5a3dca25fb8c576ed6d9a

     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: {
     8:   die ? import ../die { },
     9:   suffixedFilesIn ? import ../suffixedFilesIn { },
    10: }:
    11: 
    12: with builtins;
    13: with rec {
    14:   go = suffixedFilesIn ".nix";
    15: 
    16:   testData = go ./.;
    17: 
    18:   thisFile = ./default.nix;
    19: };
    20: 
    21: assert
    22:   testData ? default
    23:   || die {
    24:     inherit testData;
    25:     error = "Expected 'default' to appear in 'testData'";
    26:   };
    27: assert
    28:   testData.default == thisFile
    29:   || die {
    30:     inherit testData thisFile;
    31:     error = "Expected 'testData.default' to match 'thisFile'";
    32:   };
    33: assert
    34:   dirOf testData.default == ./.
    35:   || die {
    36:     inherit testData;
    37:     thisDir = ./.;
    38:     error = "Expected 'testData.default' to be a file under 'thisDir'";
    39:   };
    40: go

Generated by git2html.