1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-16 11:43:21 +03:00
mobile-nixos/boot/init/default.nix

58 lines
1.1 KiB
Nix
Raw Normal View History

{ stdenv
, fetchurl
2019-12-25 03:49:54 +03:00
, mrbgems
, 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
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 = ./.;
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() {
# 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
find $s -type f -iname '*.rb'
2019-12-23 06:32:34 +03:00
done | sort
}
# 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) \
init.rb
'';
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 = [
"./tasks"
2019-12-25 03:49:54 +03:00
] ++ tasks;
2019-12-21 08:38:27 +03:00
}