2020-03-02 06:22:09 +03:00
|
|
|
{ stdenv
|
|
|
|
, fetchurl
|
2019-12-25 03:49:54 +03:00
|
|
|
, mrbgems
|
2020-03-02 06:22:09 +03:00
|
|
|
, mruby
|
|
|
|
, script-loader
|
2019-12-25 03:49:54 +03:00
|
|
|
|
|
|
|
# Additional tasks
|
|
|
|
, tasks ? []
|
|
|
|
}:
|
2019-12-21 08:38:27 +03:00
|
|
|
|
2019-12-22 06:23:25 +03:00
|
|
|
let
|
|
|
|
ruby_rev = "37457117c941b700b150d76879318c429599d83f";
|
|
|
|
shellwords = fetchurl {
|
|
|
|
name = "shellwords.rb";
|
|
|
|
url = "https://raw.githubusercontent.com/ruby/ruby/${ruby_rev}/lib/shellwords.rb";
|
|
|
|
sha256 = "197g7qvrrijmajixa2h9c4jw26l36y8ig6qjb5d43qg4qykhqfcx";
|
|
|
|
};
|
|
|
|
in
|
2020-03-02 06:22:09 +03:00
|
|
|
stdenv.mkDerivation {
|
2019-12-21 08:38:27 +03:00
|
|
|
pname = "mobile-nixos-init";
|
2020-02-04 00:16:49 +03:00
|
|
|
version = "0.1.0";
|
2019-12-21 08:38:27 +03:00
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
2020-03-02 06:22:09 +03:00
|
|
|
nativeBuildInputs = [
|
|
|
|
mruby
|
|
|
|
];
|
|
|
|
|
2019-12-22 06:23:25 +03:00
|
|
|
postPatch = ''
|
|
|
|
cp ${shellwords} lib/0001_shellwords.rb
|
|
|
|
'';
|
|
|
|
|
2019-12-21 08:38:27 +03:00
|
|
|
buildPhase = ''
|
2019-12-23 06:32:34 +03:00
|
|
|
get_tasks() {
|
2020-03-02 06:22:09 +03:00
|
|
|
# Sorting ensures a stable lexicographic import order.
|
|
|
|
# Otherwise the compiler could accidentally be flaky.
|
2019-12-23 06:32:34 +03:00
|
|
|
for s in $tasks; do
|
2019-12-23 07:12:34 +03:00
|
|
|
find $s -type f -iname '*.rb'
|
2019-12-23 06:32:34 +03:00
|
|
|
done | sort
|
|
|
|
}
|
|
|
|
|
2020-02-28 07:02:15 +03:00
|
|
|
# This is the "script" that will be loaded.
|
|
|
|
mrbc -o init.mrb \
|
2019-12-23 06:32:34 +03:00
|
|
|
$(find lib -type f | sort) \
|
2019-12-25 03:49:54 +03:00
|
|
|
$(get_tasks) \
|
2020-02-28 07:02:15 +03:00
|
|
|
init.rb
|
2020-03-02 06:22:09 +03:00
|
|
|
'';
|
2020-02-28 07:02:15 +03:00
|
|
|
|
2020-03-02 06:22:09 +03:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
install -D -t $out/libexec/ init.mrb
|
2019-12-21 08:38:27 +03:00
|
|
|
'';
|
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
tasks = [
|
2019-12-23 07:12:34 +03:00
|
|
|
"./tasks"
|
2019-12-25 03:49:54 +03:00
|
|
|
] ++ tasks;
|
2019-12-21 08:38:27 +03:00
|
|
|
}
|