106 Commits

Author SHA1 Message Date
d8d767b117 Merge pull request 'add a nix-flake runner' (#1) from pjjw/nix-flake-runner into master
Some checks failed
Nix / build (nixos-23.05) (push) Failing after 6m13s
Nix / build (nixos-unstable) (push) Failing after 6m13s
Nix / build (nixos-22.11) (push) Failing after 4m58s
Reviewed-on: #1
2023-09-09 21:04:42 -04:00
09896ba4d9 Merge branch 'master' into pjjw/nix-flake-runner
All checks were successful
Nix / build (nixos-22.11) (pull_request) Successful in 24m52s
Nix / build (nixos-unstable) (pull_request) Successful in 15m51s
Nix / build (nixos-23.05) (pull_request) Successful in 18m43s
2023-09-08 12:24:40 -04:00
1cc157b032 Merge pull request 'cachix action failing for unknown reasons, patch to use local runner' (#2) from pjjw/gitea-actions into master
Some checks failed
Nix / build (nixos-unstable) (push) Failing after 21m13s
Nix / build (nixos-22.11) (push) Failing after 23m58s
Nix / build (nixos-23.05) (push) Failing after 24m32s
Reviewed-on: #2
2023-09-08 12:24:27 -04:00
617b5494c1 cachix action failing for unknown reasons, patch to use local runner
All checks were successful
Nix / build (nixos-22.11) (pull_request) Successful in 23m0s
Nix / build (nixos-unstable) (pull_request) Successful in 15m41s
Nix / build (nixos-23.05) (pull_request) Successful in 18m47s
2023-09-07 16:06:59 -04:00
183980b7bb add a nix-flake runner
Some checks failed
Nix / build (nixos-22.11) (pull_request) Failing after 18s
Nix / build (nixos-23.05) (pull_request) Failing after 26s
Nix / build (nixos-unstable) (pull_request) Failing after 26s
2023-09-07 15:44:37 -04:00
Jonas Chevalier
30ea4a75cd devcontainer: fix build on nixos-unstable (#64) 2023-07-18 17:31:21 +02:00
Franz Pletz
ae6d994038 bump to nixos-23.05 (#59)
fixes #57
2023-07-01 22:04:07 +02:00
dependabot[bot]
e9b6514e0e build(deps): bump cachix/install-nix-action from 20 to 22 (#58)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 20 to 22.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v20...v22)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 12:44:07 +02:00
dependabot[bot]
2205fb4968 build(deps): bump cachix/install-nix-action from 19 to 20 (#52)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 19 to 20.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v19...v20)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 08:52:19 +01:00
dependabot[bot]
d46ba9596d build(deps): bump cachix/install-nix-action from 18 to 19 (#49)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 18 to 19.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v18...v19)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 11:06:41 +01:00
Jay Rovacsek
c12f0c3133 Add 22.11 channel and use ubuntu:latest in CI (#48)
* Add 22.11, remove 21.05

* Replace references to 21.05 in favour of 22.11

* Update .github/workflows/nix.yml

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>

* Fix accidental regression of adding 21.11 back

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2022-12-14 23:32:59 +01:00
zimbatm
e334012b86 bump to nixos-22.11
Fixes #47
2022-12-14 17:01:56 +01:00
Jörg Thalheim
76af1060a4 Merge pull request #45 from nix-community/dependabot/github_actions/cachix/install-nix-action-18
build(deps): bump cachix/install-nix-action from 17 to 18
2022-10-17 10:28:35 +02:00
dependabot[bot]
adf38be427 build(deps): bump cachix/install-nix-action from 17 to 18
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 17 to 18.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v17...v18)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-17 04:03:24 +00:00
zimbatm
f0ddafd597 nix-unstable-static: enable nix flakes 2022-06-29 18:18:14 +02:00
zimbatm
ac55a180db nix-unstable-static: ship with complementary user script 2022-06-29 17:00:08 +02:00
zimbatm
bb3cbda9f3 nix-unstable-static: add run_as_user.sh script
Allow to run nix as a user.
2022-06-29 16:42:49 +02:00
zimbatm
d884d77087 nix-unstable-static: use bash interactive
Make it more useful
2022-06-29 16:34:15 +02:00
zimbatm
2d185d5f68 README: fix matrix 2022-06-27 17:23:38 +02:00
Jonas Chevalier
910b5937e5 Merge pull request #29 from teto/static
feat: added a nixStatic docker image
2022-06-27 17:13:39 +02:00
zimbatm
272875d0af feat: add nix-unstable-static docker image
This is a special docker images that contains no /nix/store. And only
static binaries in /bin.

The main use-case is to be able to bind-mount /nix from the host
into the container.
2022-06-27 17:05:13 +02:00
zimbatm
cb688a90e3 nix-shell: set the NIX_PATH
Use the same version of nixpkgs as the shell itself
2022-06-27 16:56:21 +02:00
zimbatm
16fb0b4147 nix-shell: add dive to inspect images 2022-06-27 16:56:21 +02:00
silverraven691
9bf2f6be8c Build images for channel nixos-22.05 (#44)
+  Stop building images for nixos-20.09
2022-06-15 17:17:06 +02:00
Jörg Thalheim
db78dafed2 Merge pull request #40 from nix-community/dependabot/github_actions/cachix/install-nix-action-17
build(deps): bump cachix/install-nix-action from 16 to 17
2022-04-11 08:05:21 +01:00
dependabot[bot]
b241190f21 build(deps): bump cachix/install-nix-action from 16 to 17
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 16 to 17.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v16...v17)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 04:04:06 +00:00
Jörg Thalheim
41c61425af Merge pull request #38 from nix-community/dependabot/github_actions/actions/checkout-3
build(deps): bump actions/checkout from 2 to 3
2022-03-07 10:02:53 +00:00
dependabot[bot]
5197be998f build(deps): bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 04:04:47 +00:00
V7
c52fdf233b feat: Allow Nix to accept nixConfig by default (#37)
This is useful when Nix (with Flakes enabled) is used with Continuous Integration in order to perform actions on a project having `nixConfig` defined in `flake.nix`
2022-01-14 20:26:04 +01:00
zimbatm
d0ece3e2a4 remove couchepotato
Upstream is dead and it has been removed from nixpkgs
2022-01-04 13:28:04 +01:00
Jonas Chevalier
98182ffc0e Merge pull request #36 from maydayv7/patch-1
fix: Enable Nix `experimental-features` in `cachix-flakes` image
2022-01-02 14:45:45 +01:00
maydayv7
32575d2810 fix(cachix-flakes): Enable Nix experimental-features 2021-12-27 16:17:50 +05:30
maydayv7
c51f4417ec fix(nix-flakes): Make extraContents extensible 2021-12-27 16:17:35 +05:30
Jörg Thalheim
88948a0a52 Merge pull request #35 from silverraven691/nixos-21.11
Build images for channel nixos-21.11
2021-12-02 14:46:48 +00:00
silverraven691
7cbf8629aa Build images for channel nixos-21.11
+ Stop building images for 20.03
2021-12-01 19:33:54 +01:00
Jörg Thalheim
f6c1358e7a Merge pull request #32 from nix-community/dependabot/github_actions/cachix/install-nix-action-16
build(deps): bump cachix/install-nix-action from 15 to 16
2021-11-22 07:01:36 +00:00
dependabot[bot]
60ff14dcb9 build(deps): bump cachix/install-nix-action from 15 to 16
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 15 to 16.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v15...v16)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-22 04:03:35 +00:00
Jörg Thalheim
47df79ab4c Merge pull request #31 from nix-community/dependabot/github_actions/cachix/install-nix-action-15
build(deps): bump cachix/install-nix-action from 14 to 15
2021-11-16 10:49:08 +00:00
dependabot[bot]
8049de273c build(deps): bump cachix/install-nix-action from 14 to 15
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 14 to 15.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v14...v15)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 04:03:06 +00:00
Jörg Thalheim
df7f64139a Merge pull request #25 from nix-community/dependabot/github_actions/cachix/install-nix-action-14
build(deps): bump cachix/install-nix-action from 13 to 14
2021-09-13 10:25:11 +01:00
dependabot[bot]
8b9e69d0dd build(deps): bump cachix/install-nix-action from 13 to 14
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 13 to 14.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v13...v14)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 04:03:33 +00:00
zimbatm
6bdf1707ae fixup! Build images for channel nixos-21.05 (#23) 2021-09-06 22:03:53 +02:00
silverraven691
ab7efb366f Build images for channel nixos-21.05 (#23)
* Gitlab CI: Build images for channel nixos-21.05

* GH Actions: Build images for channel nixos-21.05
2021-09-06 19:56:38 +00:00
Jonas Chevalier
50b4d08da7 use scarf to serve the images (#21)
This allows us to easily switch between container registries while
keeping the same domain prefix. It also gives access to high-level
statistics on the docker pull which can be useful to find out which
images are being used or not.
2021-04-21 18:05:42 +02:00
bion howard
debbce2425 fix typo (#20) 2021-04-15 19:27:07 +00:00
dependabot[bot]
71354ffd74 build(deps): bump cachix/install-nix-action from v12 to v13 (#19)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from v12 to v13.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v12...8d6d5e949675fbadb765c6b1a975047fa5f09b27)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-05 16:06:30 +02:00
zimbatm
0929c8c531 ci: build as much as possible
By default GitHub Actions cancels all the jobs in the build matrix if
any one of them fails. We actually want to keep going to get some
advancement on the other channels.
2021-03-08 17:41:14 +01:00
zimbatm
887722a603 nix-flakes: enable flakes in the config
Fixes #18
2021-03-08 12:18:43 +01:00
zimbatm
e850799428 nixpkgs-fmt 2021-03-08 12:17:56 +01:00
zimbatm
70854a5310 README: add nixos-20.09 and fixes 2021-02-10 14:23:23 +01:00
zimbatm
4d4b61e919 docker-login: remove \n from token 2021-02-10 14:13:13 +01:00
zimbatm
d36bde09e3 skopeo: use insecure-policy
Not sure what this is about, but it prevents me from pushing.
2021-02-10 14:06:24 +01:00
zimbatm
0d649be976 fix docker-login when ~/.docker exists 2021-02-10 13:50:31 +01:00
Jonas Chevalier
bf1338907c ci: add GitHub Actions cron (#16)
* ci: add dependabot

* ci: revamp logic

Merge username and password as a single auth token. It doesn't make
sense to split out the user and password since they are so tied
together. Might as well treat the whole think as a secret blob.

Remove Travis-CI. Travis is dead for OSS.

Add GitHub Actions cron. Remove cachix as it's pushing too much stuff.

Merge all of the CI logic into a single ci.sh script.
2021-02-10 13:25:01 +01:00
zimbatm
86f98e734f ci: add github-actions 2021-02-10 11:50:46 +01:00
zimbatm
7d21997381 Revert "Adding gnugrep to cachix (#14)"
This reverts commit 415031b849.

It wasn't really needed actually.
2021-02-10 10:36:16 +01:00
Andika Demas Riyandi
415031b849 Adding gnugrep to cachix (#14)
I have seen in `install-cachix-actions` that you use gnugrep. While we cannot do `nix-env -iA nixpkgs.gnugrep` inside the image, I prefer to put gnugrep by default in `cachix` image.
2021-02-10 09:24:37 +01:00
Raphael Das Gupta
f01e5ddc49 README.md: merge the 2 "Related projects" sections (#13) 2021-02-07 21:39:49 +00:00
zimbatm
dacde3f71f mkUserEnvironment: fix Nix compatibility issue
it was relying on a file that is not available in Nix unstable anymore
2020-11-27 15:44:39 +01:00
zimbatm
d454de5f07 ci: add nixos-20.09 2020-11-27 15:32:49 +01:00
zimbatm
a720d8ee4f remove 19.03 and 19.09 channels
Those are not receiving any more updates. Fix Nix invocations.
2020-07-07 13:00:21 +02:00
zimbatm
061bb32ed2 add cachix-flakes image 2020-07-07 12:09:39 +02:00
zimbatm
9519ca2731 fake_nixpkgs: add link to doc 2020-06-29 14:54:59 +02:00
zimbatm
0b362172fb nix: introduce fake nixpkgs (#9)
Since <nixpkgs> wasn't working, might as well make the error more
explicit. That way, users are quickly aware if they forgot to pin their
nixpkgs.
2020-06-17 20:49:42 +00:00
Badi Abdul-Wahid
0f24a9c94a images/nix: make sure /root exists
some external uses of the final image (eg drone) assume that $HOME
exists and attempt to write to it.
2020-06-14 12:53:50 +02:00
Badi Abdul-Wahid
9f6b62f45b images/nix: initialize env for bash
Prior the shell was not sourcing `/etc/profile.d/nix.sh` because,
although ENV is set, it will only be used if bash is invoked in
posix mode (either as `sh` or with `--posix`).
2020-06-14 12:53:29 +02:00
zimbatm
53440b208e nix: add USER environment variable
This is required by the nix profile and cachix as well
2020-02-23 20:10:52 +01:00
zimbatm
669e1a3129 nix: fix /tmp permissions
The /tmp folder was missing the sticky bit
2020-02-23 20:10:16 +01:00
zimbatm
8ceae9d833 fixup! nix: openssh is a runtime dependency of git 2020-02-23 17:20:47 +01:00
zimbatm
db90bcb3e9 nix: openssh is a runtime dependency of git 2020-02-23 17:14:57 +01:00
zimbatm
cca23be027 hugo: add git as a dependency
Hugo needs Git to find meta informations such as the pubDate
2020-02-23 17:03:28 +01:00
zimbatm
889fb542e6 cachix: fix build on 19.09 and under 2020-02-23 16:21:08 +01:00
zimbatm
3d793011e6 cachix: fix the description 2020-02-23 15:12:47 +01:00
zimbatm
3c956bc24c add the nixos-20.03 channel 2020-02-23 15:09:15 +01:00
zimbatm
ab443863a5 add cachix 2020-02-23 14:58:30 +01:00
zimbatm
777ae73ea1 add hugo 2020-02-23 14:54:32 +01:00
zimbatm
6597ff1349 ci: fix Travis CI builds
* run the ./build after setting the NIX_PATH. Previously the images
  were always generate with the system channel. Oops!
* pin the outer shell version to nixos-19.09. skopeo broke in unstable.
  also we don't need to force the system here, technically this could
  run on macOS.
2020-02-09 16:23:27 +01:00
zimbatm
e58ed5052b nix: add NIX_BUILD_SHELL
This is useful to avoid having nix-shell evaluate nixpkgs twice.
2020-02-07 21:35:56 +01:00
zimbatm
1305bc0290 add nix-flakes 2020-02-07 21:34:30 +01:00
zimbatm
b749d9b211 add caddy 2020-01-27 15:18:32 +01:00
zimbatm
5fc2cb9960 devcontainer: add a proper pager
The image is already quite big, why not add a proper pager?
2019-12-25 16:46:16 +01:00
zimbatm
4eefbd763a devcontainer: sedutil -> gnused
might as well use GNU tools like on other Linux distros
2019-12-24 14:26:45 +01:00
zimbatm
91703f92f2 devcontainer: -direnv, +procps
it wasn't such a good idea to add direnv by default
2019-12-24 14:15:21 +01:00
zimbatm
7fc8ed492e README: add nixery as a related project 2019-12-23 18:19:17 +01:00
zimbatm
cc193359bb devcontainer: add /home folder
useradd breaks if /home doesn't exist
2019-12-21 09:07:30 +01:00
zimbatm
3f1e51533a devcontainer: add grep and direnv 2019-12-20 22:07:10 +01:00
zimbatm
ddd995d1fd devcontainer: remove sudo
sudo is not needed in the end
2019-12-20 20:09:02 +01:00
zimbatm
5e724edccd devcontainer: use the right channel informations
<nixpkgs> is already resolved from channel:nixos-19.09 to a store path
as nix evaluation time.
2019-12-20 18:38:07 +01:00
zimbatm
7ed6a50917 ci: add the NIXPKGS_CHANNEL shortcut 2019-12-20 17:16:21 +01:00
zimbatm
9f61ec7d27 mkUserEnvironment: polyfill for older versions of nix 2019-12-20 15:43:07 +01:00
zimbatm
8014dcc5af devcontainer: vscode depends on sed 2019-12-20 12:39:59 +01:00
zimbatm
751d7a6714 devcontainer: init 2019-12-20 12:28:21 +01:00
zimbatm
f90912f967 release.nix -> default.nix
the default should be to build all the images
2019-12-17 23:35:43 +01:00
zimbatm
987c5c9460 travis: publish nixos-19.09
Fixes #6
2019-12-16 11:36:31 +01:00
zimbatm
18d25bb382 push-all: move verbose output
To help debug #6
2019-12-16 11:03:23 +01:00
zimbatm
c45c53b8c4 nix: select current nixpkgs version
a nixos-18.09 image should default to the same nixpkgs version
2019-12-15 15:57:42 +01:00
zimbatm
949ac55e09 stop accepting nixpkgs as an argument
set the NIX_PATH to select the version of nixpkgs to use
2019-12-15 15:57:40 +01:00
zimbatm
39694ed1d8 nixpkgs-fmt 2019-12-15 15:20:42 +01:00
zimbatm
77f9b50c78 nix: smaller closure
Thanks to https://gist.github.com/tomberek/53a1f50def192cc924672eddda3719c7#file-docker-helper-nix-L146-L151
2019-12-15 15:16:21 +01:00
zimbatm
1fa23404ff update to nixos-19.09 2019-11-21 13:14:01 +00:00
zimbatm
b9d1e3ad19 couchpotato: new package 2019-06-25 13:44:15 +02:00
zimbatm
3dfddf91b7 README: misc fixes 2019-03-16 15:48:28 +01:00
zimbatm
d8642dcc66 README: add microbadger links 2019-03-16 15:45:32 +01:00
zimbatm
00e19c8779 add nginx for fun 2019-03-16 15:41:12 +01:00
zimbatm
aa62d8a2a6 README: fix duplicated image table 2019-03-16 15:35:10 +01:00
zimbatm
e72af62aa2 Merge pull request #2 from nix-community/import-dir
Import dir
2019-03-16 14:01:15 +00:00
44 changed files with 868 additions and 227 deletions

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

29
.github/workflows/nix.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Nix
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
schedule:
# Run once per day
- cron: '0 0 * * *'
jobs:
build:
strategy:
# Keep building the other channels if one fails
fail-fast: false
matrix:
channel:
- nixos-unstable
- nixos-22.11
- nixos-23.05
runs-on: native
container: pjjw/nix-flake-runner:1
steps:
- uses: actions/checkout@v3
- run: nix-shell --run ./ci.sh
env:
CI_PROJECT_PATH: pjjw
CI_REGISTRY_AUTH: '${{ secrets.REGISTRY_AUTH }}'
NIXPKGS_CHANNEL: '${{ matrix.channel }}'

View File

@@ -1,26 +0,0 @@
#!/usr/bin/env bash
#
# Gitlab CI specific build script.
#
set -euo pipefail
./build
# default to the Gitlab registry
: "${REGISTRY:=$CI_REGISTRY}"
: "${REGISTRY_USER:=$CI_REGISTRY_USER}"
: "${REGISTRY_PASSWORD:=$CI_REGISTRY_PASSWORD}"
: "${IMAGE_PREFIX:=$CI_PROJECT_PATH}"
# IMAGE_TAG is provided by .gitlab-ci.yml
if [[ "$CI_COMMIT_REF_NAME" = master ]]; then
./docker-login "$REGISTRY_USER" "$REGISTRY_PASSWORD" "$REGISTRY"
./push-all "$REGISTRY" "$IMAGE_PREFIX" "$IMAGE_TAG"
if [[ $REGISTRY = *docker.io ]]; then
./dockerhub-metadata "$REGISTRY_USER" "$REGISTRY_PASSWORD" "$IMAGE_PREFIX"
fi
else
echo "=== not pushing on non-master ==="
fi

View File

@@ -1,25 +1,14 @@
image: nixos/nix:latest
stages:
- build
nixos-unstable:
build:
stage: build
script: nix-shell --run ./.gitlab-ci.sh
variables:
NIX_PATH: nixpkgs=channel:nixos-unstable
IMAGE_TAG: latest
nixos-18.09:
stage: build
script: nix-shell --run ./.gitlab-ci.sh
variables:
NIX_PATH: nixpkgs=channel:nixos-18.09
IMAGE_TAG: nixos-18.09
nixos-19.03:
stage: build
script: nix-shell --run ./.gitlab-ci.sh
variables:
NIX_PATH: nixpkgs=channel:nixos-19.03
IMAGE_TAG: nixos-19.03
image: nixpkgs/nix:nixos-22.11
script: nix-shell --run ./ci.sh
parallel:
matrix:
- NIXPKGS_CHANNEL: nixos-unstable
IMAGE_TAG: latest
- NIXPKGS_CHANNEL:
- nixos-22.11
- nixos-23.05

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
#
# Travis CI specific build script
#
set -euo pipefail
./build
# default to Docker Hub
: "${REGISTRY:=docker.io}"
: "${IMAGE_PREFIX:=nixpkgs}"
# IMAGE_TAG is provided by .travis.yml
# the user has to set REGISTRY_USER and REGISTRY_PASSWORD
if [[ "$TRAVIS_BRANCH" = master && -z "$TRAVIS_PULL_REQUEST_BRANCH" ]]; then
./docker-login "$REGISTRY_USER" "$REGISTRY_PASSWORD" "$REGISTRY"
./push-all "$REGISTRY" "$IMAGE_PREFIX" "$IMAGE_TAG"
if [[ $REGISTRY = *docker.io ]]; then
./dockerhub-metadata "$REGISTRY_USER" "$REGISTRY_PASSWORD" "$IMAGE_PREFIX"
fi
else
echo "=== not pushing on non-master ==="
fi

View File

@@ -1,15 +0,0 @@
language: nix
nix: 2.2.1
matrix:
include:
- name: nixos-unstable
env: NIX_PATH=nixpkgs=channel:nixos-unstable IMAGE_TAG=latest
- name: nixos-18.09
env: NIX_PATH=nixpkgs=channel:nixos-18.09 IMAGE_TAG=nixos-18.09
- name: nixos-19.03
env: NIX_PATH=nixpkgs=channel:nixos-19.03 IMAGE_TAG=nixos-19.03
script:
- nix-shell --run ./.travis.sh

View File

@@ -29,22 +29,6 @@ $ docker run -ti --rm nixpkgs/curl curl http://ifconfig.co
180.52.248.114
```
## List of images
Here is the current list of images that are provided. Missing one? Send an
[image request](#image-request).
| Image | Description |
| --- | --- |
| bash | CLI only |
| busybox | CLI only |
| curl | CLI only |
| docker-compose | CLI only |
| kubectl | CLI only |
| kubernetes-helm | CLI only |
| nix | nix with deps |
| nix-unstable | nixUnstable with deps |
## Channels
Each image is built with the following nixpkgs channels and map to the
@@ -55,54 +39,48 @@ nixpkgs channel describes.
| Channel | Image Tag | Description |
| --- | --- | --- |
| nixos-unstable | latest | latest and greated, major versions might change |
| nixos-18.09 | nixos-18.09 | only minor versions that include security updates |
| nixos-22.11 | nixos-22.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 |
## Docker Hub
## List of images
All images are automatically built and pushed to Docker Hub.
Here is the current list of images that are provided. Missing one? Send an
[image request](#image-request).
### Image matrix
All images are automatically built and published to Docker Hub, and served
on our custom domain, courtesy of [Scarf](https://scarf.sh).
`> ./dockerhub-image-matrix`
`> ./readme-image-matrix`
<!-- BEGIN mdsh -->
| Image / Tag | latest | nixos-18.09 | nixos-19.03 |
| --- | --- | --- | --- |
| [nixpkgs/bash](https://hub.docker.com/r/nixpkgs/bash) | ![](https://images.microbadger.com/badges/image/nixpkgs/bash.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/bash:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/bash:nixos-19.03.svg) |
| [nixpkgs/busybox](https://hub.docker.com/r/nixpkgs/busybox) | ![](https://images.microbadger.com/badges/image/nixpkgs/busybox.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/busybox:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/busybox:nixos-19.03.svg) |
| [nixpkgs/curl](https://hub.docker.com/r/nixpkgs/curl) | ![](https://images.microbadger.com/badges/image/nixpkgs/curl.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/curl:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/curl:nixos-19.03.svg) |
| [nixpkgs/docker-compose](https://hub.docker.com/r/nixpkgs/docker-compose) | ![](https://images.microbadger.com/badges/image/nixpkgs/docker-compose.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/docker-compose:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/docker-compose:nixos-19.03.svg) |
| [nixpkgs/kubectl](https://hub.docker.com/r/nixpkgs/kubectl) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubectl.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubectl:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubectl:nixos-19.03.svg) |
| [nixpkgs/kubernetes-helm](https://hub.docker.com/r/nixpkgs/kubernetes-helm) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubernetes-helm.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubernetes-helm:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubernetes-helm:nixos-19.03.svg) |
| [nixpkgs/nix](https://hub.docker.com/r/nixpkgs/nix) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix:nixos-19.03.svg) |
| [nixpkgs/nix-unstable](https://hub.docker.com/r/nixpkgs/nix-unstable) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix-unstable.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix-unstable:nixos-18.09.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix-unstable:nixos-19.03.svg) |
| Image / Tag | Pull |
| --- | --- |
| [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/cachix](https://hub.docker.com/r/nixpkgs/cachix)| `docker pull docker.nix-community.org/nixpkgs/cachix` |
| [nixpkgs/cachix-flakes](https://hub.docker.com/r/nixpkgs/cachix-flakes)| `docker pull docker.nix-community.org/nixpkgs/cachix-flakes` |
| [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/devcontainer](https://hub.docker.com/r/nixpkgs/devcontainer)| `docker pull docker.nix-community.org/nixpkgs/devcontainer` |
| [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/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/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-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-static](https://hub.docker.com/r/nixpkgs/nix-unstable-static)| `docker pull docker.nix-community.org/nixpkgs/nix-unstable-static` |
<!-- END mdsh -->
| Image / Tag | latest | nixos-18.09 |
| --- | --- | --- |
| [nixpkgs/bash](https://hub.docker.com/r/nixpkgs/bash) | ![](https://images.microbadger.com/badges/image/nixpkgs/bash.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/bash:nixos-18.09.svg) |
| [nixpkgs/busybox](https://hub.docker.com/r/nixpkgs/busybox) | ![](https://images.microbadger.com/badges/image/nixpkgs/busybox.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/busybox:nixos-18.09.svg) |
| [nixpkgs/curl](https://hub.docker.com/r/nixpkgs/curl) | ![](https://images.microbadger.com/badges/image/nixpkgs/curl.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/curl:nixos-18.09.svg) |
| [nixpkgs/docker-compose](https://hub.docker.com/r/nixpkgs/docker-compose) | ![](https://images.microbadger.com/badges/image/nixpkgs/docker-compose.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/docker-compose:nixos-18.09.svg) |
| [nixpkgs/kubectl](https://hub.docker.com/r/nixpkgs/kubectl) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubectl.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubectl:nixos-18.09.svg) |
| [nixpkgs/kubernetes-helm](https://hub.docker.com/r/nixpkgs/kubernetes-helm) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubernetes-helm.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/kubernetes-helm:nixos-18.09.svg) |
| [nixpkgs/nix](https://hub.docker.com/r/nixpkgs/nix) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix:nixos-18.09.svg) |
| [nixpkgs/nix-unstable](https://hub.docker.com/r/nixpkgs/nix-unstable) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix-unstable.svg) | ![](https://images.microbadger.com/badges/image/nixpkgs/nix-unstable:nixos-18.09.svg) |
## Adding new images
To add a new image to the project, create a new folder under
`./images/<image-name>` with a default.nix that returns the docker image.
Then run `nix-build release.nix -A <image-name>` to test that it builds, and
Then run `nix-build -A <image-name>` to test that it builds, and
then use
`docker load -i /nix/store/...<image-name>.tar.gz` to load and test the image.
## Related projects
The [docker-library](https://github.com/docker-library/official-images#readme)
is an image set maintained by the Docker Inc. team and contain
officially-supported images.
## User Feedback
### Issues
@@ -118,11 +96,20 @@ with an accompanying use-case for an image that you would like to see.
### Contributing
You are invited to contribute new features, fixes or updates, large or small;
we are always thrilled to receive pull requests, and do our brest ot process
we are always thrilled to receive pull requests, and do our best to process
them as fast as we can.
## Related projects
* The [docker-library](https://github.com/docker-library/official-images#readme)
is an image set maintained by the Docker Inc. team and contain
officially-supported images.
* [Nixery](https://nixery.dev/) is a pretty cool service that builds docker
images from nixpkgs attributes on the fly.
## License
Copyright (c) 2019 zimbatm and contributors.
Copyright (c) 2021 @zimbatm and contributors.
Licensed under the MIT.

8
build
View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# build *all* the docker images
exec nix-build release.nix \
--no-out-link \
--option sandbox true \
"$@"

50
ci.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/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")"
banner "Building images"
# Build all the docker images
nix-build \
--no-out-link \
--option sandbox true \
if [[ $(git rev-parse --abbrev-ref HEAD) != master ]]; then
banner "Skipping push on non-master branch"
exit
fi
if [[ -n "${registry_auth}" ]]; then
banner "docker login"
./docker-login "$registry_auth" "$registry"
fi
banner "docker push"
./push-all "$registry" "$image_prefix" "$image_tag"
if [[ -n "${registry_auth}" && $registry = *docker.io ]]; then
banner "docker metadata update"
./dockerhub-metadata "$registry_auth" "$image_prefix"
fi

View File

@@ -1,9 +1,4 @@
{ nixpkgs ? <nixpkgs> }:
import nixpkgs {
# docker images run on Linux
system = "x86_64-linux";
config = {};
overlays = [
(import ./overlay.nix)
];
}
let
pkgs = import ./pkgs.nix;
in
pkgs.docker-nixpkgs

View File

@@ -5,9 +5,8 @@
# Usage: ./docker-login <username> <password> [registry]
set -euo pipefail
username=$1
password=$2
registry=${3:-docker.io}
auth=$1
registry=${2:-docker.io}
# Encode some funky docker heuristic
if [[ $registry = *docker.io ]]; then
@@ -15,13 +14,13 @@ if [[ $registry = *docker.io ]]; then
registry=https://index.docker.io/v2/
fi
mkdir ~/.docker
mkdir -p ~/.docker
cat <<DOCKER_CONF > ~/.docker/config.json
{
"auths": {
"$registry": {
"auth": "$(printf "%s:%s" "$username" "$password" | base64)"
"auth": "$(echo -n "$auth" | base64)"
}
}
}

View File

@@ -1,30 +0,0 @@
#!/usr/bin/env bash
#
# Usage: ./dockerhub-image-matrix
set -euo pipefail
microbadge() {
local name=$1
local tag=${2:-latest}
if [[ $tag != latest ]]; then
name=$name:$tag
fi
# make sure that microbadger has loaded the image
curl -o /dev/null -sfL "https://microbadger.com/images/$name"
echo "![](https://images.microbadger.com/badges/image/$name.svg)"
}
## Main ##
releases_json=$(nix-instantiate ./release.nix --strict --eval --json)
echo "| Image / Tag | latest | nixos-18.09 | nixos-19.03 |"
echo "| --- | --- | --- | --- |"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
name=nixpkgs/$attr
echo "| [$name](https://hub.docker.com/r/$name) | $(microbadge "$name") | $(microbadge "$name" "nixos-18.09") | $(microbadge "$name" "nixos-19.03") |"
done

View File

@@ -6,16 +6,14 @@
# Usage: ./dockerhub-metadata <user> <password> [org]
set -euo pipefail
username=$1
password=$2
org=${3:-nixpkgs}
user=$username:$password
user=$1
org=${2:-nixpkgs}
nix_eval() {
nix-instantiate --strict --eval --json "$@"
}
releases_json=$(nix_eval release.nix)
releases_json=$(nix_eval)
to_json() {
local desc=$1 full_desc=$2
@@ -29,7 +27,7 @@ echo "=== Updating Docker Hub project descriptions"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
echo "--- $attr"
desc=$(nix_eval ./release.nix -A "$attr.meta.description" | jq -r .)
desc=$(nix_eval -A "$attr.meta.description" | jq -r .)
if [[ -f "$attr/README.md" ]]; then
full_desc=$(< "$attr/README.md")

View File

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

10
images/cachix/default.nix Normal file
View File

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

6
images/caddy/default.nix Normal file
View File

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

View File

@@ -0,0 +1,6 @@
# Nix VSCode DevContainer
WIP
Related to https://github.com/zimbatm/vscode-devcontainer-nix

View File

@@ -0,0 +1,139 @@
# A fat and modifiable Nix image
{ dockerTools
, bashInteractive
, cacert
, closureInfo
, coreutils
, curl
, direnv
, gcc-unwrapped
, gitReallyMinimal
, glibc
, gnugrep
, gnused
, gnutar
, gzip
, iana-etc
, iproute
, less
, lib
, nix
, openssh
, procps
, shadow
, xz
, mkUserEnvironment
}:
let
channel = builtins.getEnv ("NIXPKGS_CHANNEL");
# generate a user profile for the image
profile = mkUserEnvironment {
derivations = [
# core utils
coreutils
procps
gnugrep
gnused
less
# add /bin/sh
bashInteractive
nix
# runtime dependencies of nix
cacert
gitReallyMinimal
gnutar
gzip
xz
# for haskell binaries
iana-etc
# for user management
shadow
# for the vscode extension
# HACK: don't include the "libgcc" output. It has overlapping files with
# the "lib" output, and that breaks the build.
(gcc-unwrapped // {
outputs = builtins.filter (x: x != "libgcc") gcc-unwrapped.outputs;
})
iproute
];
};
image = dockerTools.buildImage {
name = "devcontainer";
contents = [ ];
extraCommands = ''
# create the Nix DB
export NIX_REMOTE=local?root=$PWD
export USER=nobody
${nix}/bin/nix-store --load-db < ${closureInfo { rootPaths = [ profile ]; }}/registration
# set the user profile
${profile}/bin/nix-env --profile nix/var/nix/profiles/default --set ${profile}
# minimal
mkdir -p bin usr/bin
ln -s /nix/var/nix/profiles/default/bin/sh bin/sh
ln -s /nix/var/nix/profiles/default/bin/env usr/bin/env
# might as well...
ln -s /nix/var/nix/profiles/default/bin/bash bin/bash
# setup shadow, bashrc
mkdir home
cp -r ${./root/etc} etc
chmod +w etc etc/group etc/passwd etc/shadow
# setup iana-etc for haskell binaries
ln -s /nix/var/nix/profiles/default/etc/protocols etc/protocols
ln -s /nix/var/nix/profiles/default/etc/services etc/services
# make sure /tmp exists
mkdir -m 0777 tmp
# allow ubuntu ELF binaries to run. VSCode copies it's own.
mkdir -p lib64
ln -s ${glibc}/lib64/ld-linux-x86-64.so.2 lib64/ld-linux-x86-64.so.2
# VSCode assumes that /sbin/ip exists
mkdir sbin
ln -s /nix/var/nix/profiles/default/bin/ip sbin/ip
'';
config = {
Cmd = [ "/nix/var/nix/profiles/default/bin/bash" ];
Env = [
"ENV=/nix/var/nix/profiles/default/etc/profile.d/nix.sh"
"GIT_SSL_CAINFO=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
"LD_LIBRARY_PATH=/nix/var/nix/profiles/default/lib"
"PAGER=less"
"PATH=/nix/var/nix/profiles/default/bin"
"SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
(
if channel != "" then
"NIX_PATH=nixpkgs=channel:${channel}"
else
"NIX_PATH=nixpkgs=${../nix/fake_nixpkgs}"
)
];
Labels = {
# https://github.com/microscaling/microscaling/blob/55a2d7b91ce7513e07f8b1fd91bbed8df59aed5a/Dockerfile#L22-L33
"org.label-schema.vcs-ref" = "master";
"org.label-schema.vcs-url" = "https://github.com/nix-community/docker-nixpkgs";
};
};
};
in
image // {
meta = image.meta // {
description = "Nix devcontainer for VSCode";
};
}

View File

@@ -0,0 +1,6 @@
# interactive session
if [[ $- == *i* ]]; then
PS1='\[\033[0;32;40m\][nix]$\[\033[0m\] '
fi

View File

@@ -0,0 +1,6 @@
root:x:0:
wheel:x:1:
tty:x:3:
users:x:100:
nixbld:x:30000:nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30
nogroup:x:65534:

View File

@@ -0,0 +1,11 @@
passwd: files mymachines systemd
group: files mymachines systemd
shadow: files
hosts: files mymachines dns myhostname
networks: files
ethers: files
services: files
protocols: files
rpc: files

View File

@@ -0,0 +1,4 @@
account sufficient pam_unix.so
auth sufficient pam_rootok.so
password requisite pam_unix.so nullok sha512
session required pam_unix.so

View File

@@ -0,0 +1,32 @@
root:x:0:0:root:/root:/nix/var/nix/profiles/default/bin/bash
nixbld1:x:30001:30000:Nix build user 1:/var/empty:/sbin/nologin
nixbld2:x:30002:30000:Nix build user 2:/var/empty:/sbin/nologin
nixbld3:x:30003:30000:Nix build user 3:/var/empty:/sbin/nologin
nixbld4:x:30004:30000:Nix build user 4:/var/empty:/sbin/nologin
nixbld5:x:30005:30000:Nix build user 5:/var/empty:/sbin/nologin
nixbld6:x:30006:30000:Nix build user 6:/var/empty:/sbin/nologin
nixbld7:x:30007:30000:Nix build user 7:/var/empty:/sbin/nologin
nixbld8:x:30008:30000:Nix build user 8:/var/empty:/sbin/nologin
nixbld9:x:30009:30000:Nix build user 9:/var/empty:/sbin/nologin
nixbld10:x:30010:30000:Nix build user 10:/var/empty:/sbin/nologin
nixbld11:x:30011:30000:Nix build user 11:/var/empty:/sbin/nologin
nixbld12:x:30012:30000:Nix build user 12:/var/empty:/sbin/nologin
nixbld13:x:30013:30000:Nix build user 13:/var/empty:/sbin/nologin
nixbld14:x:30014:30000:Nix build user 14:/var/empty:/sbin/nologin
nixbld15:x:30015:30000:Nix build user 15:/var/empty:/sbin/nologin
nixbld16:x:30016:30000:Nix build user 16:/var/empty:/sbin/nologin
nixbld17:x:30017:30000:Nix build user 17:/var/empty:/sbin/nologin
nixbld18:x:30018:30000:Nix build user 18:/var/empty:/sbin/nologin
nixbld19:x:30019:30000:Nix build user 19:/var/empty:/sbin/nologin
nixbld20:x:30020:30000:Nix build user 20:/var/empty:/sbin/nologin
nixbld21:x:30021:30000:Nix build user 21:/var/empty:/sbin/nologin
nixbld22:x:30022:30000:Nix build user 22:/var/empty:/sbin/nologin
nixbld23:x:30023:30000:Nix build user 23:/var/empty:/sbin/nologin
nixbld24:x:30024:30000:Nix build user 24:/var/empty:/sbin/nologin
nixbld25:x:30025:30000:Nix build user 25:/var/empty:/sbin/nologin
nixbld26:x:30026:30000:Nix build user 26:/var/empty:/sbin/nologin
nixbld27:x:30027:30000:Nix build user 27:/var/empty:/sbin/nologin
nixbld28:x:30028:30000:Nix build user 28:/var/empty:/sbin/nologin
nixbld29:x:30029:30000:Nix build user 29:/var/empty:/sbin/nologin
nixbld30:x:30030:30000:Nix build user 30:/var/empty:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin

View File

@@ -0,0 +1,32 @@
root:!::0:::::
nixbld1:!:18237:0:99999:7:::
nixbld2:!:18237:0:99999:7:::
nixbld3:!:18237:0:99999:7:::
nixbld4:!:18237:0:99999:7:::
nixbld5:!:18237:0:99999:7:::
nixbld6:!:18237:0:99999:7:::
nixbld7:!:18237:0:99999:7:::
nixbld8:!:18237:0:99999:7:::
nixbld9:!:18237:0:99999:7:::
nixbld10:!:18237:0:99999:7:::
nixbld11:!:18237:0:99999:7:::
nixbld12:!:18237:0:99999:7:::
nixbld13:!:18237:0:99999:7:::
nixbld14:!:18237:0:99999:7:::
nixbld15:!:18237:0:99999:7:::
nixbld16:!:18237:0:99999:7:::
nixbld17:!:18237:0:99999:7:::
nixbld18:!:18237:0:99999:7:::
nixbld19:!:18237:0:99999:7:::
nixbld20:!:18237:0:99999:7:::
nixbld21:!:18237:0:99999:7:::
nixbld22:!:18237:0:99999:7:::
nixbld23:!:18237:0:99999:7:::
nixbld24:!:18237:0:99999:7:::
nixbld25:!:18237:0:99999:7:::
nixbld26:!:18237:0:99999:7:::
nixbld27:!:18237:0:99999:7:::
nixbld28:!:18237:0:99999:7:::
nixbld29:!:18237:0:99999:7:::
nixbld30:!:18237:0:99999:7:::
nobody:!::0:::::

View File

@@ -7,5 +7,5 @@ buildCLIImage {
if docker-compose == null
then python3Packages.docker_compose
else docker-compose # nixos 19.03+
;
;
}

8
images/hugo/default.nix Normal file
View File

@@ -0,0 +1,8 @@
{ buildCLIImage
, hugo
, gitReallyMinimal
}:
buildCLIImage {
drv = hugo;
extraContents = [ gitReallyMinimal ];
}

6
images/nginx/default.nix Normal file
View File

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

View File

@@ -0,0 +1,10 @@
{ docker-nixpkgs
, nodejs
, extraContents ? [ ]
}:
docker-nixpkgs.nix-flakes.override {
extraContents = [
# nodejs for runner
nodejs
] ++ extraContents;
}

View File

@@ -0,0 +1,18 @@
{ docker-nixpkgs
, nixFlakes
, writeTextFile
, extraContents ? [ ]
}:
docker-nixpkgs.nix.override {
nix = nixFlakes;
extraContents = [
(writeTextFile {
name = "nix.conf";
destination = "/etc/nix/nix.conf";
text = ''
accept-flake-config = true
experimental-features = nix-command flakes
'';
})
] ++ extraContents;
}

View File

@@ -0,0 +1,16 @@
# nix-unstable-static
This is a special variant of the nix image that contains no `/nix/store`.
Instead, nix and all the supporting binaries are statically built and copied
into /bin.
The main use-case is to be able to run nix in the container, but share the
`/nix/store` with the host.
## Using the container with the host store
This folder ships with a complementary script that you can use to run the
image as the current user and the host /nix/store.
Usage: `docker-nix-user.sh [<command> ...<args>]`

View File

@@ -0,0 +1,131 @@
{ dockerTools
, lib
, fetchurl
, findutils
, pkgsStatic
, python3
, removeReferencesTo
, runCommand
}:
let
inherit (pkgsStatic)
bashInteractive
busybox
cacert
openssl
;
bash = bashInteractive;
# Get nix from Hydra because the nixpkgs one is not fully static
nixStaticBin = fetchurl {
url = "https://hydra.nixos.org/build/181573550/download/1/nix";
hash = "sha256-zO2xJhQIrLtL/ReTlcorjwsaTO1W5Rnr+sXwcLcujok=";
};
nixSymlinks = [
"nix-build"
"nix-channel"
"nix-collect-garbage"
"nix-copy-closure"
"nix-daemon"
"nix-env"
"nix-hash"
"nix-instantiate"
"nix-prefetch-url"
"nix-shell"
"nix-store"
];
dirs = [
"bin"
"etc/ssl/certs"
"root"
"tmp"
"usr"
];
extraCommands = ''
rm_ref() {
${removeReferencesTo}/bin/remove-references-to "$@"
}
# Create a FHS-like file structure
cp -r ${../nix/root}/* .
chmod +w etc
mkdir -p ${toString dirs}
# For /usr/bin/env
ln -s ../bin usr/bin
# Make sure /tmp has the right permissions
chmod 1777 tmp
# Add user home folder
mkdir home
# Add SSL CA certs
cp -a "${cacert}/etc/ssl/certs/ca-bundle.crt" etc/ssl/certs/ca-bundle.crt
# Install base binaries
cp -a ${busybox}/bin/* bin/
rm_ref -t ${busybox} bin/busybox
# Install shell
cp -a ${bash}/bin/bash bin/
rm_ref -t ${bash} bin/bash
# Install nix
cp -a ${nixStaticBin} bin/nix
chmod +x bin/nix
for sym in ${toString nixSymlinks}; do
ln -sv /bin/nix bin/$sym
done
mkdir -p libexec/nix
ln -s /bin/nix libexec/nix/build-remote
# Enable flakes
mkdir -p etc/nix
cat <<NIX_CONFIG > etc/nix/nix.conf
accept-flake-config = true
experimental-features = nix-command flakes
NIX_CONFIG
# Add run-as-user script
cp -a ${./run_as_user.sh} run_as_user.sh
'';
# To debug
unpacked = runCommand
"unpacked"
{ buildInputs = [ python3 ]; }
''
mkdir layer
pushd layer
${extraCommands}
popd
mv layer $out
'';
image = dockerTools.buildImage {
name = "nix-static";
inherit extraCommands;
config = {
Cmd = [ "/bin/bash" ];
Env = [
"NIX_BUILD_SHELL=/bin/bash"
"PAGER=cat"
"PATH=/bin"
"SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt"
];
};
};
in
image // {
passthru = image.passthru // { inherit unpacked; };
meta = image.meta // {
description = "Nix but statically built";
};
}

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# Run nixpkgs/nix-unstable-static as the current user and the host /nix/store.
#
# Usage: docker-nix-user.sh [<command> ...<args>]
#
set -euo pipefail
image=nixpkgs/nix-unstable-static
options=(
-ti
# Remove the container on exit
--rm
-e NIX_PATH="nixpkgs=channel:nixos-22.05"
# Used by /run_as_user.sh
-e user_id="$(id -u)"
-e user_name="$(id -nu)"
-e group_id="$(id -g)"
-e group_name="$(id -ng)"
# Use the host store
-v /nix:/nix
# Mount the code into the container
-v "$PWD:/workspace"
-w /workspace
--entrypoint /run_as_user.sh
)
exec docker run "${options[@]}" "$image" "$@"

View File

@@ -0,0 +1,29 @@
#!/bin/sh -eu
#
# This script can be used as an entrypoint. It's used to synchronize and run
# the container with the same user and group as the host user.
#
# Usage:
# user_id=$(id -u) user_name=$(id -un) \
# group_id=$(id -g) group_name=$(id -gn) \
# ./run_as_user.sh [<command> ...<args>]
#
# shellcheck disable=SC2154
# Install the host user and group into the container
delgroup "${group_name}" 2>/dev/null || true
deluser "${user_name}" 2>/dev/null || true
addgroup -g "${group_id}" "${group_name}"
adduser -D -G "${group_name}" -u "${user_id}" "${user_name}"
# Don't propagate those env vars
user=${user_name}
unset user_id user_name group_id group_name
# Change into the user
if [ $# = 0 ]; then
exec su "${user}"
else
exec su "${user}" -c /bin/sh /bin/sh -c "exec \"\$@\"" "$@"
fi

View File

@@ -1,14 +1,16 @@
{ dockerTools
, bash
, bashInteractive
, cacert
, coreutils
, curl
, gitMinimal
, gitReallyMinimal
, gnutar
, gzip
, iana-etc
, nix
, openssh
, xz
, extraContents ? [ ]
}:
let
image = dockerTools.buildImageWithNixDb {
@@ -18,19 +20,20 @@ let
./root
coreutils
# add /bin/sh
bash
bashInteractive
nix
# runtime dependencies of nix
cacert
gitMinimal
gitReallyMinimal
gnutar
gzip
openssh
xz
# for haskell binaries
iana-etc
];
] ++ extraContents;
extraCommands = ''
# for /usr/bin/env
@@ -38,19 +41,25 @@ let
ln -s ../bin usr/bin
# make sure /tmp exists
mkdir -m 0777 tmp
mkdir -m 1777 tmp
# need a HOME
mkdir -vp root
'';
config = {
Cmd = [ "/bin/bash" ];
Env = [
"ENV=/etc/profile.d/nix.sh"
"NIX_PATH=nixpkgs=channel:nixpkgs-unstable"
"BASH_ENV=/etc/profile.d/nix.sh"
"NIX_BUILD_SHELL=/bin/bash"
"NIX_PATH=nixpkgs=${./fake_nixpkgs}"
"PAGER=cat"
"PATH=/usr/bin:/bin"
"SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt"
"USER=root"
];
};
};
in
image // { meta = nix.meta // image.meta; }
image // { meta = nix.meta // image.meta; }

View File

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

View File

@@ -3,8 +3,9 @@
, cacert
}:
{ drv # derivation to build the image for
# Name of the binary to run by default
# Name of the binary to run by default
, binName ? (builtins.parseDrvName drv.name).name
, extraContents ? [ ]
, meta ? drv.meta
}:
let
@@ -17,7 +18,7 @@ let
# most program need TLS certs
cacert
drv
];
] ++ extraContents;
config = {
Cmd = [ "/bin/${binName}" ];
@@ -33,4 +34,4 @@ let
};
};
in
image // { meta = meta // image.meta; }
image // { meta = meta // image.meta; }

View File

@@ -4,9 +4,11 @@ importFn: baseDir:
let
dirEntries =
builtins.attrNames
(lib.filterAttrs
(k: v: v == "directory")
(builtins.readDir baseDir));
(
lib.filterAttrs
(k: v: v == "directory")
(builtins.readDir baseDir)
);
absDirs =
builtins.map
@@ -18,4 +20,4 @@ let
(dir: { name = builtins.baseNameOf dir; value = importFn dir; })
absDirs;
in
builtins.listToAttrs imports
builtins.listToAttrs imports

111
lib/mkUserEnvironment.nix Normal file
View File

@@ -0,0 +1,111 @@
{ writeText, lib }:
# Build a user environment purely with nix.
#
# The original implementation is a mix of C++ and nix code.
#
# See https://github.com/nixos/nix/blob/f4b94958543138671bc3641fc126589a5cffb24b/src/nix-env/user-env.cc
#
# TODO:
# * also add the drvPath if the keepDerivations nix settings is set
# * support "disabled" mode that breaks nix-env?
# * remove the use of writeText. builtins.toFile forbits the use of references
# to derivations, which makes it impossible to create exactly the same
# manifest file as `nix-env`.
#
# Arguments:
# * derivations: a list of derivations
{
# A list of derivations to install
derivations
}:
# Supporting code
with builtins;
let
# Copied from https://github.com/nixos/nix/blob/e02481ded216ffb5b06b413e3695d4e11e62e02f/corepkgs/buildenv.nix
#
# This was available at <nix/buildenv.nix>, until it got removed in Nix.
buildenv = { derivations, manifest }:
derivation {
name = "user-environment";
system = "builtin";
builder = "builtin:buildenv";
inherit manifest;
# !!! grmbl, need structured data for passing this in a clean way.
derivations =
map
(d:
[
(d.meta.active or "true")
(d.meta.priority or 5)
(builtins.length d.outputs)
] ++ map (output: builtins.getAttr output d) d.outputs)
derivations;
# Building user environments remotely just causes huge amounts of
# network traffic, so don't do that.
preferLocalBuild = true;
# Also don't bother substituting.
allowSubstitutes = false;
};
# back-compat
isPath = builtins.isPath or (x: builtins.typeOf x == "path");
# Escape Nix strings
stringEscape = str:
"\"" + (
replaceStrings
[ "\\" "\"" "\n" "\r" "\t" ]
[ "\\\\" "\\" "\\n" "\\r" "\\t" ]
str
)
+ "\"";
# Like builtins.JSON but to output Nix code
toNix = value:
if isString value then stringEscape value
else if isInt value then toString value
else if isPath value then toString value
else if true == value then "true"
else if false == value then "false"
else if null == value then "null"
else if isAttrs value then
"{ " + concatStringsSep " " (lib.mapAttrsToList (k: v: "${k} = ${toNix v};") value) + " }"
else if isList value then
"[ ${ concatStringsSep " " (map toNix value) } ]"
else throw "type ${typeOf value} not supported";
# Generate a nix-env compatible manifest.nix file
genManifest = drv:
let
outputs =
drv.meta.outputsToInstall or
# install the first output
[ (head drv.outputs) ];
base = {
inherit (drv) meta name outPath system type;
out = { inherit (drv) outPath; };
inherit outputs;
};
toOut = name: {
outPath = drv.${name}.outPath;
};
outs = lib.genAttrs outputs toOut;
in
base // outs;
writeManifest = derivations:
writeText "env-manifest.nix" (
toNix (map genManifest derivations)
);
in
buildenv {
inherit derivations;
manifest = writeManifest derivations;
}

View File

@@ -1,11 +1,32 @@
_: pkgs: let
_: pkgs:
let
importDir = import ./lib/importDir.nix {
inherit (pkgs) lib;
inherit (pkgs) lib;
};
in {
in
{
# builder stuff can be in the top-level
buildCLIImage = pkgs.callPackage ./lib/buildCLIImage.nix {};
buildCLIImage = pkgs.callPackage ./lib/buildCLIImage.nix { };
# docker images must be lower-cased
docker-nixpkgs = importDir (path: pkgs.callPackage path {}) ./images;
docker-nixpkgs = importDir (path: pkgs.callPackage path { }) ./images;
# used to build nix-env compatible user environments
mkUserEnvironment = pkgs.callPackage ./lib/mkUserEnvironment.nix { };
# gitMinimal still ships with perl and python
gitReallyMinimal = (
pkgs.git.override {
perlSupport = false;
pythonSupport = false;
withManual = false;
withpcre2 = false;
}
).overrideAttrs (
_: {
# installCheck is broken when perl is disabled
doInstallCheck = false;
}
);
}

8
pkgs.nix Normal file
View File

@@ -0,0 +1,8 @@
import <nixpkgs> {
# docker images run on Linux
system = "x86_64-linux";
config = { };
overlays = [
(import ./overlay.nix)
];
}

View File

@@ -7,14 +7,16 @@ registry=${1:-docker.io}
image_prefix=${2:-nixpkgs}
image_tag=${3:-latest}
releases_json=$(nix-instantiate ./release.nix --strict --eval --json)
releases_json=$(nix-instantiate --strict --eval --json)
echo "=== Pushing images to $registry"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
file=$(echo "$releases_json" | jq -r ".\"$attr\"")
echo "--- $attr -> $file"
skopeo copy "docker-archive://$file" "docker://$registry/$image_prefix/$attr:$image_tag"
src=docker-archive://$file
dst=docker://$registry/$image_prefix/$attr:$image_tag
echo "--- attr=$attr src=$src dst=$dst"
skopeo copy --insecure-policy "$src" "$dst"
done
echo OK

18
readme-image-matrix Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# Usage: ./dockerhub-image-matrix
set -euo pipefail
## Main ##
releases_json=$(nix-instantiate --strict --eval --json)
echo "| Image / Tag | Pull |"
echo "| --- | --- |"
for attr in $(echo "$releases_json" | jq -r "keys[]") ; do
name=nixpkgs/$attr
echo -n "| [$name](https://hub.docker.com/r/$name)"
echo -n "| \`docker pull docker.nix-community.org/$name\` "
echo "|"
done

View File

@@ -1,4 +0,0 @@
let
pkgs = import ./. {};
in
pkgs.docker-nixpkgs

View File

@@ -1,7 +1,11 @@
{ nixpkgs ? <nixpkgs> }@args:
with import ./. args;
let
nixpkgs = builtins.fetchTarball "channel:nixos-22.05";
pkgs = import nixpkgs { config = { }; overlays = [ ]; };
in
with pkgs;
mkShell {
buildInputs = [
dive
jq
skopeo
] ++ lib.optional (pkgs ? mdsh) pkgs.mdsh;
@@ -9,5 +13,7 @@ mkShell {
shellHook = ''
# try to work aroud build issues
unset TMPDIR
export NIX_PATH=nixpkgs=${toString nixpkgs}
'';
}