aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2021-02-15 10:20:54 +0000
committerDomen Kožar <domen@dev.si>2021-02-21 15:51:49 +0000
commitae4260f0a79c5cbb7c88ddbef1f512e0771f7414 (patch)
treef633afa81a85e8e982aed73f2b686e7e78c86cc8 /flake.nix
parent4e98f0345c144b9d85bed1f6b0bc509bf7ddc000 (diff)
Generate installer script for each PR/push
This works by using Cachix feature of serving a file from a store path.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix70
1 files changed, 36 insertions, 34 deletions
diff --git a/flake.nix b/flake.nix
index 8c60934e6..fc334ac5b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -109,6 +109,40 @@
];
};
+ installScriptFor = systems:
+ with nixpkgsFor.x86_64-linux;
+ runCommand "installer-script"
+ { buildInputs = [ nix ];
+ }
+ ''
+ mkdir -p $out/nix-support
+
+ # Converts /nix/store/50p3qk8kka9dl6wyq40vydq945k0j3kv-nix-2.4pre20201102_550e11f/bin/nix
+ # To 50p3qk8kka9dl6wyq40vydq945k0j3kv/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 ${./scripts/install.in} $out/install \
+ ${pkgs.lib.concatMapStrings
+ (system:
+ '' \
+ --replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
+ --replace '@tarballPath_${system}@' $(tarballPath ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
+ ''
+ )
+ systems
+ } --replace '@nixVersion@' ${version}
+
+ echo "file installer $out/install" >> $out/nix-support/hydra-build-products
+ '';
+
in {
# A Nixpkgs overlay that overrides the 'nix' and
@@ -313,40 +347,8 @@
# to https://nixos.org/nix/install. It downloads the binary
# tarball for the user's system and calls the second half of the
# installation script.
- installerScript =
- with nixpkgsFor.x86_64-linux;
- runCommand "installer-script"
- { buildInputs = [ nix ];
- }
- ''
- mkdir -p $out/nix-support
-
- # Converts /nix/store/50p3qk8kka9dl6wyq40vydq945k0j3kv-nix-2.4pre20201102_550e11f/bin/nix
- # To 50p3qk8kka9dl6wyq40vydq945k0j3kv/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 ${./scripts/install.in} $out/install \
- ${pkgs.lib.concatMapStrings
- (system:
- '' \
- --replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
- --replace '@tarballPath_${system}@' $(tarballPath ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
- ''
- )
- [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ]
- } \
- --replace '@nixVersion@' ${version}
-
- echo "file installer $out/install" >> $out/nix-support/hydra-build-products
- '';
+ installerScript = installScriptFor [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
+ installerScriptForGHA = installScriptFor [ "x86_64-linux" "x86_64-darwin" ];
# Line coverage analysis.
coverage =