What does "dot slash dot" (./.) mean in a Nix expression? - nix

Wherever I see flake-compat used, it is a variation of
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix
It is obviously a path that refers to the current directory which can be proven with a simple test:
[~/testdir]$ ll .
total 24
drwxr-xr-x 2 toraritte users 4096 Jul 21 21:56 ./
drwx------ 7 toraritte users 20480 Jul 15 23:13 ../
-rw-r--r-- 1 toraritte users 0 Jul 21 21:56 lofa
[~/testdir]$ ll ./.
total 24
drwxr-xr-x 2 toraritte users 4096 Jul 21 21:56 ./
drwx------ 7 toraritte users 20480 Jul 15 23:13 ../
-rw-r--r-- 1 toraritte users 0 Jul 21 21:56 lofa
So why not simply use .?

From 5.2.1 Values section of the Nix manual (emphasis mine):
Paths, e.g., /bin/sh or ./builder.sh. A path must contain at least one
slash to be recognised as such.
For instance, builder.sh is not a
path: it's parsed as an expression that selects the attribute sh from
the variable builder. If the file name is relative, i.e., if it does
not begin with a slash, it is made absolute at parse time relative to
the directory of the Nix expression that contained it. For instance,
if a Nix expression in /foo/bar/bla.nix refers to ../xyzzy/fnord.nix,
the absolute path is /foo/xyzzy/fnord.nix.

Related

Lua can't import a module and says file not found but the file exists

i'm trying to run a lua script from inside haproxy that imports the "pgmoon" library. i can import pgmoon and get as far as opening a socket, but then i run into this:
[ALERT] 082/234313 (8) : Lua function 'queue-request': runtime error: /usr/local/share/lua/5.3/pgmoon/init.lua:269: module 'pgmoon.crypto' not found:
no field package.preload['pgmoon.crypto']
no file '/usr/local/share/lua/5.3/pgmoon/crypto.lua'
no file '/usr/local/share/lua/5.3/pgmoon/crypto/init.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto/init.lua'
no file '/usr/share/lua/5.3/pgmoon/crypto.lua'
no file '/usr/share/lua/5.3/pgmoon/crypto/init.lua'
no file './pgmoon/crypto.lua'
no file './pgmoon/crypto/init.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.3/pgmoon/crypto.so'
no file '/usr/lib/lua/5.3/pgmoon/crypto.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './pgmoon/crypto.so'
no file '/usr/local/lib/lua/5.3/pgmoon.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.3/pgmoon.so'
no file '/usr/lib/lua/5.3/pgmoon.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './pgmoon.so' from [C] global 'require', /usr/local/share/lua/5.3/pgmoon/init.lua:269 C function line 267 ..., /usr/local/share/lua/5.3/pgmoon/init.lua:211 method 'connect', /usr/local/haproxy/queue-request.lua:38 C function line 25.
however, there is a file at /usr/local/share/lua/5.3/pgmoon/crypto.lua, this is what ls shows:
# ls -la /usr/local/share/lua/5.3/pgmoon/
total 60
drwxr-xr-x 1 root root 4096 Mar 24 23:42 .
drwxr-xr-x 1 root root 4096 Mar 24 23:00 ..
-rw-r--r-- 1 root root 2880 Mar 24 23:00 arrays.lua
-rw-r--r-- 1 root root 1130 Mar 24 23:00 bit.lua
-rw-r--r-- 1 root root 1587 Mar 24 23:00 cqueues.lua
-rw-r--r-- 1 root root 654 Mar 24 23:00 crypto.lua
-rw-r--r-- 1 root root 2084 Mar 24 23:00 hstore.lua
-rw-r--r-- 1 root root 20127 Mar 24 23:00 init.lua
-rw-r--r-- 1 root root 665 Mar 24 23:00 json.lua
-rw-r--r-- 1 root root 2728 Mar 24 23:42 socket.lua
-rw-r--r-- 1 root root 457 Mar 24 23:00 util.lua
i could see it being permissions-related, if the haproxy user couldn't access a root owned file, but by the time it gets here it's already executed init.lua which has imported socket.lua and they've all got the same permissions...
Anybody know why lua thinks there is no file at crypto.lua?
I guess that you have haproxy configured with chroot and there actually isn't a file at /usr/local/share/lua/5.3/pgmoon/crypto.lua - in the chroot you haproxy runs in.
The require('pgmoon.crypto') in init.lua is within a function and probably tries to run long after Haproxy and lua initialization - and the root change.
And somewhat (un)relatedly - you can probably expect other problems with the pgmoon not being aware of haproxy, eg. its use of luasocket and not the haproxy-provided replacement: https://www.haproxy.com/blog/5-ways-to-extend-haproxy-with-lua/
The Socket class is a replacement for the standard Lua Socket class and is compatible with HAProxy’s non-blocking nature. When you want to use socket functions in your actions, you must use this class.

Haproxy can load socket.http.module 'socket.http' not found

