import <channel-name> => not found - nix

I'm following nix pills [1], which doesn't work anymore with the newest channel release [2].
$ echo 'graph test { a -- b }'|result/bin/dot -Tpng -o test.png
Format: "png" not recognized. ...
So I took the advice to use an old channel [3] (and replace binutils with binutils-unwrapped).
nix-channel --add https://nixos.org/channels/nixpkgs-release-14.12
Which works perfectly fine.
nixpkgs https://nixos.org/channels/nixpkgs-unstable
nixpkgs-release-14.12 https://nixos.org/channels/nixpkgs-release-14.12
But when I try to use it via import <nixpkgs-release-14.12>
I get
error: file 'nixpkgs-release-14.12' was not found in the Nix search path
[1] https://nixos.org/nixos/nix-pills/inputs-design-pattern.html
[2] https://github.com/NixOS/nix-pills/issues/107
[3] https://github.com/NixOS/nix-pills/issues/107#issuecomment-470992383

I hacked it via
import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-14.12.tar.gz)
Works, but I'm not sure it's the optimal solution.

You have to download it with the nix-channel --update command, but that won't work because the channel has been removed. You'll have to use a newer channel and run --update.

You can do it by checking out the version you want with git in a directory and setting NIX_PATH. Otherwise, it's either not available and/or your other packages in the newer channel would supersede it. You'd have to call your command with NIX_PATH=$mynixcheckoutdir prepended.

Related

Nixos 22.05 system build fails when referencing channel "file 'nixos-2111' was not found in the Nix search path (add it using $NIX_PATH or -I)"

