hello, im trying to add
to mi configuration.nix file.
if i type this in console:
[root@Predator:/nix/store]# nix build --no-link --print-out-paths --eval-store auto github:niksingh710/nsearch
warning: $HOME ('/home/fher') is not owned by you, falling back to the one defined in the 'passwd' file ('/root')
/nix/store/nzkccqglq6q95vmqckvf7ncfd4fvidgf-nsearch
[root@Predator:/nix/store]# /nix/store/nzkccqglq6q95vmqckvf7ncfd4fvidgf-nsearch/bin/nsearch
all is right and run with no problem with absolute path
my questions are:
a) how can I add this to the path of the system from console (from nix build)
b) how can I add this to my configuration.nix so it works system wide as a environment.systemPackages and is reproducible (installs automatically with nixos-switch rebuild)
Thanks in advance
So I assume you donāt use a flake.nix
to manage your system configurationā¦ Iād recommend you to do that, since people rely on it nowadays although it isnāt yet considered a āstableā feature. If youād insist on staying with the current non flake setup, Iād try something like this:
nixpkgs.overlays = let
nsearchFlake= import (builtins.fetchTarball "https://github.com/niksingh710/nsearch/archive/master.tar.gz");
in [
(
final: prev: {
nsearch = nsearchFlake.packages.${self.pkgs.system}.default;
# Your own overlays...
}
)
];
However, Iām not sure about ${self.pkgs.system}
so you might want to hard-code x86_64-linux
instead.
Alternatively, since that is jusf a jq
and fzf
script, if you have both of these installed, you can simply āinstallā it imperatively by cloning the repo and adding that nsearch
script to your $PATH
. Thatās what I would do for such a simple script, as itād allow me better control when Iāll want to debug issues with it by myself.
1 Like
tryed to add what you said and gave me this error:
at /etc/nixos/configuration.nix:29:43:
28| final: prev: {
29| nsearch = nsearchFlake.packages.${self.pkgs.system}.default;
| ^
30| # Your own overlays...
I donāt how to do the x86_64-linux
part
Im less than a couple of months using nixos so be gentle with the explanation (im reading the documentation, but Its difficultā¦).
And also thanks for the speedy answer.
edited:
with:
nixpkgs.overlays = let
nsearchFlake= import (builtins.fetchTarball "https://github.com/niksingh710/nsearch/archive/master.tar.gz");
in [
(
final: prev: {
nsearch = nsearchFlake.packages.${pkgs.x86_64-linux.system}.default;
# Your own overlays...
} )
];
it doesnt gives error when nixos-rebuild switch, but i dont see the command in path and it doesnt have a path in store
I meant:
nixpkgs.overlays = let
nsearchFlake= import (builtins.fetchTarball "https://github.com/niksingh710/nsearch/archive/master.tar.gz");
in [
(
final: prev: {
nsearch = nsearchFlake.packages.x86_64-linux.default;
# Your own overlays...
}
)
];
1 Like
Thanks for the help, I found another way to do it , after messing with chatgpt for an hour i arrived to this.
created file nsearch.nix in /etc/nixos
{ config, pkgs, ... }:
let
myFlake = builtins.getFlake "github:niksingh710/nsearch";
in
{
environment.systemPackages = with pkgs; [
(myFlake.packages.${system}.default or (throw "Package 'default' not found in the flake"))
];
}
got package name with :
[root@Predator:/etc/nixos]# nix flake show github:niksingh710/nsearch
github:niksingh710/nsearch/6661b4e24f30345ab307964e4fc253ea807ea6f9
# āāāāpackages
# āāāāaarch64-linux
# ā āāāādefault omitted (use '--all-systems' to show)
# āāāāx86_64-darwin
# ā āāāādefault omitted (use '--all-systems' to show)
# āāāāx86_64-linux
# āāāā**default**: package 'nsearch'
#
default is the name to put in (myFlake.packages.${system}.name or (throw āPackage ānameā not found in the flakeā))
and imported it in configuration.nix:
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./nsearch.nix
];
it works !!!
thanks for your help and sorry for your time.
THANKS
Haha thatās interesting - it seems that you have flake enabled if you can run this command - if that is the case, then definitely using a complete /etc/nixos/flake.nix
setup is the way to go.
But anyway itās OK to start out like this. Get used to Nix in general, and at some point I assume youād feel confident to switch your setupā¦ Good luck !