Skip to content

Commit

Permalink
Merge pull request #12 from azazak123/feat/add-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
azazak123 authored Feb 28, 2024
2 parents df02688 + 1597557 commit a31cbea
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ jobs:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: nix build
- name: Build docker image
run: nix build .#staticDocker
- name: Build static
run: nix build .#static
- name: Build docker image of static
run: nix build .#staticDocker
- name: Test
run: nix develop --command dune runtest
- name: Check
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 32 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"x86_64-linux"
];

createScope = pkgs: on: on.buildDuneProject { pkgs = pkgs; } package ./. query;

# Packages from devPackagesQuery
getOcamlDevPackages = pkgs: scope:
builtins.attrValues
Expand All @@ -36,6 +34,8 @@
ocaml-base-compiler = "*";
};

createScope = pkgs: on: on.buildDuneProject { pkgs = pkgs; } package ./. query;

getDevPackages = pkgs:
with pkgs;[
zip
Expand Down Expand Up @@ -69,12 +69,37 @@
f system pkgs scope
);

getDockerImage = pkgs: pkg: pkgs.dockerTools.buildImage {
name = package;
tag = "latest";
created = "now";

copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ pkg pkgs.iana-etc ];
pathsToLink = [ "/bin" "/etc" ];
};

extraCommands = ''
mkdir -p ./tmp
'';

config = {
Cmd = [ "/bin/${package}" ];
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
ExposedPorts = {
"80/tcp" = { };
};
};
};

in
nixpkgs.lib.recursiveUpdate
rec {
packages = forSystems (_: _: scope:
{
packages = forSystems (_: pkgs: scope:
rec {
default = scope.${package};
docker = getDockerImage pkgs default;
}
);

Expand Down Expand Up @@ -104,7 +129,6 @@
(attr: {
# Prevent the ocaml dependencies from leaking into dependent environments
doNixSupport = false;
removeOcamlReferences = true;

buildInputs = attr.buildInputs ++ [
pkgs.pkgsStatic.gmp
Expand All @@ -115,22 +139,16 @@
buildPhase = "dune build -p avatar-bot --profile static";
}
);

conf-gmp = prev.conf-gmp.overrideAttrs (attr: {
depsBuildBuild = [ pkgs.stdenv.cc ];
});

conf-gmp-powm-sec = prev.conf-gmp-powm-sec.overrideAttrs (attr: {
depsBuildBuild = [ pkgs.stdenv.cc ];
});
};

scopeMusl =
((createScope pkgsMusl on).overrideScope' overlayMusl);
mainMusl = scopeMusl.${package};
in
{
rec {
packages.x86_64-linux.static = mainMusl;
packages.x86_64-linux.staticDocker =
getDockerImage pkgs packages.x86_64-linux.static;

devShells.x86_64-linux.static = pkgsMusl.mkShell {
inputsFrom = [ mainMusl ];
Expand Down

0 comments on commit a31cbea

Please sign in to comment.