-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add resources to build docker image via nix
- Loading branch information
Derek Gonyeo
committed
Feb 28, 2018
1 parent
6f9d264
commit 9946df4
Showing
8 changed files
with
129 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
*.ho | ||
*.o | ||
*.swp | ||
docker-rootfs | ||
out* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine | ||
|
||
COPY docker-rootfs/nix /nix | ||
COPY docker-rootfs/root /root | ||
COPY docker-rootfs/bin /bin | ||
|
||
ENTRYPOINT /bin/cyanide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [ -e out ]; then | ||
rm -rf out | ||
fi | ||
|
||
if [ -e out-* ]; then | ||
rm -rf out-* | ||
fi | ||
|
||
if [ -e docker-rootfs ]; then | ||
rm -rf docker-rootfs | ||
fi | ||
|
||
nix-env -i cyanide -f . -r -p out | ||
nix-env -i vim -p out | ||
|
||
mkdir -p docker-rootfs | ||
|
||
for i in $(nix-store -qR out/); do | ||
mkdir -p $(dirname docker-rootfs/$i) | ||
cp -r $i docker-rootfs/$i | ||
done | ||
chmod -R +w docker-rootfs | ||
|
||
mkdir -p docker-rootfs/root/.config/cyanide/ | ||
mkdir -p docker-rootfs/etc | ||
mkdir -p docker-rootfs/bin | ||
|
||
cat > docker-rootfs/root/.config/cyanide/cyanide.conf <<EOF | ||
[DATABASE] | ||
host = localhost | ||
port = 5432 | ||
user = cyanide | ||
password = cyanide | ||
database = cyanide | ||
[EDITOR] | ||
editor = | ||
EOF | ||
|
||
cat > docker-rootfs/root/.vimrc <<EOF | ||
" Be iMproved | ||
set nocompatible | ||
" Enable spellchecking | ||
set spell | ||
" unicode | ||
set encoding=utf-8 " best default encoding | ||
setglobal fileencoding=utf-8 " ... | ||
set nobomb " do not write utf-8 BOM! | ||
EOF | ||
|
||
ln -s ../$(realpath out)/bin/cyanide docker-rootfs/bin/cyanide | ||
ln -s ../$(realpath out)/bin/vim docker-rootfs/bin/vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
source build-docker-rootfs.sh | ||
|
||
docker build . -t cyanide | ||
|
||
rm -rf out out-* docker-rootfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }: | ||
|
||
let | ||
|
||
inherit (nixpkgs) pkgs; | ||
|
||
f = { mkDerivation, base, brick, bytestring, config-ini | ||
, directory, either, microlens, postgresql-simple, process, SHA | ||
, stdenv, text, time, transformers, vector, vty | ||
}: | ||
mkDerivation { | ||
pname = "cyanide"; | ||
version = "0.1.0.0"; | ||
src = ./.; | ||
isLibrary = false; | ||
isExecutable = true; | ||
enableSharedExecutables = false; | ||
executableHaskellDepends = [ | ||
base brick bytestring config-ini directory either microlens | ||
postgresql-simple process SHA text time transformers vector vty | ||
]; | ||
homepage = "https://github.com/dgonyeo/cyanide#readme"; | ||
license = stdenv.lib.licenses.gpl3; | ||
}; | ||
|
||
haskellPackages = if compiler == "default" | ||
then pkgs.haskellPackages | ||
else pkgs.haskell.packages.${compiler}; | ||
|
||
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; | ||
|
||
drv = variant (haskellPackages.callPackage f {}); | ||
|
||
in | ||
|
||
if pkgs.lib.inNixShell then drv.env else drv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters