Skip to content

Instantly share code, notes, and snippets.

@akkesm
Created January 26, 2022 17:51
Show Gist options
  • Save akkesm/9d1241410500d069ceb37bb0c7c73e13 to your computer and use it in GitHub Desktop.
Save akkesm/9d1241410500d069ceb37bb0c7c73e13 to your computer and use it in GitHub Desktop.
Small Perl 5.34 Docker image
# build with `nix build`
# 153 MB with cpanm
# 93 MB without cpanm
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
in
{
overlay = final: prev: {
perl-extraflags = prev.perl534.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ [
"-Duse64bitall"
"-Dcccdlflags='-fPIC'"
"-Dcccdlflags='-fPIC'"
"-Dccdlflags='-rdynamic'"
"-Duselargefiles"
"-Dd_semctl_semun"
];
});
perl-docker = final.dockerTools.buildImage {
name = "perl-small";
contents = final.perl534Packages.Appcpanminus;
config = {
Cmd = [ "${final.perl-extraflags}/bin/perl" "-de0" ];
WorkingDir = "/";
};
};
};
packages = forAllSystems (system: { inherit (nixpkgsFor.${system}) perl-docker; });
defaultPackage = forAllSystems (system: self.packages.${system}.perl-docker);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment