generate tarball.nix with a script

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-04-29 18:43:00 +00:00
parent dd50643eaf
commit e1f9bbb8f2
3 changed files with 28 additions and 8 deletions

View File

@ -25,25 +25,21 @@
};
version = builtins.substring 0 8 self.lastModifiedDate;
in {
packages = rec {
packages = let tsmeta = import ./tarball.nix; in rec {
imagebuilder = pkgs.buildGoModule {
pname = "taildeck-imagebuilder";
inherit version;
inherit (tsmeta) version;
src = ./.;
vendorSha256 =
"sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
};
tsTarball = builtins.fetchurl {
url =
"https://pkgs.tailscale.com/stable/tailscale_1.24.2_amd64.tgz";
sha256 = "1b697g694vigzmv5q48l1d3pjc9l5gwzazggnfi7z9prb9cvlnx2";
};
tsTarball = tsmeta.tarball;
image = pkgs.stdenv.mkDerivation {
pname = "tailscale-image";
version = "1.24.2";
inherit (tsmeta) version;
buildInputs = with pkgs; [ squashfsTools imagebuilder ];
phases = "installPhase";

17
gen_tarball.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env nix-shell
#! nix-shell -p curl -p jq -p nix -i bash
set -euo pipefail
version="$(curl https://pkgs.tailscale.com/stable/?mode=json | jq .Tarballs.amd64 -r)"
url="https://pkgs.tailscale.com/stable/${version}"
shasum="$(nix-prefetch-url "${url}")"
rm -f tarball.nix
echo "{
version = \"$(echo ${version} | cut -d_ -f2)\";
tarball = builtins.fetchurl {
url = \"${url}\";
sha256 = \"${shasum}\";
};
}" >> tarball.nix

7
tarball.nix Normal file
View File

@ -0,0 +1,7 @@
{
version = "1.24.2";
tarball = builtins.fetchurl {
url = "https://pkgs.tailscale.com/stable/tailscale_1.24.2_amd64.tgz";
sha256 = "1b697g694vigzmv5q48l1d3pjc9l5gwzazggnfi7z9prb9cvlnx2";
};
}