Skip to content

Commit

Permalink
adding first ubuntu base with nix! (#1)
Browse files Browse the repository at this point in the history
* adding first ubuntu base with nix!
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Nov 28, 2022
1 parent cc22d56 commit 5fd8a92
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/build_simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ basedir=$(dirname $filename)
printf "Base directory is ${basedir}\n"
# Get relative path to PWD and generate dashed name from it
echo "${prefix} -t ${container} ."
echo "Current directory is ${PWD}"
ls
${prefix} -f $filename -t ${container} .

echo "uri=${container}" >> $GITHUB_OUTPUT
Expand Down
4 changes: 0 additions & 4 deletions .github/scripts/prepare_paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ parsed=""
for file in ${changed_files}; do
filename=$(basename ${file})

# We are going to have paths inside/outside container and need relative
if [[ "$filename" == "uptodate.yaml" ]]; then
parsed="${parsed} ${file}"
fi
# If we find a Dockerfile, change to uptodate.yaml if it exists
if [[ "$filename" == "Dockerfile" ]]; then
dir=$(dirname ${file})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ to provide some nix bases for testing. We are hoping to provide one or more Nix
that can be used to build software. For more specific (pre-built) developer environments, please
see [rse-ops/devbox](https://github.com/rse-ops/devbox)

![img/rse-ops-docker.png](https://github.com/rse-ops/radius-docker/blob/main/img/rse-ops-docker.png)
![https://raw.githubusercontent.com/rse-ops/docker-images/main/img/rse-ops-docker.png](https://raw.githubusercontent.com/rse-ops/docker-images/main/img/rse-ops-docker.png)

[![License](https://img.shields.io/badge/License-MIT%203--Clause-blue.svg)](https://github.com/rse-ops/radius-docker/blob/main/LICENSE)

Expand Down
53 changes: 53 additions & 0 deletions nix-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG ubuntu_version=22.04
FROM ubuntu:$ubuntu_version
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV EDITOR=vim

# docker build -t nix-base .

RUN apt-get update && \
apt-get install -y \
ca-certificates \
bash-completion \
build-essential \
curl \
cmake \
gnupg \
htop \
jq \
less \
lsb-release \
lsof \
man-db \
nano \
ssl-cert \
sudo \
unzip \
xz-utils \
zip

# install nix
RUN sh <(curl -L https://nixos.org/nix/install) --daemon

RUN mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs && \
echo 'sandbox = false' >> $HOME/.config/nix/nix.conf && \
echo "experimental-features = nix-command flakes" >> $HOME/.config/nix/nix.conf && \
echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc

# install docker and configure daemon to use vfs as GitHub codespaces requires vfs
# https://github.com/moby/moby/issues/13742#issuecomment-725197223
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin && \
mkdir -p /etc/docker && \
echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json

# Ensure we can use NUR (nix user repository) and allow unfree
COPY nix-ubuntu/config.nix /root/.config/nixpkgs/config.nix

# Install our packages, enter the container in the shell
WORKDIR /code
21 changes: 21 additions & 0 deletions nix-ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Nix Ubuntu

This will serve as a base container for nix environments (that should also
work in VS Code). We use an ubuntu base since our user base isn't entirely
comfortable with nix yet.

## Example Usage

**under development**

```dockerfile
FROM ghcr.io/rse-ops/nix-ubuntu:ubuntu-22.04
COPY shell.nix shell.nix
RUN $HOME/.nix-profile/bin/nix-env -i -f shell.nix
```

To install from the rseops Nix User Repository (!!):

```bash
$ nix-env -f '<nixpkgs>' -iA nur.repos.rseops.conduit
```
8 changes: 8 additions & 0 deletions nix-ubuntu/config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
allowUnfree = true;
packageOverrides = pkgs: {
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
};
}
4 changes: 4 additions & 0 deletions nix-ubuntu/uptodate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dockerbuild:
matrix:
ubuntu_version:
- "22.04"

0 comments on commit 5fd8a92

Please sign in to comment.