From 5e98d2918300462e6c87bbe485ada02caf7f961f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 23 Jan 2026 17:48:04 -0600 Subject: [PATCH] Back to just dockerTools --- flake.lock | 44 +++----------------------- flake.nix | 4 +-- img/builder.nix | 42 ++++++------------------- lib.nix | 82 +++++++++++++------------------------------------ 4 files changed, 37 insertions(+), 135 deletions(-) diff --git a/flake.lock b/flake.lock index f9f98cb..3efb586 100644 --- a/flake.lock +++ b/flake.lock @@ -18,35 +18,18 @@ "type": "github" } }, - "nix2container": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1767430085, - "narHash": "sha256-SiXJ6xv4pS2MDUqfj0/mmG746cGeJrMQGmoFgHLS25Y=", - "owner": "nlewo", - "repo": "nix2container", - "rev": "66f4b8a47e92aa744ec43acbb5e9185078983909", - "type": "github" - }, - "original": { - "owner": "nlewo", - "repo": "nix2container", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1767028467, - "narHash": "sha256-7G+2aXClSMaTY1ogpX14CAxjRsvyVzpE0GRwL71WO7g=", + "lastModified": 1763934636, + "narHash": "sha256-9glbI7f1uU+yzQCq5LwLgdZqx6svOhZWkd4JRY265fc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1cabc318c11299f07ca53e3cb719854682fe6eb3", + "rev": "ee09932cedcef15aaf476f9343d1dea2cb77e261", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -66,27 +49,10 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1763934636, - "narHash": "sha256-9glbI7f1uU+yzQCq5LwLgdZqx6svOhZWkd4JRY265fc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ee09932cedcef15aaf476f9343d1dea2cb77e261", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "flake-parts": "flake-parts", - "nix2container": "nix2container", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 2847e93..2eeb212 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,6 @@ description = "Standard images that Greg wants to build"; inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; - nix2container.url = "github:nlewo/nix2container"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; @@ -29,8 +28,7 @@ }: let lib' = import ./lib.nix { - inherit (inputs.nix2container.packages.${system}) nix2container; - inherit (pkgs) lib; + inherit pkgs; }; in { diff --git a/img/builder.nix b/img/builder.nix index 278b2be..20bd820 100644 --- a/img/builder.nix +++ b/img/builder.nix @@ -24,39 +24,17 @@ let destination = "/etc/containers/policy.json"; } ); - nix-conf = writeTextFile { - name = "nix.conf"; - text = '' - experimental-features = nix-command flakes - ''; - destination = "/etc/nix/nix.conf"; - }; in -lib'.mkImage pkgs { +lib'.mkImage { name = name "builder"; - copyToRoot = pkgs.buildEnv { - name = "policy"; - paths = [ - policy - nix-conf - ]; - }; - initializeNixDatabase = true; - layers = [ - { - deps = [ - buildah - git - nix - nix-output-monitor - podman - policy - ]; - } - { - deps = [ - nodejs_24 - ]; - } + contents = [ + buildah + git + nix + nix-output-monitor + nodejs_24 + podman + policy ]; + includeNixDB = true; } diff --git a/lib.nix b/lib.nix index 7531eba..7484ea7 100644 --- a/lib.nix +++ b/lib.nix @@ -1,70 +1,30 @@ -{ nix2container, lib, ... }: +{ pkgs, ... }: -rec { - baseImage = - pkgs: - mkImage { - inherit pkgs; - name = "src.thehellings.com/greg/base"; - }; - - baseLayer = - pkgs: with pkgs; rec { - copyToRoot = deps; - deps = [ - (pkgs.buildEnv { - name = "base-env"; - paths = [ - bashInteractive - cacert - coreutils-full - dockerTools.binSh - dockerTools.caCertificates - dockerTools.shadowSetup - dockerTools.usrBinEnv - findutils - gnugrep - gnused - ]; - }) - ]; - }; - - foldLayers = - let - merge = - parents: current: - let - layer = nix2container.buildLayer ( - current - // { - layers = parents; - } - ); - in - parents ++ [ layer ]; - in - layers: lib.foldl merge [ ] layers; +{ + basePackages = with pkgs; rec { + copyToRoot = paths; + paths = [ + bashInteractive + cacert + coreutils-full + dockerTools.binSh + dockerTools.caCertificates + dockerTools.shadowSetup + dockerTools.usrBinEnv + findutils + gnugrep + gnused + ]; + }; mkImage = - pkgs: config: - let - base = baseLayer pkgs; - path = pkgs.lib.makeBinPath (base.deps ++ lib.flatten (builtins.map (e: e.deps) config.layers)); - in - nix2container.buildImage ( - (lib.mergeAttrs { + options: + pkgs.dockerTools.buildLayeredImage ( + pkgs.lib.mergeAttrs { tag = "latest"; config = { - Env = [ - "PATH=${path}" - "USER=nobody" - ]; Cmd = [ "${pkgs.bashInteractive}/bin/bash" ]; }; - } config) - // { - layers = foldLayers ([ base ] ++ config.layers); - } + } options ); }