Skip to content

Commit

Permalink
organize files
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML committed Jun 6, 2023
1 parent 6afc426 commit bc7d2bc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 50 deletions.
57 changes: 57 additions & 0 deletions pkgs/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local miq = require "miq"

local fetch = miq.fetch
local package = miq.package
local f = miq.f

local pkgs = {}

pkgs.bootstrap_tools = fetch {
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz"
}

pkgs.busybox = fetch {
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/busybox",
executable = true
}

pkgs.toybox = fetch {
url = "http://landley.net/toybox/bin/toybox-x86_64",
executable = true
}

pkgs.unpack_bootstrap_tools = fetch {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/d6b863fd9b7bb962e6f9fdf292419a775e772891/pkgs/stdenv/linux/bootstrap-tools-musl/scripts/unpack-bootstrap-tools.sh",
executable = true
}

pkgs.bootstrap = package {
name = "bootstap",
version = "1.0",
deps = {
},
script = f[[
set -exu
{{pkgs.toybox}} mkdir -p $HOME/bin
export PATH="$HOME/bin:${PATH}"
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/ln
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/cp
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/tar
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/mkdir
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/chmod
cp -v {{pkgs.bootstrap_tools}} $HOME/bootstrap.tar.xz
mkdir -pv $miq_out
pushd $miq_out
tar -xvf $HOME/bootstrap.tar.xz
export out=$miq_out
export tarball={{pkgs.bootstrap_tools}}
export builder={{pkgs.busybox}}
{{pkgs.unpack_bootstrap_tools}}
]],
env = {
}
}

return pkgs
56 changes: 7 additions & 49 deletions pkgs/init.lua
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
local miq = require "miq"
local inspect = miq.inspect
local fetch = miq.fetch
local miq = require ("miq")
local package = miq.package
local f = miq.f
local trace = miq.trace

---@param first table
---@param second table
local merge = function(first, second)
for k,v in pairs(second) do first[k] = v end
end


local pkgs = {}

pkgs.bootstrap_tools = fetch {
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz"
}

pkgs.busybox = fetch {
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/busybox",
executable = true
}

pkgs.toybox = fetch {
url = "http://landley.net/toybox/bin/toybox-x86_64",
executable = true
}

pkgs.unpack_bootstrap_tools = fetch {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/d6b863fd9b7bb962e6f9fdf292419a775e772891/pkgs/stdenv/linux/bootstrap-tools-musl/scripts/unpack-bootstrap-tools.sh",
executable = true
}
merge(pkgs, require("bootstrap"))


pkgs.test = package {
Expand All @@ -43,34 +28,7 @@ pkgs.test = package {
}
}

pkgs.bootstrap = package {
name = "bootstap",
version = "1.0",
deps = {
},
script = f[[
set -exu
{{pkgs.toybox}} mkdir -p $HOME/bin
export PATH="$HOME/bin:${PATH}"
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/ln
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/cp
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/tar
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/mkdir
{{pkgs.toybox}} ln -vs {{pkgs.toybox}} $HOME/bin/chmod
cp -v {{pkgs.bootstrap_tools}} $HOME/bootstrap.tar.xz
mkdir -pv $miq_out
pushd $miq_out
tar -xvf $HOME/bootstrap.tar.xz

export out=$miq_out
export tarball={{pkgs.bootstrap_tools}}
export builder={{pkgs.busybox}}
{{pkgs.unpack_bootstrap_tools}}
]],
env = {
}
}


miq.trace(pkgs)
Expand Down
6 changes: 5 additions & 1 deletion src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::hash::Hash;
use std::path::{Path, PathBuf};

use color_eyre::eyre::{bail, Context};
use color_eyre::eyre::{bail, Context, ContextCompat};
use color_eyre::Result;
use mlua::prelude::*;
use mlua::{chunk, StdLib, Table, Value};
Expand Down Expand Up @@ -34,10 +34,14 @@ impl crate::Main for Args {

pub fn evaluate<P: AsRef<Path>>(path: P) -> Result<BTreeMap<String, Unit>> {
let path = path.as_ref();
let path = path.canonicalize()?;
info!("Loading {:?}", path);

let lua = create_lua_env()?;

let parent = path.parent().wrap_err("Reading input file's parent")?;
std::env::set_current_dir(parent).wrap_err(format!("Changing directory to {:?}", parent))?;

let toplevel_export_lua: Table = lua.load(path).eval().wrap_err("Loading input file")?;

let mut toplevel_export: BTreeMap<String, Unit> = BTreeMap::new();
Expand Down

0 comments on commit bc7d2bc

Please sign in to comment.