mirror of
https://github.com/nix-community/naersk
synced 2024-11-22 19:53:05 +00:00
Avoid IFD as much as possible
This commit is contained in:
parent
104df3fe88
commit
2692cfbfc1
3 changed files with 27 additions and 27 deletions
24
build.nix
24
build.nix
|
@ -17,8 +17,8 @@ src:
|
|||
, buildInputs ? []
|
||||
, nativeBuildInputs ? []
|
||||
, builtDependencies ? []
|
||||
, cargolockPath ? null
|
||||
, cargotomlPath ? null
|
||||
, cargolock ? null
|
||||
, cargotoml ? null
|
||||
, release ? true
|
||||
, stdenv
|
||||
, lib
|
||||
|
@ -43,13 +43,11 @@ with
|
|||
|
||||
with rec
|
||||
{
|
||||
drv = stdenv.mkDerivation
|
||||
drv = stdenv.mkDerivation (
|
||||
{ inherit
|
||||
src
|
||||
doCheck
|
||||
nativeBuildInputs
|
||||
cargolockPath
|
||||
cargotomlPath
|
||||
cratePaths
|
||||
name
|
||||
version;
|
||||
|
@ -88,24 +86,24 @@ with rec
|
|||
''
|
||||
runHook preConfigure
|
||||
|
||||
if [ -n "$cargolockPath" ]
|
||||
if [ -n "$cargolock" ]
|
||||
then
|
||||
echo "Setting Cargo.lock"
|
||||
if [ -f "Cargo.lock" ]
|
||||
then
|
||||
echo "WARNING: replacing existing Cargo.lock"
|
||||
fi
|
||||
cp --no-preserve mode "$cargolockPath" Cargo.lock
|
||||
echo "$cargolock" > Cargo.lock
|
||||
fi
|
||||
|
||||
if [ -n "$cargotomlPath" ]
|
||||
if [ -n "$cargotoml" ]
|
||||
then
|
||||
echo "Setting Cargo.toml"
|
||||
if [ -f "Cargo.toml" ]
|
||||
then
|
||||
echo "WARNING: replacing existing Cargo.toml"
|
||||
fi
|
||||
cp "$cargotomlPath" Cargo.toml
|
||||
echo "$cargotoml" > Cargo.toml
|
||||
fi
|
||||
|
||||
mkdir -p target
|
||||
|
@ -209,7 +207,13 @@ with rec
|
|||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
} //
|
||||
lib.optionalAttrs (! isNull cargolock )
|
||||
{ cargolock = builtinz.toTOML cargolock; } //
|
||||
lib.optionalAttrs (! isNull cargotoml )
|
||||
{ cargotoml = builtinz.toTOML cargotoml; }
|
||||
)
|
||||
;
|
||||
|
||||
# XXX: the actual crate format is not documented but in practice is a
|
||||
# gzipped tar; we simply unpack it and introduce a ".cargo-checksum.json"
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
, remarshal
|
||||
}:
|
||||
|
||||
rec
|
||||
{
|
||||
writeTOML = attrs:
|
||||
let toTOML = import ./to-toml.nix { inherit lib; }; in
|
||||
writeText "write-toml" (toTOML attrs);
|
||||
toTOML = import ./to-toml.nix { inherit lib; };
|
||||
writeTOML = attrs: writeText "write-toml" (toTOML attrs);
|
||||
|
||||
readTOML = usePure: f:
|
||||
if usePure then
|
||||
|
|
24
default.nix
24
default.nix
|
@ -45,18 +45,16 @@ with rec
|
|||
{
|
||||
commonAttrs = src: attrs: rec
|
||||
{ usePureFromTOML = attrs.usePureFromTOML or true;
|
||||
cargolockPath = attrs.cargolockPath or null;
|
||||
cargotomlPath = attrs.cargotomlPath or null;
|
||||
cargolock =
|
||||
if isNull cargolockPath then
|
||||
cargolock = attrs.cargolock or null;
|
||||
cargotoml = attrs.cargotoml or null;
|
||||
cargolock' =
|
||||
if isNull cargolock then
|
||||
builtinz.readTOML usePureFromTOML "${src}/Cargo.lock"
|
||||
else
|
||||
builtinz.readTOML usePureFromTOML cargolockPath;
|
||||
else cargolock;
|
||||
rootCargotoml =
|
||||
if isNull cargotomlPath then
|
||||
if isNull cargotoml then
|
||||
builtinz.readTOML usePureFromTOML "${src}/Cargo.toml"
|
||||
else
|
||||
builtinz.readTOML usePureFromTOML cargotomlPath;
|
||||
else cargotoml;
|
||||
|
||||
# All the Cargo.tomls, including the top-level one
|
||||
cargotomls =
|
||||
|
@ -81,7 +79,7 @@ with rec
|
|||
|
||||
if isNull workspaceMembers then "."
|
||||
else lib.concatStringsSep "\n" workspaceMembers;
|
||||
crateDependencies = libb.mkVersions cargolock;
|
||||
crateDependencies = libb.mkVersions cargolock';
|
||||
targetInstructions =
|
||||
if builtins.hasAttr "targets" attrs then
|
||||
lib.concatMapStringsSep " " (target: "-p ${target}") attrs.targets
|
||||
|
@ -164,12 +162,10 @@ with rec
|
|||
{ cargoBuild = "source ${buildDepsScript}";
|
||||
doCheck = false;
|
||||
copyBuildArtifacts = true;
|
||||
cargolockPath = builtinz.writeTOML cargolock;
|
||||
cargotomlPath = builtinz.writeTOML
|
||||
(
|
||||
cargolock = cargolock';
|
||||
cargotoml =
|
||||
{ package = { name = "dummy"; version = "0.0.0"; }; } //
|
||||
{ dependencies = directDependencies; }
|
||||
)
|
||||
;
|
||||
name =
|
||||
if lib.length cargotomls == 0 then
|
||||
|
|
Loading…
Reference in a new issue