ci: add docker image build
Some checks failed
Build a docker image. / build-docker-image (push) Failing after 4s

This commit is contained in:
2026-03-24 23:59:22 +01:00
parent a5ded91f8a
commit 4769584a4a
4 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
name: Build a docker image.
on: [push]
jobs:
build-docker-image:
runs-on: nixos
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build flake
run: nix build .#docker

View File

@@ -13,6 +13,12 @@
overlays.avcpp = final: prev: {
avcpp = final.callPackage ./nix/avcpp.nix {};
};
overlays.lib = final: prev: {
lib = prev.lib.extend (_: _:
import ./nix/lib.nix {
inherit (final) lib;
});
};
};
systems = [
"x86_64-linux"
@@ -28,12 +34,14 @@
overlays = [
self.overlays.mosh-me
self.overlays.avcpp
self.overlays.lib
];
config = {};
};
packages.default = pkgs.mosh-me;
packages.mosh-me = pkgs.mosh-me;
packages.docker = pkgs.callPackage ./nix/docker.nix {tag = pkgs.lib.gitRevOrLastModified self;};
devShells.default = self'.devShells.mosh-me;
devShells.mosh-me = pkgs.mkShell {

27
nix/docker.nix Normal file
View File

@@ -0,0 +1,27 @@
{
buildEnv,
dockerTools,
runtimeShell,
tag ? "latest",
mosh-me,
...
}:
dockerTools.buildImage {
name = "mosh-me";
inherit tag;
created = "now";
copyToRoot = buildEnv {
name = "image-root";
paths = [mosh-me];
pathsToLink = ["/bin"];
};
runAsRoot = ''
#!${runtimeShell}
mkdir -p /pwd
'';
config = {
Cmd = ["/bin/mosh-me"];
WorkingDir = "/pwd";
};
}

9
nix/lib.nix Normal file
View File

@@ -0,0 +1,9 @@
{lib, ...}: let
firstNonNull = xs: lib.findFirst (x: x != null) "unknown" xs;
in {
gitRevOrLastModified = flake:
firstNonNull [
(lib.mapNullable (r: "git-" + r) (flake.shortRev or flake.rev or null))
(lib.mapNullable (n: "from-" + (lib.toLower n)) flake.sourceInfo.lastModifiedDate or null)
];
}