1010 let
1111 name' = sanitizeName name + "-src" ;
1212 in
13- if spec . builtin or true then
14- builtins_fetchurl { inherit ( spec ) url sha256 ; name = name' ; }
15- else
16- pkgs . fetchurl { inherit ( spec ) url sha256 ; name = name' ; } ;
13+ if spec . builtin or true then
14+ builtins_fetchurl { inherit ( spec ) url sha256 ; name = name' ; }
15+ else
16+ pkgs . fetchurl { inherit ( spec ) url sha256 ; name = name' ; } ;
1717
1818 fetch_tarball = pkgs : name : spec :
1919 let
2020 name' = sanitizeName name + "-src" ;
2121 in
22- if spec . builtin or true then
23- builtins_fetchTarball { name = name' ; inherit ( spec ) url sha256 ; }
24- else
25- pkgs . fetchzip { name = name' ; inherit ( spec ) url sha256 ; } ;
22+ if spec . builtin or true then
23+ builtins_fetchTarball { name = name' ; inherit ( spec ) url sha256 ; }
24+ else
25+ pkgs . fetchzip { name = name' ; inherit ( spec ) url sha256 ; } ;
2626
2727 fetch_git = name : spec :
2828 let
2929 ref =
3030 if spec ? ref then spec . ref else
31- if spec ? branch then "refs/heads/${ spec . branch } " else
32- if spec ? tag then "refs/tags/${ spec . tag } " else
33- abort "In git source '${ name } ': Please specify `ref`, `tag` or `branch`!" ;
31+ if spec ? branch then "refs/heads/${ spec . branch } " else
32+ if spec ? tag then "refs/tags/${ spec . tag } " else
33+ abort "In git source '${ name } ': Please specify `ref`, `tag` or `branch`!" ;
3434 submodules = if spec ? submodules then spec . submodules else false ;
3535 submoduleArg =
3636 let
4444 + "but your nix's (${ builtins . nixVersion } ) builtins.fetchGit "
4545 + "does not support them"
4646 )
47- { }
48- else { } ;
47+ { }
48+ else { } ;
4949 in
50- if nixSupportsSubmodules
51- then { inherit submodules ; }
52- else emptyArgWithWarning ;
50+ if nixSupportsSubmodules
51+ then { inherit submodules ; }
52+ else emptyArgWithWarning ;
5353 in
54- builtins . fetchGit
55- ( { url = spec . repo ; inherit ( spec ) rev ; inherit ref ; } // submoduleArg ) ;
54+ builtins . fetchGit
55+ ( { url = spec . repo ; inherit ( spec ) rev ; inherit ref ; } // submoduleArg ) ;
5656
5757 fetch_local = spec : spec . path ;
5858
8686 hasNixpkgsPath = builtins . any ( x : x . prefix == "nixpkgs" ) builtins . nixPath ;
8787 hasThisAsNixpkgsPath = <nixpkgs> == ./. ;
8888 in
89- if builtins . hasAttr "nixpkgs" sources
90- then sourcesNixpkgs
91- else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
92- import <nixpkgs> { }
93- else
94- abort
95- ''
96- Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
97- add a package called "nixpkgs" to your sources.json.
98- '' ;
89+ if builtins . hasAttr "nixpkgs" sources
90+ then sourcesNixpkgs
91+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
92+ import <nixpkgs> { }
93+ else
94+ abort
95+ ''
96+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
97+ add a package called "nixpkgs" to your sources.json.
98+ '' ;
9999
100100 # The actual fetching function.
101101 fetch = pkgs : name : spec :
@@ -118,10 +118,10 @@ let
118118 saneName = stringAsChars ( c : if isNull ( builtins . match "[a-zA-Z0-9]" c ) then "_" else c ) name ;
119119 ersatz = builtins . getEnv "NIV_OVERRIDE_${ saneName } " ;
120120 in
121- if ersatz == "" then drv else
122- # this turns the string into an actual Nix path (for both absolute and
123- # relative paths)
124- if builtins . substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins . getEnv "PWD" + "/${ ersatz } " ;
121+ if ersatz == "" then drv else
122+ # this turns the string into an actual Nix path (for both absolute and
123+ # relative paths)
124+ if builtins . substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins . getEnv "PWD" + "/${ ersatz } " ;
125125
126126 # Ports of functions for older nix versions
127127
132132 ) ;
133133
134134 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
135- range = first : last : if first > last then [ ] else builtins . genList ( n : first + n ) ( last - first + 1 ) ;
135+ range = first : last : if first > last then [ ] else builtins . genList ( n : first + n ) ( last - first + 1 ) ;
136136
137137 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
138138 stringToCharacters = s : map ( p : builtins . substring p 1 s ) ( range 0 ( builtins . stringLength s - 1 ) ) ;
@@ -143,43 +143,46 @@ let
143143 concatStrings = builtins . concatStringsSep "" ;
144144
145145 # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
146- optionalAttrs = cond : as : if cond then as else { } ;
146+ optionalAttrs = cond : as : if cond then as else { } ;
147147
148148 # fetchTarball version that is compatible between all the versions of Nix
149149 builtins_fetchTarball = { url , name ? null , sha256 } @attrs :
150150 let
151151 inherit ( builtins ) lessThan nixVersion fetchTarball ;
152152 in
153- if lessThan nixVersion "1.12" then
154- fetchTarball ( { inherit url ; } // ( optionalAttrs ( ! isNull name ) { inherit name ; } ) )
155- else
156- fetchTarball attrs ;
153+ if lessThan nixVersion "1.12" then
154+ fetchTarball ( { inherit url ; } // ( optionalAttrs ( ! isNull name ) { inherit name ; } ) )
155+ else
156+ fetchTarball attrs ;
157157
158158 # fetchurl version that is compatible between all the versions of Nix
159159 builtins_fetchurl = { url , name ? null , sha256 } @attrs :
160160 let
161161 inherit ( builtins ) lessThan nixVersion fetchurl ;
162162 in
163- if lessThan nixVersion "1.12" then
164- fetchurl ( { inherit url ; } // ( optionalAttrs ( ! isNull name ) { inherit name ; } ) )
165- else
166- fetchurl attrs ;
163+ if lessThan nixVersion "1.12" then
164+ fetchurl ( { inherit url ; } // ( optionalAttrs ( ! isNull name ) { inherit name ; } ) )
165+ else
166+ fetchurl attrs ;
167167
168168 # Create the final "sources" from the config
169169 mkSources = config :
170- mapAttrs (
171- name : spec :
172- if builtins . hasAttr "outPath" spec
173- then abort
174- "The values in sources.json should not have an 'outPath' attribute"
175- else
176- spec // { outPath = replace name ( fetch config . pkgs name spec ) ; }
177- ) config . sources ;
170+ mapAttrs
171+ (
172+ name : spec :
173+ if builtins . hasAttr "outPath" spec
174+ then
175+ abort
176+ "The values in sources.json should not have an 'outPath' attribute"
177+ else
178+ spec // { outPath = replace name ( fetch config . pkgs name spec ) ; }
179+ )
180+ config . sources ;
178181
179182 # The "config" used by the fetchers
180183 mkConfig =
181184 { sourcesFile ? if builtins . pathExists ./sources.json then ./sources.json else null
182- , sources ? if isNull sourcesFile then { } else builtins . fromJSON ( builtins . readFile sourcesFile )
185+ , sources ? if isNull sourcesFile then { } else builtins . fromJSON ( builtins . readFile sourcesFile )
183186 , system ? builtins . currentSystem
184187 , pkgs ? mkPkgs sources system
185188 } : rec {
191194 } ;
192195
193196in
194- mkSources ( mkConfig { } ) // { __functor = _ : settings : mkSources ( mkConfig settings ) ; }
197+ mkSources ( mkConfig { } ) // { __functor = _ : settings : mkSources ( mkConfig settings ) ; }
0 commit comments