diff --git a/pkgs/anoia/default.nix b/pkgs/anoia/default.nix index 9333e63..9882c57 100644 --- a/pkgs/anoia/default.nix +++ b/pkgs/anoia/default.nix @@ -2,6 +2,7 @@ fennel , stdenv , lua +, lualinux }: let pname = "anoia"; in stdenv.mkDerivation { @@ -9,7 +10,7 @@ in stdenv.mkDerivation { version = "0.1"; src = ./.; nativeBuildInputs = [ fennel ]; - buildInputs = with lua.pkgs; [ luafilesystem ]; + buildInputs = with lua.pkgs; [ luafilesystem lualinux ]; outputs = [ "out" "dev" ]; doCheck = true; diff --git a/pkgs/anoia/fs.fnl b/pkgs/anoia/fs.fnl index 8d60571..e3645cc 100644 --- a/pkgs/anoia/fs.fnl +++ b/pkgs/anoia/fs.fnl @@ -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] - (= (lfs.symlinkattributes pathname :mode) "directory")) + (let [(mode size mtime) (ll.lstat3 pathname)] + (= (ifmt-bits mode) S_IFDIR))) (fn mktree [pathname] (if (or (= pathname "") (= pathname "/")) @@ -10,28 +22,28 @@ (or (directory? pathname) (let [parent (string.gsub pathname "/[^/]+/?$" "")] (or (directory? parent) (mktree parent)) - (assert (lfs.mkdir pathname))))) + (assert (ll.mkdir pathname))))) (fn rmtree [pathname] - (case (lfs.symlinkattributes pathname) + (case (ifmt-bits (ll.lstat3 pathname)) nil true - {:mode "directory"} + S_IFDIR (do (each [f (lfs.dir pathname)] (when (not (or (= f ".") (= f ".."))) (rmtree ( .. pathname "/" f))) (lfs.rmdir pathname))) - {:mode "file"} + S_IFREG (os.remove pathname) - {:mode "link"} + S_IFLNK (os.remove pathname) unknown - (error (.. "can't remove " pathname " of kind \"" unknown.mode "\"")))) + (error (.. "can't remove " pathname " of mode \"" unknown "\"")))) { : mktree : rmtree : directory? - :symlink (fn [from to] (lfs.link from to true)) + :symlink (fn [from to] (ll.symlink from to)) } diff --git a/pkgs/odhcp-script/default.nix b/pkgs/odhcp-script/default.nix index 523729f..8aa081b 100644 --- a/pkgs/odhcp-script/default.nix +++ b/pkgs/odhcp-script/default.nix @@ -2,5 +2,6 @@ writeFennelScript , anoia , lua +, lualinux }: -writeFennelScript "odhcpc-script" [anoia lua.pkgs.luafilesystem] ./odhcp6-script.fnl +writeFennelScript "odhcpc-script" [anoia lualinux] ./odhcp6-script.fnl diff --git a/pkgs/uevent-watch/default.nix b/pkgs/uevent-watch/default.nix index 07a7888..df8f45f 100644 --- a/pkgs/uevent-watch/default.nix +++ b/pkgs/uevent-watch/default.nix @@ -1,6 +1,7 @@ { lua , nellie +, lualinux , writeFennel , runCommand , anoia @@ -15,7 +16,7 @@ stdenv.mkDerivation { installPhase = '' mkdir -p $out/bin cp -p ${writeFennel "uevent-watch" { - packages = [fennel anoia nellie lua.pkgs.luafilesystem]; + packages = [fennel anoia nellie lualinux]; mainFunction = "run"; } ./watch.fnl} $out/bin/uevent-watch '';