Skip to content

Instantly share code, notes, and snippets.

@3noch
Created December 13, 2016 21:14
Show Gist options
  • Save 3noch/5847364b7428e175a1860c16f14b8336 to your computer and use it in GitHub Desktop.
Save 3noch/5847364b7428e175a1860c16f14b8336 to your computer and use it in GitHub Desktop.
Craft Happy Lager Demo with Nix
{ callPackage
, fetchFromGitHub
, runCommand
, writeableDirStr ? "/var/lib/writeable" # e.g. "/var/lib/phpfpm/HappyLager"
, writeableOrigDirName ? "_writeable" # e.g. "_writeable"
, ...
}:
let
craft-cms-deriv = { fetchzip, runCommand, ... }:
let
version = "2.6";
build = "2954";
in fetchzip {
url = "https://download.buildwithcraft.com/craft/${version}/${version}.${build}/Craft-${version}.${build}.zip";
stripRoot = false;
sha256 = "0xl6qfavnx5j5b4nrqsbs2r9lv3m20x66m73j8y75risr0251wrl";
};
craft-cms = callPackage craft-cms-deriv {};
appName = "craft-cms-demo-happy-lager";
src = fetchFromGitHub {
owner = "pixelandtonic";
repo = "HappyLager";
rev = "35f1ac5720d74f9f5c2bd2ce2180fae94cb97d92";
sha256 = "1ma51j0i9pc6h4c65ndz8b9256m1fqqsa8hhq4ss39ybdk8qlxvb";
};
in runCommand appName { inherit src; } ''
mkdir -p "$out"
cp -r "$src"/* "$out"
ls "$out"
cp -r "${craft-cms}/craft/app" "$out/craft" # This fails with cp: cannot create directory '/nix/store/j42z3dbqq6f61nj6n4a62vfxh75r8wh4-HappyLager-CraftCMS-Demo/craft/app': Permission denied
find $out -name ".htaccess" | xargs rm
writeable_orig_dir="$out/${writeableOrigDirName}"
mkdir -p "$writeable_orig_dir"
mv "$out/config" "$writeable_orig_dir"
mv "$out/storage" "$writeable_orig_dir"
ln -s "${writeableDirStr}/config" "$out/config"
ln -s "${writeableDirStr}/storage" "$out/storage"
''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment