I’m trying to make a derivation for the (proprietary) TotalPhase Data Center software, available here after log in from a browser. By my understanding that means I’ll need to use nix-store --add-fixed
, nix-prefetch-url
, or nix store add
to add the .zip
to the Nix store and then in the derivation use requireFile
to get the .zip
from the Nix store.
Unfortunately that does not work:
Shell session adding the file & trying nix build
:
~/tmp/totalphase-data-center took 2s
❯ nix-store --add-fixed sha256 data-center-linux-x86_64-v7.10.000.zip
/nix/store/g6cd26y2fa1pp17chflrp2bnw6pqi282-data-center-linux-x86_64-v7.10.000.zip
~/tmp/totalphase-data-center
❯ nix hash path /nix/store/g6cd26y2fa1pp17chflrp2bnw6pqi282-data-center-linux-x86_64-v7.10.000.zip
sha256-gGCHbr3nDzN6Qow8AgMa5WGnzBRkbVs4rcO8K6m7sNk=
~/tmp/totalphase-data-center
❯ nix build
error: builder for '/nix/store/0c44n2l064xbyigzyln1rziry2m6n2dw-data-center-linux-x86_64-v7.10.000.zip.drv' failed with exit code 1;
last 10 log lines:
> ***
> Unfortunately, we cannot download file data-center-linux-x86_64-v7.10.000.zip automatically.
> Please go to https://www.totalphase.com/products/data-center/ to download it yourself, and add it to the Nix store
> using either
> nix-store --add-fixed sha256 data-center-linux-x86_64-v7.10.000.zip
> or
> nix-prefetch-url --type sha256 file:///path/to/data-center-linux-x86_64-v7.10.000.zip
>
> ***
>
For full logs, run 'nix log /nix/store/0c44n2l064xbyigzyln1rziry2m6n2dw-data-center-linux-x86_64-v7.10.000.zip.drv'.
error: 1 dependencies of derivation '/nix/store/v83h4882nb34rsag4np6m6h3vcy0rsv2-totalphase-data-center-7.10.000.drv' failed to build
My current flake.nix
with the derivation:
{
description = "TotalPhase Data Center software for protocol analyzer hardware";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
version = "7.10.000";
in
{
packages.${system}.default = with pkgs; stdenv.mkDerivation {
name = "totalphase-data-center-${version}";
# Get a local file. This will error if the hash is wrong.
# Run `nix store add-file <path/to/data-center-linux-x86_64-v${version}.zip`, get the output path. Use that output in
# `nix hash path <output path of nix store add-file>`
# Paste that into the hash line below.
src = requireFile {
name = "data-center-linux-x86_64-v${version}.zip";
url = "https://www.totalphase.com/products/data-center/";
hash = "sha256-gGCHbr3nDzN6Qow8AgMa5WGnzBRkbVs4rcO8K6m7sNk=";
};
nativeBuildInputs = [
autoPatchelfHook
unzip
];
buildInputs = [
bash
gdk-pixbuf
glibc
];
sourceRoot = ".";
dontBuild = true;
dontConfigure = true;
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,doc,example,i18n,lib}
install -m755 totalphase-data-center-v${version} -d $out
runHook postInstall
'';
};
};
}
How do I get requireFile
to find the file in the Nix store?