mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
support 'unknown' source type
This commit is contained in:
parent
042d203237
commit
76ae17fc27
@ -27,6 +27,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
{
|
||||||
|
"if": {
|
||||||
|
"properties": { "type": { "const": "unknown" } }
|
||||||
|
},
|
||||||
|
"then": { "properties": {} }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"if": {
|
"if": {
|
||||||
"properties": { "type": { "const": "fetchurl" } }
|
"properties": { "type": { "const": "fetchurl" } }
|
||||||
|
@ -145,7 +145,7 @@ def translate(args):
|
|||||||
# calculate combined hash
|
# calculate combined hash
|
||||||
if args.combined:
|
if args.combined:
|
||||||
|
|
||||||
print("Start building FOD for combined sources to get output hash")
|
print("Building FOD of combined sources to retrieve output hash")
|
||||||
|
|
||||||
# remove hashes from lock file and init sourcesCombinedHash with emtpy string
|
# remove hashes from lock file and init sourcesCombinedHash with emtpy string
|
||||||
strip_hashes_from_lock(lock)
|
strip_hashes_from_lock(lock)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# this fetcher takes an attrset of sources and combines all contained FODs
|
||||||
|
# to one large FOD. Non-FOD sources like derivations and store paths are
|
||||||
|
# not touched
|
||||||
{
|
{
|
||||||
defaultFetcher,
|
defaultFetcher,
|
||||||
|
|
||||||
@ -20,11 +23,36 @@ let
|
|||||||
defaultFetched = (defaultFetcher { inherit sources; }).fetchedSources;
|
defaultFetched = (defaultFetcher { inherit sources; }).fetchedSources;
|
||||||
|
|
||||||
# extract the arguments from the individual fetcher calls
|
# extract the arguments from the individual fetcher calls
|
||||||
fetcherArgsAll = lib.mapAttrs (pname: fetched:
|
fetcherArgsAll =
|
||||||
(fetched.overrideAttrs (args: {
|
let
|
||||||
passthru.originalArgs = args;
|
fetcherArgsAll' =
|
||||||
})).originalArgs
|
lib.mapAttrs
|
||||||
) defaultFetched;
|
(pname: fetched:
|
||||||
|
|
||||||
|
# handle FOD sources
|
||||||
|
if lib.all (attr: fetched ? "${attr}") [ "outputHash" "outputHashAlgo" "outputHashMode" ] then
|
||||||
|
(fetched.overrideAttrs (args: {
|
||||||
|
passthru.originalArgs = args;
|
||||||
|
})).originalArgs
|
||||||
|
|
||||||
|
# handle non-FOD sources
|
||||||
|
else if lib.isDerivation fetched || lib.isStorePath fetched then
|
||||||
|
null
|
||||||
|
|
||||||
|
# error out on unknown source types
|
||||||
|
else
|
||||||
|
throw ''
|
||||||
|
Error while generating FOD fetcher for combined sources.
|
||||||
|
Cannot classify source of '${pname}'.
|
||||||
|
Known source types:
|
||||||
|
- FOD
|
||||||
|
- derivation
|
||||||
|
- store path
|
||||||
|
''
|
||||||
|
)
|
||||||
|
defaultFetched;
|
||||||
|
in
|
||||||
|
lib.filterAttrs (pname: fetcherArgs: fetcherArgs != null) fetcherArgsAll';
|
||||||
|
|
||||||
# convert arbitrary types to string, like nix does with derivation arguments
|
# convert arbitrary types to string, like nix does with derivation arguments
|
||||||
toString = x:
|
toString = x:
|
||||||
@ -61,16 +89,17 @@ let
|
|||||||
|
|
||||||
mkdir $out
|
mkdir $out
|
||||||
|
|
||||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (pname: fetcherArgs: ''
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (pname: fetcherArgs:
|
||||||
OUT_ORIG=$out
|
''
|
||||||
export out=$OUT_ORIG/${fetcherArgs.name}
|
OUT_ORIG=$out
|
||||||
mkdir workdir
|
export out=$OUT_ORIG/${fetcherArgs.name}
|
||||||
pushd workdir
|
mkdir workdir
|
||||||
${fetchItem pname fetcherArgs}
|
pushd workdir
|
||||||
popd
|
${fetchItem pname fetcherArgs}
|
||||||
rm -r workdir
|
popd
|
||||||
export out=$OUT_ORIG
|
rm -r workdir
|
||||||
'') fetcherArgsAll )}
|
export out=$OUT_ORIG
|
||||||
|
'') fetcherArgsAll )}
|
||||||
|
|
||||||
echo "FOD_PATH=$(${nix}/bin/nix hash-path $out)"
|
echo "FOD_PATH=$(${nix}/bin/nix hash-path $out)"
|
||||||
'';
|
'';
|
||||||
@ -101,6 +130,9 @@ in
|
|||||||
fetchedSources =
|
fetchedSources =
|
||||||
# attrset: pname -> path of downloaded source
|
# attrset: pname -> path of downloaded source
|
||||||
lib.genAttrs (lib.attrNames sources) (pname:
|
lib.genAttrs (lib.attrNames sources) (pname:
|
||||||
"${FODAllSources}/${fetcherArgsAll."${pname}".name}"
|
if fetcherArgsAll ? "${pname}" then
|
||||||
|
"${FODAllSources}/${fetcherArgsAll."${pname}".name}"
|
||||||
|
else
|
||||||
|
sources."${pname}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
inherit (source) url;
|
inherit (source) url;
|
||||||
sha256 = source.hash or null;
|
sha256 = source.hash or null;
|
||||||
}
|
}
|
||||||
|
else if source.type == "unknown" then
|
||||||
|
null
|
||||||
else throw "unsupported source type '${source.type}'"
|
else throw "unsupported source type '${source.type}'"
|
||||||
) sources;
|
) sources;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user