flake(pihole): build pihole docker image (x86_64 & aarch64) + basic devShell for updating image info
This commit is contained in:
commit
ef77de3abd
2 changed files with 69 additions and 0 deletions
63
flake.nix
Normal file
63
flake.nix
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
{
|
||||||
|
description = "Pihole docker image & NixOS module for configuring a rootless pihole container (w/ port-forwarding)";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||||
|
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils }: with flake-utils.lib; eachSystem (with system; [ x86_64-linux aarch64-linux ]) (curSystem:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${curSystem};
|
||||||
|
|
||||||
|
imageName = "pihole/pihole";
|
||||||
|
imageBaseInfo = import ./pihole-image-base-info.nix;
|
||||||
|
imageInfo = {
|
||||||
|
${system.x86_64-linux}.pihole = imageBaseInfo // {
|
||||||
|
arch = "amd64";
|
||||||
|
sha256 = "sha256-5FUtafW2YdTfOfA0ieiyJasMUYEGReOMQ4PGZ8e32hY=";
|
||||||
|
};
|
||||||
|
|
||||||
|
${system.aarch64-linux}.pihole = imageBaseInfo // {
|
||||||
|
arch = "arm64";
|
||||||
|
sha256 = "sha256-1gizGShpYT1IM3OzomTrHzoLWBejhOWmcLs52YauGzc=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
piholeImage = pkgs.dockerTools.pullImage imageInfo.${curSystem}.pihole;
|
||||||
|
|
||||||
|
in {
|
||||||
|
packages = {
|
||||||
|
inherit piholeImage;
|
||||||
|
default = piholeImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = let
|
||||||
|
updatePiholeImageInfoScript = pkgs.writeShellScriptBin "update-pihole-image-info" ''
|
||||||
|
INSPECT_RESULT=`skopeo inspect "docker://${imageName}:latest"`
|
||||||
|
IMAGE_DIGEST=`echo $INSPECT_RESULT | jq '.Digest'`
|
||||||
|
LATEST_LABEL=`echo $INSPECT_RESULT | jq '.Labels."org.opencontainers.image.version"'`
|
||||||
|
|
||||||
|
cat >pihole-image-base-info.nix <<EOF
|
||||||
|
{
|
||||||
|
imageName = "${imageName}";
|
||||||
|
imageDigest = $IMAGE_DIGEST;
|
||||||
|
finalImageTag = $LATEST_LABEL;
|
||||||
|
os = "linux";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
|
||||||
|
in pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
skopeo
|
||||||
|
jq
|
||||||
|
updatePiholeImageInfoScript
|
||||||
|
];
|
||||||
|
|
||||||
|
inputsFrom = [ self.packages.${curSystem}.default ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
6
pihole-image-base-info.nix
Normal file
6
pihole-image-base-info.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
imageName = "pihole/pihole";
|
||||||
|
imageDigest = "sha256:aa6140856dfc67f3ae36c352e30903f944e4e220699ffeeaf6b85235b2d84c95";
|
||||||
|
finalImageTag = "2022.09.4";
|
||||||
|
os = "linux";
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue