forked from DGNum/liminix
convert anoia.fs to use lualinux instead of lfs
This commit is contained in:
parent
834858d5bc
commit
dbd1264352
4 changed files with 27 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
||||||
fennel
|
fennel
|
||||||
, stdenv
|
, stdenv
|
||||||
, lua
|
, lua
|
||||||
|
, lualinux
|
||||||
}:
|
}:
|
||||||
let pname = "anoia";
|
let pname = "anoia";
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
|
@ -9,7 +10,7 @@ in stdenv.mkDerivation {
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
nativeBuildInputs = [ fennel ];
|
nativeBuildInputs = [ fennel ];
|
||||||
buildInputs = with lua.pkgs; [ luafilesystem ];
|
buildInputs = with lua.pkgs; [ luafilesystem lualinux ];
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
(local lfs (require :lfs))
|
(local ll (require :lualinux))
|
||||||
|
|
||||||
|
(local S_IFMT 0xf000)
|
||||||
|
(local S_IFSOCK 0xc000)
|
||||||
|
(local S_IFLNK 0xa000)
|
||||||
|
(local S_IFREG 0x8000)
|
||||||
|
(local S_IFBLK 0x6000)
|
||||||
|
(local S_IFDIR 0x4000)
|
||||||
|
(local S_IFCHR 0x2000)
|
||||||
|
(local S_IFIFO 0x1000)
|
||||||
|
|
||||||
|
(fn ifmt-bits [mode] (and mode (band mode 0xf000)))
|
||||||
|
|
||||||
(fn directory? [pathname]
|
(fn directory? [pathname]
|
||||||
(= (lfs.symlinkattributes pathname :mode) "directory"))
|
(let [(mode size mtime) (ll.lstat3 pathname)]
|
||||||
|
(= (ifmt-bits mode) S_IFDIR)))
|
||||||
|
|
||||||
(fn mktree [pathname]
|
(fn mktree [pathname]
|
||||||
(if (or (= pathname "") (= pathname "/"))
|
(if (or (= pathname "") (= pathname "/"))
|
||||||
|
@ -10,28 +22,28 @@
|
||||||
(or (directory? pathname)
|
(or (directory? pathname)
|
||||||
(let [parent (string.gsub pathname "/[^/]+/?$" "")]
|
(let [parent (string.gsub pathname "/[^/]+/?$" "")]
|
||||||
(or (directory? parent) (mktree parent))
|
(or (directory? parent) (mktree parent))
|
||||||
(assert (lfs.mkdir pathname)))))
|
(assert (ll.mkdir pathname)))))
|
||||||
|
|
||||||
(fn rmtree [pathname]
|
(fn rmtree [pathname]
|
||||||
(case (lfs.symlinkattributes pathname)
|
(case (ifmt-bits (ll.lstat3 pathname))
|
||||||
nil true
|
nil true
|
||||||
{:mode "directory"}
|
S_IFDIR
|
||||||
(do
|
(do
|
||||||
(each [f (lfs.dir pathname)]
|
(each [f (lfs.dir pathname)]
|
||||||
(when (not (or (= f ".") (= f "..")))
|
(when (not (or (= f ".") (= f "..")))
|
||||||
(rmtree ( .. pathname "/" f)))
|
(rmtree ( .. pathname "/" f)))
|
||||||
(lfs.rmdir pathname)))
|
(lfs.rmdir pathname)))
|
||||||
{:mode "file"}
|
S_IFREG
|
||||||
(os.remove pathname)
|
(os.remove pathname)
|
||||||
{:mode "link"}
|
S_IFLNK
|
||||||
(os.remove pathname)
|
(os.remove pathname)
|
||||||
unknown
|
unknown
|
||||||
(error (.. "can't remove " pathname " of kind \"" unknown.mode "\""))))
|
(error (.. "can't remove " pathname " of mode \"" unknown "\""))))
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
: mktree
|
: mktree
|
||||||
: rmtree
|
: rmtree
|
||||||
: directory?
|
: directory?
|
||||||
:symlink (fn [from to] (lfs.link from to true))
|
:symlink (fn [from to] (ll.symlink from to))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
writeFennelScript
|
writeFennelScript
|
||||||
, anoia
|
, anoia
|
||||||
, lua
|
, lua
|
||||||
|
, lualinux
|
||||||
}:
|
}:
|
||||||
writeFennelScript "odhcpc-script" [anoia lua.pkgs.luafilesystem] ./odhcp6-script.fnl
|
writeFennelScript "odhcpc-script" [anoia lualinux] ./odhcp6-script.fnl
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
lua
|
lua
|
||||||
, nellie
|
, nellie
|
||||||
|
, lualinux
|
||||||
, writeFennel
|
, writeFennel
|
||||||
, runCommand
|
, runCommand
|
||||||
, anoia
|
, anoia
|
||||||
|
@ -15,7 +16,7 @@ stdenv.mkDerivation {
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp -p ${writeFennel "uevent-watch" {
|
cp -p ${writeFennel "uevent-watch" {
|
||||||
packages = [fennel anoia nellie lua.pkgs.luafilesystem];
|
packages = [fennel anoia nellie lualinux];
|
||||||
mainFunction = "run";
|
mainFunction = "run";
|
||||||
} ./watch.fnl} $out/bin/uevent-watch
|
} ./watch.fnl} $out/bin/uevent-watch
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue