mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Factor out the installer script
This commit is contained in:
parent
60fe4ddaa1
commit
77003a4f0c
2 changed files with 46 additions and 32 deletions
43
flake.nix
43
flake.nix
|
@ -89,38 +89,17 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
installScriptFor = systems:
|
installScriptFor = systems:
|
||||||
with nixpkgsFor.x86_64-linux.native;
|
nixpkgsFor.x86_64-linux.native.callPackage ./scripts/installer.nix {
|
||||||
runCommand "installer-script"
|
systemTarballPairs = map
|
||||||
{ buildInputs = [ nix ];
|
(system: {
|
||||||
}
|
inherit system;
|
||||||
''
|
tarball =
|
||||||
mkdir -p $out/nix-support
|
if builtins.elem system crossSystems
|
||||||
|
then self.hydraJobs.binaryTarballCross.x86_64-linux.${system}
|
||||||
# Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
|
else self.hydraJobs.binaryTarball.${system};
|
||||||
tarballPath() {
|
})
|
||||||
# Remove the store prefix
|
systems;
|
||||||
local path=''${1#${builtins.storeDir}/}
|
};
|
||||||
# Get the path relative to the derivation root
|
|
||||||
local rest=''${path#*/}
|
|
||||||
# Get the derivation hash
|
|
||||||
local drvHash=''${path%%-*}
|
|
||||||
echo "$drvHash/$rest"
|
|
||||||
}
|
|
||||||
|
|
||||||
substitute ${./scripts/install.in} $out/install \
|
|
||||||
${pkgs.lib.concatMapStrings
|
|
||||||
(system: let
|
|
||||||
tarball = if builtins.elem system crossSystems then self.hydraJobs.binaryTarballCross.x86_64-linux.${system} else self.hydraJobs.binaryTarball.${system};
|
|
||||||
in '' \
|
|
||||||
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \
|
|
||||||
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \
|
|
||||||
''
|
|
||||||
)
|
|
||||||
systems
|
|
||||||
} --replace '@nixVersion@' ${version}
|
|
||||||
|
|
||||||
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
|
|
||||||
testNixVersions = pkgs: client: daemon:
|
testNixVersions = pkgs: client: daemon:
|
||||||
pkgs.callPackage ./package.nix {
|
pkgs.callPackage ./package.nix {
|
||||||
|
|
35
scripts/installer.nix
Normal file
35
scripts/installer.nix
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{ lib
|
||||||
|
, runCommand
|
||||||
|
, nix
|
||||||
|
, systemTarballPairs
|
||||||
|
}:
|
||||||
|
|
||||||
|
runCommand "installer-script" {
|
||||||
|
buildInputs = [ nix ];
|
||||||
|
} ''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
|
||||||
|
# Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
|
||||||
|
tarballPath() {
|
||||||
|
# Remove the store prefix
|
||||||
|
local path=''${1#${builtins.storeDir}/}
|
||||||
|
# Get the path relative to the derivation root
|
||||||
|
local rest=''${path#*/}
|
||||||
|
# Get the derivation hash
|
||||||
|
local drvHash=''${path%%-*}
|
||||||
|
echo "$drvHash/$rest"
|
||||||
|
}
|
||||||
|
|
||||||
|
substitute ${./install.in} $out/install \
|
||||||
|
${lib.concatMapStrings
|
||||||
|
({ system, tarball }:
|
||||||
|
'' \
|
||||||
|
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \
|
||||||
|
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \
|
||||||
|
''
|
||||||
|
)
|
||||||
|
systemTarballPairs
|
||||||
|
} --replace '@nixVersion@' ${nix.version}
|
||||||
|
|
||||||
|
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
||||||
|
''
|
Loading…
Reference in a new issue