When running sudo nixos-rebuild --upgrade boot I run into an error of:
error: file 'nixos-2111' was not found in the Nix search path (add it using $NIX_PATH or -I)
at /etc/nixos/chris.nix:30:23:
29| };
30| nixos-2111 = import <nixos-2111> {
| ^
31| config = config.nixpkgs.config;
This only occurred after I updated the nixos channel with sudo nix-channel --add https://nixos.org/channels/nixos-22.05 nixos (for the purpose of upgrading my Nixos system). This config built correctly previously (which is on 20.09).
What might be the cause of this issue? How can I diagnose this further? That channel definitely exists according to:
sudo nix-channel --list
nixos https://nixos.org/channels/nixos-22.05
nixos-2003 https://nixos.org/channels/nixos-20.03
nixos-2111 https://nixos.org/channels/nixos-21.11
nixos2003 https://nixos.org/channels/nixos-20.03
nixos2009 https://nixos.org/channels/nixos-20.09
unstable https://nixos.org/channels/nixpkgs-unstable
And:
nix repl '<nixos-2111>'
Welcome to Nix version 2.3.11. Type :? for help.
Loading '<nixos-2111>'...
Added 15491 variables.
My only suspicion is the new nix version of 2.8 from the prior 2.3.11 - perhaps it uses an different set of channels?
Update: Just removed the references to this channel (and the associated packages), and it built successfully. Which is weird as there were other channels referenced in this exact format so maybe something specifically to do with 21.11...

Ghostscript installed but not found RGhost::Config::GS[:path]='/path/to/my/gs'

I've been trying for a few hours now solve this problem and I looked everywhere for a solution and I did not find one. I'm trying to run a spec test for my project and I have the following error coming up:
RuntimeError:
Ghostscript not found in your system environment (linux-gnu).
Install it and set the variable RGhost::Config::GS[:path] with the executable.
Example: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style
RGhost::Config::GS[:path]="C:\\gs\\bin\\gswin32c.exe" #windows-style
And I do try to put RGhost::Config::GS[:path]='/usr/local/bin/gs' and it returns:
bash: RGhost::Config::GS[:path]=/usr/local/bin/gs: No such file or directory
but ghostscript is installed, I did everything (make, sudo make install, etc etc) and when I run gs -v it returns:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
When I use the user interface and search for "gs" in the "Files" application, it is found in /home/marcelle/projects/ghostscript-9.26/bin/gs and I also tried:
RGhost::Config::GS[:path]='/home/marcelle/projects/ghostscript-9.26/bin/gs'
and it returns the same error:
bash: RGhost::Config::GS[:path]=/home/marcelle/projects/ghostscript-9.26/bin/gs: No such file or directory
I also tried to delete ghostscript from my notebook with autoremove and purge and installed it again using what I mentioned before (./configure, make, sudo make install), restarted the notebook, the terminal and nothing.
PS: I'm using Ubuntu 20.04.
I managed to figure out a solution. Looking for the code for the Rghost, what I saw in its spec is that the path expected was different than the path the ghostscript really is.
When I run whereis or which on my terminal, it returns:
which gs
/usr/local/bin/gs
So I was trying to point to this path. But seeing the spec test for Rghost which I found on github for Rghost, we can see that it expects /usr/bin/gs:
it 'should detect linux env properly' do
RbConfig::CONFIG.should_receive(:[]).twice.with('host_os').and_return('linux')
File.should_receive(:exists?).with('/usr/bin/gs').and_return(true)
RGhost::Config.config_platform
RGhost::Config::GS[:path].should == '/usr/bin/gs'
end
So it expects /usr/bin and not /usr/local/bin.
Then I just copied to that path and the spec ran with no problems anymore:
sudo cp /usr/local/bin/gs /usr/bin
I've no experience with Ruby at all, but I also got this error when using asciidoctor, which uses rghost for the PDF generation.
The command RGhost::Config::GS[:path]='/path/to/my/gs' mentioned in the error is not a shell command, which is why bash couldn't handle it. However, to me it wasn't immediately clear what to do with this command either. I expected an easy way to set this variable somewhere, but couldn't find it.
What worked for me was searching the rghost.rb file, which is where this variable is set and can be changed. In Windows, it was located in C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\rghost-0.9.7\lib\rghost.rb.
In this file, I added the following line, which solved the problem:
RGhost::Config::GS[:path]="C:\\Program Files\\gs\\gs9.55.0\\bin\\gswin64c.exe"
NB: the mentioned paths can be different for everyone, so make sure to use that paths that are valid for your system.

How to undo `nix-channel --update`

After clean installation via NixOps, I logined to machine and executed
# nix-channel --update
This pulled ~130Mb of nixpkgs into my /nix/store. How can I undo this?
On a normal Nix or NixOS install, if you've updated your channels by accident with nix-channel --update, you can undo this by running
nix-channel --rollback
See the manual for more details.
On a NixOps installation, channels are configured but not actually used. See the other answer for that.
On a NixOps installation it seems that channels are configured, but aren't actually used by NixOps. This means that running nix-channel --update will create the very first generation, and nix-channel --rollback won't work as that can't roll back past the first generation.
The following seems to work for clearing out this information.
Do not run this on a Nix or NixOS install! This is just for NixOps.
rm /nix/var/nix/profiles/per-user/root/channels-1-link
rm /nix/var/nix/profiles/per-user/root/channels
rm ~/.nix-defexpr/channels
nix-collect-garbage -d

NixOS: Setting the default channel in configuration.nix

How do I set the default channel in NixOS's /etc/configuration.nix?
There is a command to set it and rebuild with
sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
sudo nixos-rebuild switch -I nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs
but I'd like to have it setup in configuration.nix so I don't have to remember how to do this everytime. Thanks!
system.autoUpgrade.channel is what you might be looking for
set it to any channel e.g.
system.autoUpgrade.channel = "https://nixos.org/channels/nixos-16.03-small/";
the documentation says:
by default, this is the channel set using nix-channel (run
nix-channel --list to see the current value)
an up to date list of channels can be found on https://nixos.org/channels/
ref: https://nixos.org/nixos/manual/options.html#opt-system.autoUpgrade.channel
https://nixos.org/nixos/manual/index.html#idm140737317454064
Set nixPath = [ "nixpkgs=http://nixos.org/channels/nixos-unstable/nixexprs.tar.xz" ];, see https://github.com/snabblab/snabblab-nixos/blob/d8b9761b107293891b19021f2f0f77a0e3ba3746/modules/common.nix#L39
The nix.nixPath (ref) option looks like it will do what you're after.
Also the nixos-unstable channel might be more appropriate for you, rather than nixpkgs-unstable. I believe the pkgs in the nixpkgs channel are tested and built for non-nixOS systems, though I can't remember a reference for that at the moment.
nix-channel --add https://nixos.org/channels/nixos-unstable/
nix-channel --update nixos-unstable
# /etc/nixos/configuration.nix
# Put nixos-unstable at the front of nixPath
{ lib, ... }:
{
nix.nixPath = lib.mkDefault (lib.mkBefore [ "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos-unstable" ]);
}
If you want the imperative nix-channel commands in your configuration.nix as well you could write a small systemd service to do so, as shown here.
Edit: To ensure configuration.nix is built from the latest unstable channel just set the value of nixpkgs as in the answer from #iElectric and Nix will use the expressions contained at that URL whenever it evaluates configuration.nix.
PS I realised you could also just point the nixos path to the nixos-unstable channel by doing nix-channel --add https://nixos.org/channels/nixos-unstable/ nixos but I think the first solution is clearer.

command-not-found not working because programs.sqlite is missing

I'm on the unstable nix channel:
# nix-channel --list
nixos https://nixos.org/channels/nixos-unstable
# nix-channel --update
downloading Nix expressions from ‘https://nixos.org/releases/nixos/unstable/nixos-16.09pre78848.9549257//nixexprs.tar.xz’...
downloading ‘https://nixos.org/releases/nixos/unstable/nixos-16.09pre78848.9549257//nixexprs.tar.xz’... [ [6192/6921 KiB, 6143.1 KiB/s]
unpacking channels...
For some reason, command-not-found doesn't work:
$ command-not-found
/home/fabian command-not-found
DBI connect('dbname=/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite','',...) failed: unable to open database file at /run/current-system/sw/bin/command-not-found line 13.
cannot open database `/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' at /run/current-system/sw/bin/command-not-found line 13.
Indeed, /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite doesn't exist. What could be the reason for this?
FWIW, it seems nixos-install doesn't properly generate programs.sqlite.
I was seeing the same error on a fresh 17.03 install, even though it's working on other systems I have that are also on 17.03.
Manually running nix-channel --update was all that was needed to fix it for me. (I didn't run nixos-rebuild or anything that would have changed the versions of command-not-found.)
Apparently it's removed in the most recent channels/nixos builds and awaiting a replacement - refs (1) (2)

Resources