i already install luasocket
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require("socket.http")
table: 0x9b2d80
>
debian:/usr/local/share/lua/5.3/socket# ll
total 56
-rw-r--r-- 1 root root 10640 Dec 22 17:47 ftp.lua
-rw-r--r-- 1 root root 3698 Dec 22 17:47 headers.lua
-rw-r--r-- 1 root root 13216 Dec 22 17:47 http.lua
-rw-r--r-- 1 root root 8074 Dec 22 17:47 smtp.lua
-rw-r--r-- 1 root root 3766 Dec 22 17:47 tp.lua
-rw-r--r-- 1 root root 11105 Dec 22 17:47 url.lua
in Haproxy Lua code:
local http = require("socket.http")
When i request web,
runtime error: /etc/haproxy/waf/lib.lua:7: module 'socket.http' not found:#012#011no field package.preload['socket.http']#012#011no file '/usr/local/share/lua/5.3/socket/http.lua'#012#011no file '/usr/local/share/lua/5.3/socket/http/init.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http/init.lua'#012#011no file '/usr/share/lua/5.3/socket/http.lua'#012#011no file '/usr/share/lua/5.3/socket/http/init.lua'#012#011no file './socket/http.lua'#012#011no file './socket/http/init.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket/http.so'#012#011no file '/usr/lib/lua/5.3/socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/loadall.so'#012#011no file './socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/socket.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket.so'#012#011no file '/usr/lib/lua/5.3/socket.so'#012#011no file '/usr/lo
who can help me. thx
Your computer cannot find the required files.
https://www.lua.org/pil/8.1.html
To determine its path, require first checks the global variable
LUA_PATH. If the value of LUA_PATH is a string, that string is the
path. Otherwise, require checks the environment variable LUA_PATH.
Finally, if both checks fail, require uses a fixed path (typically
"?;?.lua", although it is easy to change that when you compile Lua).
The content of LUA_PATH will be copied into package.path. So either add the location of that module to the system variable befor running Lua or add it to package.path befor require.

grep --exclude-from: how to include multiple files

If I use --exclude-from multiple times (to include multiple files), will grep just use the last --exclude-from or will it "or" all the filters together as if they had been in one file (and using one --exclude-from)?
Although this is not clear from either the man pages or grep's source code, exclude-from is additive. Here's my example:
Make five files named 'file.a' through 'file.f' each containing 'test_string', and five filters 'ex_a.lst' through 'ex_f.lst' containing '*.a' through '*.f', respectively:
$ for X in a b c d e f; do echo test_string > file.$X; echo file.$X > ex_$X.lst; done
$ ls -l
total 48
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_a.lst
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_b.lst
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_c.lst
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_d.lst
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_e.lst
-rw-rw-r-- 1 user group 7 Jan 17 17:02 ex_f.lst
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.a
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.b
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.c
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.d
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.e
-rw-rw-r-- 1 user group 12 Jan 17 17:02 file.f
$ cat file.a
test_string
$ cat ex_a.lst
file.a
Search for 'test_string' in the current directory, without filters:
$ grep -R test_string | sort
file.a:test_string
file.b:test_string
file.c:test_string
file.d:test_string
file.e:test_string
file.f:test_string
All files matched. Now add three filters from three files:
$ grep -R test_string --exclude-from=ex_a.lst --exclude-from=ex_c.lst --exclude-from=ex_e.lst | sort
file.b:test_string
file.d:test_string
file.f:test_string
We are left with only three results, the ones that weren't filtered out! For this to be the case, we must have selected all three 'ex_[ace].lst' filter files.

Jenkins can't find artifacts

I have a jenkins running a job, after which I want it to "archive artifact", which is basically just get some files.
The Job clones a github and when ran, it generates some log files which I need.
The patter is:
logfiles/*
I added a command to list the directory to make sure the files are there, and indeed they are.
+ ls -la logfiles
total 24
drwxr-xr-x 2 root root 4096 Apr 22 23:23 .
drwxr-xr-x 8 root root 4096 Apr 22 23:23 ..
-rw-r--r-- 1 root root 0 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41.log
-rw-r--r-- 1 root root 1248 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_shortmsg.csv
-rw-r--r-- 1 root root 2521 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_stats.log
-rw-r--r-- 1 root root 8035 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_trace_msg.log
Archiving artifacts
ERROR: No artifacts found that match the file pattern "logfiles/*". Configuration error?
ERROR: ‘logfiles/*’ doesn’t match anything, but ‘*’ does. Perhaps that’s what you mean?
Build step 'Archive the artifacts' changed build result to FAILURE
I don't really understand why they are not found.
Hope someone can help!
Thanks!
I finally found my problem. I had configured the job to do the git clone. But for some reason I also added the cloning on the build steps... once i removed that jenkins started getting the files properly.
I would still like to understand why this would happen...
Thanks to all

idlj parameter invalid argument -td mac?

Im trying to follow a tutorial to do a CORBA assignment.
project
-Client/HelloClient.java
-Server/HelloServer.java
-Hello.idl
I do the first step, trying to compile the IDL (from the project root), and it fails.
$ idlj –td Client –fclient Hello.idl
com.sun.tools.corba.se.idl.InvalidArgument: Invalid argument: –td.
java version "1.8.0_11"
$ ls -l
total 16
drwxr-xr-x 3 juliusskye staff 102 Oct 28 20:14 Client
-rw-r-----# 1 juliusskye staff 85 Oct 28 17:49 Hello.idl
drwxr-xr-x 3 juliusskye staff 102 Oct 28 17:52 Server
-rw-r--r-- 1 juliusskye staff 425 Oct 29 13:45 idljintro.iml
drwxr-xr-x 2 juliusskye staff 68 Oct 29 13:45 src
I found this which says CORBA has problems parsing paths with / in front. But mine doesn't have a /
apparently the Lecturer's instructions were wrong or outdated or the compiler is not fully working but compilation of all files is achieved by
idlj -fall hello.idl

Resources