All Projects → LnL7 → Nix Docker

LnL7 / Nix Docker

Licence: mit
Docker images for the Nix package manager

Labels

Projects that are alternatives of or similar to Nix Docker

Miso
🍜 A tasty Haskell front-end framework
Stars: ✭ 1,911 (+911.11%)
Mutual labels:  nix
Ihp
🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness
Stars: ✭ 2,746 (+1352.91%)
Mutual labels:  nix
Nixpkgs Channels
DEPRECATED! Use NixOS/nixpkgs repository instead.
Stars: ✭ 173 (-8.47%)
Mutual labels:  nix
Robotnix
Build Android (AOSP) using Nix
Stars: ✭ 149 (-21.16%)
Mutual labels:  nix
Nix Bitcoin
A collection of Nix packages and NixOS modules for easily installing full-featured Bitcoin nodes with an emphasis on security.
Stars: ✭ 154 (-18.52%)
Mutual labels:  nix
Deploy Rs
A simple multi-profile Nix-flake deploy tool.
Stars: ✭ 164 (-13.23%)
Mutual labels:  nix
Poetry2nix
Convert poetry projects to nix automagically [[email protected]]
Stars: ✭ 141 (-25.4%)
Mutual labels:  nix
Nixpkgs Wayland
Automated, pre-built packages for Wayland (sway/wlroots) tools for NixOS.
Stars: ✭ 178 (-5.82%)
Mutual labels:  nix
Home Manager
Manage a user environment using Nix [maintainer=@rycee]
Stars: ✭ 2,447 (+1194.71%)
Mutual labels:  nix
Musnix
Real-time audio in NixOS
Stars: ✭ 173 (-8.47%)
Mutual labels:  nix
Dotfiles
My dotfiles
Stars: ✭ 150 (-20.63%)
Mutual labels:  nix
Nix On Droid
Nix-enabled environment for your Android device.
Stars: ✭ 154 (-18.52%)
Mutual labels:  nix
Nixpkgs Fmt
Nix code formatter for nixpkgs [[email protected]]
Stars: ✭ 171 (-9.52%)
Mutual labels:  nix
Dotfiles
~ 🍭 ~
Stars: ✭ 147 (-22.22%)
Mutual labels:  nix
Legacy Old Hercules
Abandoned
Stars: ✭ 174 (-7.94%)
Mutual labels:  nix
Appvm
Nix-based app VMs
Stars: ✭ 146 (-22.75%)
Mutual labels:  nix
Vulnix
Vulnerability (CVE) scanner for Nix/NixOS.
Stars: ✭ 161 (-14.81%)
Mutual labels:  nix
Comma
Stars: ✭ 186 (-1.59%)
Mutual labels:  nix
Pypi2nix
Abandoned! Generate Nix expressions for Python packages
Stars: ✭ 178 (-5.82%)
Mutual labels:  nix
Nixos Mailserver
A complete and Simple Nixos Mailserver
Stars: ✭ 172 (-8.99%)
Mutual labels:  nix

nix-docker

Docker images for the Nix package manager

This repository contains nix expressions to build a minimal docker image for the nix package manager. The current official docker image for nix is based on alpine, this image that is build from scratch and looks a lot more like nixos.

  • nix, bash and coreutils are installed in a system profile that is linked to /run/current-system/sw, the only global paths are /bin/sh and /usr/bin/env

  • it's easy to build a new custom baseimage using a specific version of nixpkgs, this makes it a lot easier to create an image with a custom version of nix or nixpkgs.

  • the lnl7/nix:ssh image can be used to setup an image that can be used as a remote builder, this allows you to build expressions for x86_64-linux on other platforms (ex. building a new baseimage on a darwin machine)

Base Images

All the images are based on the latest baseimage, previous versions are available in my repository https://hub.docker.com/r/lnl7/nix/tags.

  • lnl7/nix:2020-09-11 (2.3.7)
  • lnl7/nix:2020-06-07 (2.3.6)
  • lnl7/nix:2020-03-07 (2.3.3)
  • lnl7/nix:2019-03-01 (2.2)
  • lnl7/nix:2018-09-21 (2.1.2)
  • lnl7/nix:2018-07-17 (2.0.4)
  • lnl7/nix:2018-04-17 (2.0)
  • lnl7/nix:2018-03-13-patch1
  • lnl7/nix:2018-01-13 (1.11.16)
  • lnl7/nix:2017-10-07 (1.11.15)
  • lnl7/nix:2017-06-17 (1.11.10)
  • lnl7/nix:2017-06-09 (1.11.9)
  • lnl7/nix:2017-01-21 (1.11.6)
  • lnl7/nix:124f25b (1.11.4)
  • lnl7/nix:ea9d390 (1.11.2)
  • lnl7/nix:272cf5c

Default Image

The default image is intended for interactive use and includes some common and useful packages:

docker run --rm -it lnl7/nix nix repl '<nixpkgs>'
nix-repl> 

Building an Image

FROM lnl7/nix:2.3.7

RUN nix-env -iA \
 nixpkgs.curl \
 nixpkgs.jq

Building a new Base Image

nix-shell -A env --run './result/bin/run-docker-build'

The src can also can be overridden to use a custom nixpkgs for the image.

nix-shell -A env --argstr src ./srcs/2018-03-13.nix

Running as a remote builder

docker run --restart always --name nix-docker -d -p 3022:22 lnl7/nix:ssh

If you have not setup a remote builder before you can follow these steps.

Configure SSH

An insecure rsa key is provided in the repo, the following assumes you are using it. Optional instructions for generating a fresh key are provided at the end.

Single User Mode

Copy the rsa key to your ssh folder

chmod 600 ssh/insecure_rsa
cp ssh/insecure_rsa ~/.ssh/docker_rsa

Add an entry for the container in your ~/.ssh/config

Host nix-docker
  User root
  HostName 127.0.0.1
  Port 3022
  IdentityFile ~/.ssh/docker_rsa
Multi User Mode (Nix Daemon)

Copy the insecure rsa key to /etc/nix

sudo mkdir -p /etc/nix
chmod 600 ssh/insecure_rsa
sudo cp ssh/insecure_rsa /etc/nix/docker_rsa

Add an ssh entry to /var/root/.ssh/config if you are using nix daemon

Host nix-docker
  User root
  HostName 127.0.0.1
  Port 3022
  IdentityFile /etc/nix/docker_rsa

Optional: setup your own ssh key, instead of using the insecure key.

ssh-keygen -t rsa -b 2048 -N "" -f docker_rsa
scp docker_rsa.pub nix-docker:/root/.ssh/authorized_keys

Then copy the key to either /etc/nix or ~/.ssh depending on if you are running nix in single or multi user mode.

Create a signing keypair

openssl genrsa -out /etc/nix/signing-key.sec 2048
openssl rsa -in /etc/nix/signing-key.sec -pubout > /etc/nix/signing-key.pub
chmod 600 /etc/nix/signing-key.sec
ssh nix-docker mkdir -p /etc/nix
scp /etc/nix/signing-key.sec nix-docker:/etc/nix/signing-key.sec

Setup the container as a remote builder

sudo cp ssh/remote-build-env /etc/nix/
sudo cp ssh/machines /etc/nix/

Build a linux derivation

nix-build -E 'with import <nixpkgs> { system = "x86_64-linux"; }; hello.overrideAttrs (drv: { REBUILD = builtins.currentTime; })'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].