make builds in nix flakes

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-04-29 18:06:02 +00:00
parent acd4500adf
commit a61bcfbccd
2 changed files with 30 additions and 3 deletions

View File

@ -25,6 +25,33 @@
}; };
version = builtins.substring 0 8 self.lastModifiedDate; version = builtins.substring 0 8 self.lastModifiedDate;
in { in {
packages = rec {
imagebuilder = pkgs.buildGoModule {
pname = "taildeck-imagebuilder";
inherit version;
src = ./.;
vendorSha256 =
"sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
};
tsTarball = builtins.fetchurl {
url = "https://pkgs.tailscale.com/stable/tailscale_1.24.2_amd64.tgz";
sha256 = "1b697g694vigzmv5q48l1d3pjc9l5gwzazggnfi7z9prb9cvlnx2";
};
image = pkgs.stdenv.mkDerivation {
pname = "tailscale-image";
version = "1.24.2";
buildInputs = with pkgs; [ squashfsTools imagebuilder ];
phases = "installPhase";
installPhase = ''
mkdir -p $out
taildeck --out $out --tarball ${tsTarball}
'';
};
};
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ go gopls gotools go-tools squashfsTools ]; buildInputs = with pkgs; [ go gopls gotools go-tools squashfsTools ];
}; };

View File

@ -15,8 +15,8 @@ import (
) )
var ( var (
out = flag.String("out-dir", ".", "where to save squashfs images to") out = flag.String("out", ".", "where to save squashfs images to")
tsTarballPath = flag.String("tailscale-tarball", "./var/tailscale_1.24.2_amd64.tgz", "path to tailscale tarball on disk") tsTarballPath = flag.String("tarball", "./var/tailscale_1.24.2_amd64.tgz", "path to tailscale tarball on disk")
distro = flag.String("distro", "arch", "distro to stamp into system extension") distro = flag.String("distro", "arch", "distro to stamp into system extension")
) )
@ -105,7 +105,7 @@ func main() {
} }
sp := strings.Split(filepath.Base(*tsTarballPath), "_") sp := strings.Split(filepath.Base(*tsTarballPath), "_")
cmd := exec.Command(binPath, tmpDir, fmt.Sprintf("tailscale_sysext_%s.raw", sp[1]), "-quiet", "-noappend", "-all-root", "-root-mode", "755", "-b", "1M", "-comp", "xz", "-Xdict-size", "100%") cmd := exec.Command(binPath, tmpDir, fmt.Sprintf("%s/tailscale_sysext_%s.raw", *out, sp[1]), "-quiet", "-noappend", "-all-root", "-root-mode", "755", "-b", "1M", "-comp", "xz", "-Xdict-size", "100%")
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {