1 Commits

24 changed files with 37 additions and 230 deletions

View File

@@ -2,13 +2,12 @@ name: Nix
on: on:
push: push:
branches: branches:
- main - master
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
schedule: schedule:
# Run once per day # Run once per day
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
build: build:
strategy: strategy:
@@ -17,66 +16,13 @@ jobs:
matrix: matrix:
channel: channel:
- nixos-unstable - nixos-unstable
- nixos-25.05 - nixos-22.11
- nixos-25.11 - nixos-23.05
system: runs-on: native
- aarch64-linux container: pjjw/nix-flake-runner:1
- x86_64-linux
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v3
- name: Set up QEMU - run: nix-shell --run ./ci.sh
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-platforms = aarch64-linux
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Push to Docker Hub
run: nix-shell --run ./ci.sh
env:
CI_PROJECT_PATH: 'nixpkgs'
CI_REGISTRY: 'docker.io'
CI_REGISTRY_AUTH: '${{ secrets.REGISTRY_AUTH }}'
NIXPKGS_CHANNEL: '${{ matrix.channel }}'
NIX_SYSTEM_NAME: '${{ matrix.system }}'
- name: Push to GitHub Pages
run: nix-shell --run ./ci.sh
env:
CI_PROJECT_PATH: 'nix-community/docker-nixpkgs'
CI_REGISTRY: 'ghcr.io'
CI_REGISTRY_AUTH: '${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}'
NIXPKGS_CHANNEL: '${{ matrix.channel }}'
NIX_SYSTEM_NAME: '${{ matrix.system }}'
push-manifest:
needs: [build]
strategy:
fail-fast: false
matrix:
channel:
- nixos-unstable
- nixos-25.05
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-platforms = aarch64-linux
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix-shell --run ./ci-manifests.sh
env: env:
CI_REGISTRY_AUTH: '${{ secrets.REGISTRY_AUTH }}' CI_REGISTRY_AUTH: '${{ secrets.REGISTRY_AUTH }}'
NIXPKGS_CHANNEL: '${{ matrix.channel }}' NIXPKGS_CHANNEL: '${{ matrix.channel }}'
NIX_SYSTEM_NAME: '${{ matrix.system }}'

View File

@@ -3,12 +3,12 @@ stages:
build: build:
stage: build stage: build
image: nixpkgs/nix:nixos-25.05 image: nixpkgs/nix:nixos-22.11
script: nix-shell --run ./ci.sh script: nix-shell --run ./ci.sh
parallel: parallel:
matrix: matrix:
- NIXPKGS_CHANNEL: nixos-unstable - NIXPKGS_CHANNEL: nixos-unstable
IMAGE_TAG: latest IMAGE_TAG: latest
- NIXPKGS_CHANNEL: - NIXPKGS_CHANNEL:
- nixos-25.05 - nixos-22.11
- nixos-25.11 - nixos-23.05

View File

@@ -39,8 +39,8 @@ nixpkgs channel describes.
| Channel | Image Tag | Description | | Channel | Image Tag | Description |
| --- | --- | --- | | --- | --- | --- |
| nixos-25.05 | nixos-25.05 | only minor versions that include security updates | | nixos-22.11 | nixos-22.11 | only minor versions that include security updates |
| nixos-25.11 | nixos-25.11 | only minor versions that include security updates | | nixos-23.05 | nixos-23.05 | only minor versions that include security updates |
| nixos-unstable | latest | latest and greatest, major versions might change | | nixos-unstable | latest | latest and greatest, major versions might change |
## List of images ## List of images
@@ -52,11 +52,9 @@ All images are automatically built and published to Docker Hub, and served
on our custom domain, courtesy of [Scarf](https://scarf.sh). on our custom domain, courtesy of [Scarf](https://scarf.sh).
`> ./readme-image-matrix` `> ./readme-image-matrix`
<!-- BEGIN mdsh --> <!-- BEGIN mdsh -->
| Image / Tag | Pull | | Image / Tag | Pull |
| --- | --- | | --- | --- |
| [nixpkgs/attic](https://hub.docker.com/r/nixpkgs/attic)| `docker pull docker.nix-community.org/nixpkgs/attic` |
| [nixpkgs/bash](https://hub.docker.com/r/nixpkgs/bash)| `docker pull docker.nix-community.org/nixpkgs/bash` | | [nixpkgs/bash](https://hub.docker.com/r/nixpkgs/bash)| `docker pull docker.nix-community.org/nixpkgs/bash` |
| [nixpkgs/busybox](https://hub.docker.com/r/nixpkgs/busybox)| `docker pull docker.nix-community.org/nixpkgs/busybox` | | [nixpkgs/busybox](https://hub.docker.com/r/nixpkgs/busybox)| `docker pull docker.nix-community.org/nixpkgs/busybox` |
| [nixpkgs/cachix](https://hub.docker.com/r/nixpkgs/cachix)| `docker pull docker.nix-community.org/nixpkgs/cachix` | | [nixpkgs/cachix](https://hub.docker.com/r/nixpkgs/cachix)| `docker pull docker.nix-community.org/nixpkgs/cachix` |
@@ -64,19 +62,15 @@ on our custom domain, courtesy of [Scarf](https://scarf.sh).
| [nixpkgs/caddy](https://hub.docker.com/r/nixpkgs/caddy)| `docker pull docker.nix-community.org/nixpkgs/caddy` | | [nixpkgs/caddy](https://hub.docker.com/r/nixpkgs/caddy)| `docker pull docker.nix-community.org/nixpkgs/caddy` |
| [nixpkgs/curl](https://hub.docker.com/r/nixpkgs/curl)| `docker pull docker.nix-community.org/nixpkgs/curl` | | [nixpkgs/curl](https://hub.docker.com/r/nixpkgs/curl)| `docker pull docker.nix-community.org/nixpkgs/curl` |
| [nixpkgs/devcontainer](https://hub.docker.com/r/nixpkgs/devcontainer)| `docker pull docker.nix-community.org/nixpkgs/devcontainer` | | [nixpkgs/devcontainer](https://hub.docker.com/r/nixpkgs/devcontainer)| `docker pull docker.nix-community.org/nixpkgs/devcontainer` |
| [nixpkgs/devenv](https://hub.docker.com/r/nixpkgs/devenv)| `docker pull docker.nix-community.org/nixpkgs/devenv` |
| [nixpkgs/docker-compose](https://hub.docker.com/r/nixpkgs/docker-compose)| `docker pull docker.nix-community.org/nixpkgs/docker-compose` | | [nixpkgs/docker-compose](https://hub.docker.com/r/nixpkgs/docker-compose)| `docker pull docker.nix-community.org/nixpkgs/docker-compose` |
| [nixpkgs/hugo](https://hub.docker.com/r/nixpkgs/hugo)| `docker pull docker.nix-community.org/nixpkgs/hugo` | | [nixpkgs/hugo](https://hub.docker.com/r/nixpkgs/hugo)| `docker pull docker.nix-community.org/nixpkgs/hugo` |
| [nixpkgs/kubectl](https://hub.docker.com/r/nixpkgs/kubectl)| `docker pull docker.nix-community.org/nixpkgs/kubectl` | | [nixpkgs/kubectl](https://hub.docker.com/r/nixpkgs/kubectl)| `docker pull docker.nix-community.org/nixpkgs/kubectl` |
| [nixpkgs/kubernetes-helm](https://hub.docker.com/r/nixpkgs/kubernetes-helm)| `docker pull docker.nix-community.org/nixpkgs/kubernetes-helm` | | [nixpkgs/kubernetes-helm](https://hub.docker.com/r/nixpkgs/kubernetes-helm)| `docker pull docker.nix-community.org/nixpkgs/kubernetes-helm` |
| [nixpkgs/maddy](https://hub.docker.com/r/nixpkgs/maddy)| `docker pull docker.nix-community.org/nixpkgs/maddy` |
| [nixpkgs/nginx](https://hub.docker.com/r/nixpkgs/nginx)| `docker pull docker.nix-community.org/nixpkgs/nginx` | | [nixpkgs/nginx](https://hub.docker.com/r/nixpkgs/nginx)| `docker pull docker.nix-community.org/nixpkgs/nginx` |
| [nixpkgs/nix](https://hub.docker.com/r/nixpkgs/nix)| `docker pull docker.nix-community.org/nixpkgs/nix` | | [nixpkgs/nix](https://hub.docker.com/r/nixpkgs/nix)| `docker pull docker.nix-community.org/nixpkgs/nix` |
| [nixpkgs/nix-flakes](https://hub.docker.com/r/nixpkgs/nix-flakes)| `docker pull docker.nix-community.org/nixpkgs/nix-flakes` | | [nixpkgs/nix-flakes](https://hub.docker.com/r/nixpkgs/nix-flakes)| `docker pull docker.nix-community.org/nixpkgs/nix-flakes` |
| [nixpkgs/nix-unstable](https://hub.docker.com/r/nixpkgs/nix-unstable)| `docker pull docker.nix-community.org/nixpkgs/nix-unstable` | | [nixpkgs/nix-unstable](https://hub.docker.com/r/nixpkgs/nix-unstable)| `docker pull docker.nix-community.org/nixpkgs/nix-unstable` |
| [nixpkgs/nix-unstable-static](https://hub.docker.com/r/nixpkgs/nix-unstable-static)| `docker pull docker.nix-community.org/nixpkgs/nix-unstable-static` | | [nixpkgs/nix-unstable-static](https://hub.docker.com/r/nixpkgs/nix-unstable-static)| `docker pull docker.nix-community.org/nixpkgs/nix-unstable-static` |
| [nixpkgs/pocket-id](https://hub.docker.com/r/nixpkgs/pocket-id)| `docker pull docker.nix-community.org/nixpkgs/pocket-id` |
| [nixpkgs/yarr](https://hub.docker.com/r/nixpkgs/yarr)| `docker pull docker.nix-community.org/nixpkgs/yarr` |
<!-- END mdsh --> <!-- END mdsh -->
## Adding new images ## Adding new images

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env bash
#
# CI specific build script.
#
set -euo pipefail
channel=${NIXPKGS_CHANNEL:-nixos-unstable}
registry=${CI_REGISTRY:-docker.io}
registry_auth=${CI_REGISTRY_AUTH:-}
image_prefix=${CI_PROJECT_PATH:-nixpkgs}
if [[ $channel == nixos-unstable ]]; then
image_tag=latest
else
image_tag=$channel
fi
export NIX_PATH=channel:$channel
banner() {
echo "========================================================"
echo " $*"
echo "========================================================"
}
cd "$(dirname "$0")"
if [[ $(git rev-parse --abbrev-ref HEAD) != main ]]; then
banner "Skipping push on non-main branch"
exit
fi
if [[ -n "${registry_auth}" ]]; then
banner "docker login"
./docker-login "$registry_auth" "$registry"
fi
banner "generate manifests"
./generate-manifests "$registry" "$image_prefix" "$image_tag"

6
ci.sh
View File

@@ -8,7 +8,6 @@ channel=${NIXPKGS_CHANNEL:-nixos-unstable}
registry=${CI_REGISTRY:-docker.io} registry=${CI_REGISTRY:-docker.io}
registry_auth=${CI_REGISTRY_AUTH:-} registry_auth=${CI_REGISTRY_AUTH:-}
image_prefix=${CI_PROJECT_PATH:-nixpkgs} image_prefix=${CI_PROJECT_PATH:-nixpkgs}
system_name=${NIX_SYSTEM_NAME:-x86_64-linux}
if [[ $channel == nixos-unstable ]]; then if [[ $channel == nixos-unstable ]]; then
image_tag=latest image_tag=latest
@@ -31,10 +30,9 @@ banner "Building images"
nix-build \ nix-build \
--no-out-link \ --no-out-link \
--option sandbox true \ --option sandbox true \
--argstr system "$system_name"
if [[ $(git rev-parse --abbrev-ref HEAD) != main ]]; then if [[ $(git rev-parse --abbrev-ref HEAD) != master ]]; then
banner "Skipping push on non-main branch" banner "Skipping push on non-master branch"
exit exit
fi fi

View File

@@ -1,14 +1,4 @@
{ let
system ? builtins.currentSystem pkgs = import ./pkgs.nix;
}: let
_parts = builtins.split "-" system;
arch = builtins.elemAt _parts 0;
os = builtins.elemAt _parts 2;
system' =
if os == "darwin"
then "${arch}-linux"
else system;
pkgs =
import ./pkgs.nix system';
in in
pkgs.docker-nixpkgs pkgs.docker-nixpkgs

View File

@@ -8,10 +8,9 @@ set -euo pipefail
user=$1 user=$1
org=${2:-nixpkgs} org=${2:-nixpkgs}
system_name=${NIX_SYSTEM_NAME:-x86_64-linux}
nix_eval() { nix_eval() {
nix-instantiate --strict --eval --argstr system "$system_name" --json "$@" nix-instantiate --strict --eval --json "$@"
} }
releases_json=$(nix_eval) releases_json=$(nix_eval)

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
#
# Usage: ./push-all <registry> <image-prefix> <image-tag>
set -euo pipefail
registry=${1:-docker.io}
image_prefix=${2:-nixpkgs}
image_tag=${3:-latest}
system_name=${NIX_SYSTEM_NAME:-x86_64-linux}
releases_json=$(nix-instantiate --strict --argstr system "$system_name" --eval --json)
echo "=== Generating manifests for $registry"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
repository=$registry/$image_prefix/$attr
target_image=${repository}:${image_tag}
echo "--- attr=$attr target=$target_image"
podman manifest create "$target_image"
podman manifest add "$target_image" "docker://$repository:${image_tag}-x86_64-linux"
podman manifest add "$target_image" "docker://$repository:${image_tag}-aarch64-linux"
podman manifest push --all "$target_image" "docker://$target_image"
done
echo OK

View File

@@ -1,10 +0,0 @@
{ docker-nixpkgs
, attic-client
}:
(docker-nixpkgs.nix.override {
extraContents = [ attic-client ];
}).overrideAttrs (prev: {
meta = (prev.meta or { }) // {
description = "Nix and Attic client image";
};
})

View File

@@ -14,7 +14,7 @@
, gnutar , gnutar
, gzip , gzip
, iana-etc , iana-etc
, iproute2 , iproute
, less , less
, lib , lib
, nix , nix
@@ -42,11 +42,7 @@ let
nix nix
# runtime dependencies of nix # runtime dependencies of nix
# HACK: don't include the "hashed" output. It has overlapping files with cacert
# the "unbundled" output, and that breaks the build.
(cacert // {
outputs = builtins.filter (x: x != "hashed") cacert.outputs;
})
gitReallyMinimal gitReallyMinimal
gnutar gnutar
gzip gzip
@@ -65,7 +61,7 @@ let
(gcc-unwrapped // { (gcc-unwrapped // {
outputs = builtins.filter (x: x != "libgcc") gcc-unwrapped.outputs; outputs = builtins.filter (x: x != "libgcc") gcc-unwrapped.outputs;
}) })
iproute2 iproute
]; ];
}; };
@@ -130,7 +126,7 @@ let
]; ];
Labels = { Labels = {
# https://github.com/microscaling/microscaling/blob/55a2d7b91ce7513e07f8b1fd91bbed8df59aed5a/Dockerfile#L22-L33 # https://github.com/microscaling/microscaling/blob/55a2d7b91ce7513e07f8b1fd91bbed8df59aed5a/Dockerfile#L22-L33
"org.label-schema.vcs-ref" = "main"; "org.label-schema.vcs-ref" = "master";
"org.label-schema.vcs-url" = "https://github.com/nix-community/docker-nixpkgs"; "org.label-schema.vcs-url" = "https://github.com/nix-community/docker-nixpkgs";
}; };
}; };

View File

@@ -1,11 +0,0 @@
{ docker-nixpkgs
, devenv ? null
}:
(docker-nixpkgs.nix.override {
# only available since 24.05
extraContents = [ devenv ];
}).overrideAttrs (prev: {
meta = (prev.meta or { }) // {
description = "Nix and devenv image";
};
})

View File

@@ -1,6 +0,0 @@
{ buildCLIImage
, maddy
}:
buildCLIImage {
drv = maddy;
}

View File

@@ -1,10 +1,10 @@
{ docker-nixpkgs { docker-nixpkgs
, nixVersions , nixFlakes
, writeTextFile , writeTextFile
, extraContents ? [ ] , extraContents ? [ ]
}: }:
docker-nixpkgs.nix.override { docker-nixpkgs.nix.override {
nix = nixVersions.stable; nix = nixFlakes;
extraContents = [ extraContents = [
(writeTextFile { (writeTextFile {
name = "nix.conf"; name = "nix.conf";
@@ -12,12 +12,7 @@ docker-nixpkgs.nix.override {
text = '' text = ''
accept-flake-config = true accept-flake-config = true
experimental-features = nix-command flakes experimental-features = nix-command flakes
max-jobs = auto
''; '';
}) })
] ++ extraContents; ] ++ extraContents;
extraEnv = [
"PATH=/root/.nix-profile/bin:/usr/bin:/bin" # Not sure how to just prepend
];
} }

View File

@@ -19,8 +19,8 @@ let
# Get nix from Hydra because the nixpkgs one is not fully static # Get nix from Hydra because the nixpkgs one is not fully static
nixStaticBin = fetchurl { nixStaticBin = fetchurl {
url = "https://hydra.nixos.org/build/305222051/download/1/nix"; url = "https://hydra.nixos.org/build/181573550/download/1/nix";
hash = "sha256-OahnvQ/OKnRhbXaIJ7iEQYu86ECGtUqwW8XrryVkXaM="; hash = "sha256-zO2xJhQIrLtL/ReTlcorjwsaTO1W5Rnr+sXwcLcujok=";
}; };
nixSymlinks = [ nixSymlinks = [
@@ -84,12 +84,11 @@ let
mkdir -p libexec/nix mkdir -p libexec/nix
ln -s /bin/nix libexec/nix/build-remote ln -s /bin/nix libexec/nix/build-remote
# Enable flakes and parallel building # Enable flakes
mkdir -p etc/nix mkdir -p etc/nix
cat <<NIX_CONFIG > etc/nix/nix.conf cat <<NIX_CONFIG > etc/nix/nix.conf
accept-flake-config = true accept-flake-config = true
experimental-features = nix-command flakes experimental-features = nix-command flakes
max-jobs = auto
NIX_CONFIG NIX_CONFIG
# Add run-as-user script # Add run-as-user script

View File

@@ -1,6 +1,6 @@
{ docker-nixpkgs { docker-nixpkgs
, pkgs , nixUnstable
}: }:
docker-nixpkgs.nix.override { docker-nixpkgs.nix.override {
nix = pkgs.nixVersions.latest; nix = nixUnstable;
} }

View File

@@ -11,7 +11,6 @@
, openssh , openssh
, xz , xz
, extraContents ? [ ] , extraContents ? [ ]
, extraEnv ? [ ]
}: }:
let let
image = dockerTools.buildImageWithNixDb { image = dockerTools.buildImageWithNixDb {
@@ -59,7 +58,7 @@ let
"PATH=/usr/bin:/bin" "PATH=/usr/bin:/bin"
"SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt" "SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt"
"USER=root" "USER=root"
] ++ extraEnv; ];
}; };
}; };
in in

View File

@@ -3,7 +3,7 @@ throw ''
This container doesn't include nixpkgs. This container doesn't include nixpkgs.
The best way to work around that is to pin your dependencies. See The best way to work around that is to pin your dependencies. See
https://nix.dev/tutorials/first-steps/towards-reproducibility-pinning-nixpkgs.html https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html
Or if you must, override the NIX_PATH environment variable with eg: Or if you must, override the NIX_PATH environment variable with eg:
"NIX_PATH=nixpkgs=channel:nixos-unstable" "NIX_PATH=nixpkgs=channel:nixos-unstable"

View File

@@ -1,6 +0,0 @@
{ buildCLIImage
, pocket-id
}:
buildCLIImage {
drv = pocket-id;
}

View File

@@ -1,6 +0,0 @@
{ buildCLIImage
, yarr
}:
buildCLIImage {
drv = yarr;
}

View File

@@ -28,7 +28,7 @@ let
]; ];
Labels = { Labels = {
# https://github.com/microscaling/microscaling/blob/55a2d7b91ce7513e07f8b1fd91bbed8df59aed5a/Dockerfile#L22-L33 # https://github.com/microscaling/microscaling/blob/55a2d7b91ce7513e07f8b1fd91bbed8df59aed5a/Dockerfile#L22-L33
"org.label-schema.vcs-ref" = "main"; "org.label-schema.vcs-ref" = "master";
"org.label-schema.vcs-url" = "https://github.com/nix-community/docker-nixpkgs"; "org.label-schema.vcs-url" = "https://github.com/nix-community/docker-nixpkgs";
}; };
}; };

View File

@@ -1,9 +1,7 @@
system:
# docker images run on Linux
assert builtins.elem system ["x86_64-linux" "aarch64-linux"];
import <nixpkgs> { import <nixpkgs> {
# docker images run on Linux
system = "x86_64-linux";
config = { }; config = { };
inherit system;
overlays = [ overlays = [
(import ./overlay.nix) (import ./overlay.nix)
]; ];

View File

@@ -6,16 +6,15 @@ set -euo pipefail
registry=${1:-docker.io} registry=${1:-docker.io}
image_prefix=${2:-nixpkgs} image_prefix=${2:-nixpkgs}
image_tag=${3:-latest} image_tag=${3:-latest}
system_name=${NIX_SYSTEM_NAME:-x86_64-linux}
releases_json=$(nix-instantiate --strict --argstr system "$system_name" --eval --json) releases_json=$(nix-instantiate --strict --eval --json)
echo "=== Pushing images to $registry" echo "=== Pushing images to $registry"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
file=$(echo "$releases_json" | jq -r ".\"$attr\"") file=$(echo "$releases_json" | jq -r ".\"$attr\"")
src=docker-archive://$file src=docker-archive://$file
dst=docker://$registry/$image_prefix/$attr:${image_tag}-${system_name} dst=docker://$registry/$image_prefix/$attr:$image_tag
echo "--- attr=$attr src=$src dst=$dst" echo "--- attr=$attr src=$src dst=$dst"
skopeo copy --insecure-policy "$src" "$dst" skopeo copy --insecure-policy "$src" "$dst"
done done

View File

@@ -3,11 +3,9 @@
# Usage: ./dockerhub-image-matrix # Usage: ./dockerhub-image-matrix
set -euo pipefail set -euo pipefail
system_name=${NIX_SYSTEM_NAME:-x86_64-linux}
## Main ## ## Main ##
releases_json=$(nix-instantiate --strict --argstr system "$system_name" --eval --json) releases_json=$(nix-instantiate --strict --eval --json)
echo "| Image / Tag | Pull |" echo "| Image / Tag | Pull |"
echo "| --- | --- |" echo "| --- | --- |"

View File

@@ -1,5 +1,5 @@
let let
nixpkgs = builtins.fetchTarball "channel:nixos-23.11"; nixpkgs = builtins.fetchTarball "channel:nixos-22.05";
pkgs = import nixpkgs { config = { }; overlays = [ ]; }; pkgs = import nixpkgs { config = { }; overlays = [ ]; };
in in
with pkgs; with pkgs;
@@ -8,7 +8,6 @@ mkShell {
dive dive
jq jq
skopeo skopeo
podman
] ++ lib.optional (pkgs ? mdsh) pkgs.mdsh; ] ++ lib.optional (pkgs ? mdsh) pkgs.mdsh;
shellHook = '' shellHook = ''