ci: add docker image build
Some checks failed
Build a docker image. / build-docker-image (push) Failing after 4s
Some checks failed
Build a docker image. / build-docker-image (push) Failing after 4s
This commit is contained in:
12
.gitea/workflows/docker.yaml
Normal file
12
.gitea/workflows/docker.yaml
Normal 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
|
||||
@@ -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
27
nix/docker.nix
Normal 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
9
nix/lib.nix
Normal 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)
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user