How to install the make command in nixos - nix

I search in the the list of nix package. I write make.
I only find ekam and it doesn't work.
nix-shell -p ekam

Search for gnumake
On nixos:
nix-env -iA nixos.gnumake
On a shell:
nix-shell -p gnumake
works, but
nix-shell -p
is enough
You can now test on a project
make

Related

`nix-shell -p [package] --command [command]`

I'm trying to run a command in script using nix-shell -p [package] --command [comand] and getting an error Permission denied on files, that the command needs to operate on. The command needs only read access and if I try to do nix-shell -p [package] and then run the [command] there by hand, then everything is okay, but if I try to do it through the --command [command] it gives me an error. Why is that?
Edit:
The command looks like this: nix-shell -p ormolu --command "ormolu --mode check $(find . -name '*.hs')"
This has nothing to do with nix-shell (or ormolu). Try this instead:
nix-shell -p ormolu --command "find . -name '*.hs' -exec ormolu --mode check {} + "
The reason you've got permission denied is that you actually passing the first output of the find command to ormolu, and trying to execute the rest of the .hs files.

Docker openapi client generator can't find "spec file"

I have generated a openapi json file, and I wish to create a typescript client using docker.
I have tried to do something similar to what is on the openapi generator site (https://openapi-generator.tech/ - scroll down to docker part), but it doesn't work.
Command from site:
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli generate \
-i /local/petstore.yaml \
-g go \
-o /local/out/go
What I have tried:
docker run --rm -v \
$PWD:/local openapitools/openapi-generator-cli generate -i ./openapi.json \
-g typescript-axios
No matter what I do, there is always a problem with the ./openapi.json file. The error which occours:
[error] The spec file is not found: ./openapi.json
[error] Check the path of the OpenAPI spec and try again.
I have tried the things below:
-i ~/compass_backend/openapi.json
-i openapi.json
-i ./openapi.json
-i $PWD:/openapi.json
cat openapi.json | docker run .... (error, -i is required)
I am out of ideas. The error is always the same. What am I doing wrong?
I was able to solve the problem by switching from bash to powershell. Docker uses windows path notation and I was trying to use bash notation. If you type pwd in bash you get this:
/c/Users/aniemirka/compass_backend
And if you type pwd in powershell you get this:
C:\Users\aniemirka\compass_backend
So docker was trying to mount a volume to /c/Users/aniemirka/compass_backend\local, and it couldn't read it because it is not windows notation, so the volume didn't exist.

Why 'invalid reference format' when trying to run GUI in docker container?

I am new to docker and am experimenting with trying to get firefox GUI up and running. The Dockerfile I have is:
FROM ubuntu:21.10
RUN apt-get update
RUN apt-get install -y firefox
RUN groupadd -g GID <USERNAME>
RUN useradd -d /home/<USERNAME> -s /bin/bash \
-m <USERNAME> -u UID -g GID
USER <USERNAME>
ENV HOME /home/<USERNAME>
CMD /usr/bin/firefox
...where UID is userID and GID is groupID
I then build with:
$> docker build -t gui .
The image build completes successfully. Then I do:
$> docker run -v /tmp/.X11-unix:/tmp/.X11-unix \
-h $HOSTNAME -v $HOME/.Xauthority:/home/$USER/.Xauthority \
-e DISPLAY=$DISPLAY gui
At this point I get the error:
"docker: invalid reference format: repository name must be lowercase."
It's almost as if docker is trying to interpret the X server directory binding and display variable setting as a repository name.
What I am doing wrong?
Thanks in advance...
In fact the error you get tells you that docker cannot understand the reference i.e. the name of the image you are trying to run. As well explained by David Maze. He has proposed to debug it thanks to an echo command.
If you follow his advice, for example in your command if $HOSTNAME is not defined you will see the command with variable expanded and be able to see that it will lead to the observed error if launched. To fix it you can quote your variable (always a good advice to prevent errors) and check that each variable is defined. In your case a missing $HOSTNAME is my best guess.
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -h -v /Users/xxx/.Xauthority:/home/xxx/.Xauthority -e DISPLAY=/mydisplay gui
# docker: invalid reference format: repository name must be lowercase.
David Maze's comment gave the solution:
You're not quoting your environment variable expansions, so if $HOSTNAME is empty or $HOME contains a space you can get errors like this. Try putting the word echo in front of the command and seeing how the shell expands it.

Docker: Running nano in docker container

I open an interactive shell into a docker container like so
sudo docker exec -t -i {container_name} bash
So far so good but trying to run nano results in:
Error opening terminal: unknown.
I think this can be related with Docker Issue #9299.
There are some workarounds commented in that issue:
Run the container allocating a pseudo-TTY (option -t).
Export environment variable $TERM=xterm in the container's process run in exec (i.e.: export TERM=xterm)
Run comand : export TERM=xterm
You can add
ENV TERM xterm
to your Dockerfile if you will use the editor regularly. We have that setting in our base container, since we're constantly debugging things with vi/emacs.
docker exec -it id_container bash
apt-get update
apt-get install nano
export TERM=xterm
as $TERM was already set to xterm but still not working for me, here is a way that worked: docker exec -it [CONTAINER_ID] /bin/bash -c "export TERM=xterm; exec bash"
Run this command in your container apk add nano
I did a workaround, in my .bashrc i have added:
alias nano='export TERM=xterm && nano'
In this case the error no longer appear
For me export TERM=xterm causes some display issues described here:
https://superuser.com/questions/1172222/issues-editing-files-with-nano-in-bash-windows-10
In that case export TERM=linux may works better.
I don't know if we are talking about the same thing but you need to make apt update | apt install nano so you can install it in the container.

Is there a way to expand aliases in a non-interactive sh shell?

I have a collection of aliases defined in ~/.aliases which I would like to make available to sh even when it is run non-interactively. My system has been setup in the typical way so that sh is a symlink to bash.
When bash is run non-interactively as bash, this could by using shopt -s expand_aliases together with setting $ENV or $BASH_ENV to (directly or indirectly) source ~/.aliases.
But when bash is invoked non-interactively as sh, it seems to ignore $ENV and all startup files, so I can't see a way to do it. Any ideas? Or is this just not possible?
One way to force the shell to be interactive when running a script is using -i such as:
$ bash -i <script>
Also, note that if your script has execute permissions, you can replace:
#!/bin/bash
with:
#!/bin/bash -i

Resources