File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- { lib , buildGoModule } :
1+ { buildGoModule } :
2+ let
3+ source = import ../../nix/source.nix ;
4+ in
25buildGoModule {
36 name = "devshell" ;
4- src = lib . cleanSource ./. ;
5- vendorSha256 = "sha256-CksQhzcKuHWihdJeTazQ5EG8aFkZ5cpss90eRCT+ERc=" ;
7+ src = source . filter {
8+ path = ./. ;
9+ allow = [
10+ ./go.mod
11+ ./go.sum
12+ ( source . matchExt "go" )
13+ ] ;
14+ } ;
15+ vendorSha256 = "sha256-NFsQoPDXEeOmyLR2bCgKuRHw2sjhGQbUmHV8bMJzANw=" ;
616}
Original file line number Diff line number Diff line change 1+ # A standalone source filtering library
2+ let
3+ inherit ( builtins )
4+ any
5+ isFunction
6+ isString
7+ isPath
8+ map
9+ stringLength
10+ substring
11+ ;
12+
13+ # Copied from the nixpkgs stdlib
14+ hasSuffix =
15+ # Suffix to check for
16+ suffix :
17+ # Input string
18+ content :
19+ let
20+ lenContent = stringLength content ;
21+ lenSuffix = stringLength suffix ;
22+ in
23+ lenContent >= lenSuffix &&
24+ substring ( lenContent - lenSuffix ) lenContent content == suffix ;
25+
26+ # If an argument to allow or deny is a path, transform it to a matcher.
27+ #
28+ # This probably needs more work, I don't think that it works on sub-folders.
29+ toMatcher = f :
30+ let
31+ path_ = toString f ;
32+ in
33+ if isFunction f then f
34+ else
35+ ( path : type : path_ == toString path ) ;
36+ in
37+ {
38+ # Match paths with the given extension
39+ matchExt = ext :
40+ path : type :
41+ ( hasSuffix ".${ ext } " path ) ;
42+
43+ # A proper filter
44+ filter = { path , name ? "source" , allow ? [ ] , deny ? [ ] } :
45+ let
46+ allow_ = builtins . map toMatcher allow ;
47+ deny_ = builtins . map toMatcher deny ;
48+ in
49+ builtins . path {
50+ inherit name path ;
51+ filter = path : type :
52+ ( builtins . any ( f : f path type ) allow_ ) &&
53+ ( ! builtins . any ( f : f path type ) deny_ ) ;
54+ } ;
55+ }
You can’t perform that action at this time.
0 commit comments