-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
55 lines (45 loc) · 1.9 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Build release with: nix -L build .#release
{
description = "The LogJuicer app";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs@{ self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python311.withPackages
(ps: [ ps.openstacksdk ps.prometheus-client ps.pyyaml ]);
info = builtins.fromTOML (builtins.readFile ./pyproject.toml);
container-name = "ghcr.io/softwarefactory-project/zuul-capacity";
container = pkgs.dockerTools.streamLayeredImage {
name = container-name;
tag = "latest";
created = "now";
config.Entrypoint =
[ "${python}/bin/python3" "${self}/zuul-capacity.py" ];
config.Labels = {
"org.opencontainers.image.source" =
"https://github.com/softwarefactory-project/zuul-capacity";
};
};
publish-container-release =
pkgs.writeShellScriptBin "container-release" ''
set -e
export PATH=$PATH:${pkgs.gzip}/bin:${pkgs.skopeo}/bin
IMAGE="docker://${container-name}"
echo "Logging to registry..."
echo $GH_TOKEN | skopeo login --username $GH_USERNAME --password-stdin ghcr.io
echo "Building and publishing the image..."
${container} | gzip --fast | skopeo copy docker-archive:/dev/stdin $IMAGE:${info.project.version}
echo "Tagging latest"
skopeo copy $IMAGE:${info.project.version} $IMAGE:latest
'';
in {
packages.container = container;
apps.publish-container-release =
flake-utils.lib.mkApp { drv = publish-container-release; };
devShell = pkgs.mkShell { buildInputs = with pkgs; [ uv ]; };
});
}