Added most basic postgresql

Changelog: added
Signed-off-by: GeorgeRaven <GeorgeRavenCommunity@pm.me>
This commit is contained in:
GeorgeRaven
2025-10-25 20:58:24 +01:00
parent 4ea6fabb13
commit ceb85126e9
4 changed files with 43 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
**result
**result-*

View File

@@ -0,0 +1,2 @@
result
Dockerfile

View File

@@ -0,0 +1,31 @@
# https://mitchellh.com/writing/nix-with-dockerfiles
ARG GID="1000"
ARG UID="1000"
ARG SRC_DIR="."
ARG PKG_DIR="/app"
ARG NIX_STORE_DIR="/nix/store"
FROM harbor.deepcypher.me/docker.io/nixos/nix:2.32.1 AS builder
ARG SRC_DIR \
PKG_DIR
WORKDIR ${PKG_DIR}
COPY ${SRC_DIR} ${PKG_DIR}
RUN nix \
--extra-experimental-features "nix-command flakes" \
--option filter-syscalls false \
build
RUN mkdir /tmp/nix-store-closure && \
cp -R $(nix-store --query --requisites result/) /tmp/nix-store-closure && \
ls -alh /tmp/nix-store-closure
FROM scratch
ARG PKG_DIR \
UID \
GID
ENV PKG_DIR=${PKG_DIR} \
PATH=${PKG_DIR}/bin:${PATH}
COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder ${PKG_DIR}/result ${PKG_DIR}
USER ${UID}:${GID}
WORKDIR ${PKG_DIR}
CMD ["postgres"]

View File

@@ -1,23 +1,28 @@
{
description = "A flake to build and provide a postgresql environment";
description = "Basic postgresql flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-25.05";
flake-utils.url = "github:numtide/flake-utils";
# force subflake dependencies to follow nixpkgs version
# of parent flake
# flake-utils.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
...
}@inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages.postgresql = pkgs.postgresql;
packages.default = self.packages.${system}.postgresql;
# nix fmt formatter option attributes
formatter = pkgs.nixfmt-tree;
}