generators: refactor toPLIST
This commit is contained in:
parent
161414063f
commit
d361371d23
|
@ -176,14 +176,7 @@ rec {
|
||||||
else abort "toPretty: should never happen (v = ${v})";
|
else abort "toPretty: should never happen (v = ${v})";
|
||||||
|
|
||||||
# PLIST handling
|
# PLIST handling
|
||||||
|
toPLIST = {}: v: let
|
||||||
toPLIST = x: ''
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
'' + pprExpr "" x
|
|
||||||
+ "\n</plist>";
|
|
||||||
|
|
||||||
pprExpr = ind: x: with builtins;
|
pprExpr = ind: x: with builtins;
|
||||||
if isNull x then "" else
|
if isNull x then "" else
|
||||||
if isBool x then pprBool ind x else
|
if isBool x then pprBool ind x else
|
||||||
|
@ -191,7 +184,7 @@ rec {
|
||||||
if isString x then pprStr ind x else
|
if isString x then pprStr ind x else
|
||||||
if isList x then pprList ind x else
|
if isList x then pprList ind x else
|
||||||
if isAttrs x then pprAttrs ind x else
|
if isAttrs x then pprAttrs ind x else
|
||||||
throw "invalid plist type";
|
abort "pprExpr: should never happen (v = ${v})";
|
||||||
|
|
||||||
pprLiteral = ind: x: ind + x;
|
pprLiteral = ind: x: ind + x;
|
||||||
|
|
||||||
|
@ -216,11 +209,18 @@ rec {
|
||||||
(pprLiteral ind "</dict>")
|
(pprLiteral ind "</dict>")
|
||||||
];
|
];
|
||||||
|
|
||||||
attrFilter = name: value: name != "_module" && value != null;
|
pprAttr = let attrFilter = name: value: name != "_module" && value != null;
|
||||||
|
in ind: x: libStr.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList
|
||||||
pprAttr = ind: x: libStr.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList (name: value: lib.optional (attrFilter name value) [
|
(name: value: lib.optional (attrFilter name value) [
|
||||||
(pprKey "\t${ind}" name)
|
(pprKey "\t${ind}" name)
|
||||||
(pprExpr "\t${ind}" value)
|
(pprExpr "\t${ind}" value)
|
||||||
]) x));
|
]) x));
|
||||||
|
|
||||||
|
in ''
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
${pprExpr "" v}
|
||||||
|
</plist>'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,11 +286,11 @@ let
|
||||||
in
|
in
|
||||||
|
|
||||||
runCommand "MacOSX.platform" {} ''
|
runCommand "MacOSX.platform" {} ''
|
||||||
install -D ${writeText "Info.plist" (toPLIST Info)} $out/Info.plist
|
install -D ${writeText "Info.plist" (toPLIST {} Info)} $out/Info.plist
|
||||||
install -D ${writeText "version.plist" (toPLIST Version)} $out/version.plist
|
install -D ${writeText "version.plist" (toPLIST {} Version)} $out/version.plist
|
||||||
install -D ${writeText "Architectures.xcspec" (toPLIST Architectures)} $out/Developer/Library/Xcode/Specifications/Architectures.xcspec
|
install -D ${writeText "Architectures.xcspec" (toPLIST {} Architectures)} $out/Developer/Library/Xcode/Specifications/Architectures.xcspec
|
||||||
install -D ${writeText "PackageTypes.xcspec" (toPLIST PackageTypes)} $out/Developer/Library/Xcode/Specifications/PackageTypes.xcspec
|
install -D ${writeText "PackageTypes.xcspec" (toPLIST {} PackageTypes)} $out/Developer/Library/Xcode/Specifications/PackageTypes.xcspec
|
||||||
install -D ${writeText "ProductTypes.xcspec" (toPLIST ProductTypes)} $out/Developer/Library/Xcode/Specifications/ProductTypes.xcspec
|
install -D ${writeText "ProductTypes.xcspec" (toPLIST {} ProductTypes)} $out/Developer/Library/Xcode/Specifications/ProductTypes.xcspec
|
||||||
|
|
||||||
mkdir -p $out/Developer/SDKs/
|
mkdir -p $out/Developer/SDKs/
|
||||||
cd $out/Developer/SDKs/
|
cd $out/Developer/SDKs/
|
||||||
|
|
|
@ -24,6 +24,6 @@ in
|
||||||
runCommand "MacOSX${version}.sdk" {
|
runCommand "MacOSX${version}.sdk" {
|
||||||
inherit version;
|
inherit version;
|
||||||
} ''
|
} ''
|
||||||
install -D ${writeText "SDKSettings.plist" (toPLIST SDKSettings)} $out/SDKSettings.plist
|
install -D ${writeText "SDKSettings.plist" (toPLIST {} SDKSettings)} $out/SDKSettings.plist
|
||||||
install -D ${writeText "SystemVersion.plist" (toPLIST SystemVersion)} $out/System/Library/CoreServices/SystemVersion.plist
|
install -D ${writeText "SystemVersion.plist" (toPLIST {} SystemVersion)} $out/System/Library/CoreServices/SystemVersion.plist
|
||||||
''
|
''
|
||||||
|
|
|
@ -24,7 +24,7 @@ runCommand "nixpkgs.xctoolchain" {
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
} (''
|
} (''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
install -D ${writeText "ToolchainInfo.plist" (toPLIST ToolchainInfo)} $out/ToolchainInfo.plist
|
install -D ${writeText "ToolchainInfo.plist" (toPLIST {} ToolchainInfo)} $out/ToolchainInfo.plist
|
||||||
|
|
||||||
mkdir -p $out/usr/include
|
mkdir -p $out/usr/include
|
||||||
mkdir -p $out/usr/lib
|
mkdir -p $out/usr/lib
|
||||||
|
|
Loading…
Reference in New Issue