diff options
| author | seth <[email protected]> | 2024-01-07 20:42:07 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-01-07 21:08:57 -0500 |
| commit | 90ad9d652f009a53b57115c924446baf6f1d3b7b (patch) | |
| tree | 6df1841fc082fefd37846391a0d9964cb482b401 /container.nix | |
| parent | 4578d68f3106f95607e9d3e713936ba2a565322b (diff) | |
feat: use nix to build images
this should result in smaller images, as well as safer updates
Diffstat (limited to 'container.nix')
| -rw-r--r-- | container.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/container.nix b/container.nix new file mode 100644 index 0000000..79d7c5c --- /dev/null +++ b/container.nix @@ -0,0 +1,51 @@ +{ + lib, + pkgs, + system, + ... +}: arch: let + crossPkgs = + { + "x86_64-linux" = { + "x86_64" = pkgs.pkgsStatic; + "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; + }; + + "aarch64-linux" = { + "x86_64" = pkgs.pkgsCross.musl64; + "aarch64" = pkgs.pkgsStatic; + }; + } + .${system} + .${arch}; + + packwiz = crossPkgs.packwiz.overrideAttrs (oldAttrs: { + ldflags = [ + "-linkmode external" + "-extldflags '-static -L${crossPkgs.musl}/lib'" + "-s -w -X github.com/packwiz/packwiz.version=${oldAttrs.version}" + ]; + + postInstall = ""; + + CGO_ENABLED = 0; + }); +in + pkgs.dockerTools.buildLayeredImage { + name = "packwiz-serve"; + tag = "latest-${arch}"; + + contents = [packwiz]; + + config = { + Cmd = ["/bin/packwiz" "serve"]; + Env = [ + "HOME=/home" # why exactly does packwiz need a home dir? :shrug: + ]; + WorkingDir = "/data"; + Volumes = {"/data" = {};}; + ExposedPorts = {"8080" = {};}; + }; + + architecture = crossPkgs.go.GOARCH; + } |
