Hi. Can I use dnf pkg manger inside nixos to install pkgs? I see that dnf is a pkg available in nixpkgs so I wonder if it is possible.
It might be possible somehow but you’d really be going against how either of them are intended to be used.
What are you actually trying to achieve by doing that though?
Would something like a Distrobox container suffice?
I want to follow rails getting started guide but the setting for it in nix is bit too much for me. Bundix doesn’t exactly works great either.
So I figure if I can use dnf for quickly getting installing stuff, I can get to learning much faster instead of having to tinker with nix
I don’t see how not-using nix would help you learn nix. You can use nix on another distro if you want.
That’s fair. But some times I just wanna get in and out quick, and not bother with the overhead of having to set it up in nix.
About using nix on other distros, i’m just more comfortable with nixos now with how it works once, works forever so it’s hard to move away
Then why not distrobox as mentioned?
Yup, I’ll have a look
Another somewhat simpler option for one off needs for software, you can just spawn a nix shell with the package you want.
Example nmap, which is listed in the pkg repo as pkgs.nmap
nix-shell -p nmap
will spawn an ephemeral shell with the nmap tool available in your path will all compiled options.
You can do this for multiple packages by just stringing them together in the command
nix-shell -p nmap binutils stdenv
As for learning nix, you can get 90% of what you want done with 2 resources.
NixOS Search - search packages
NixOS Search - search options you can stuff directly into your config at /etc/nixos/configuration.nix
Both will show you example bits for how you can enable/disable features in nix directly in the intended manner.
Here are some example snips for config options in particular, which are available for ALOT of packages. Most of the mainstream tools and off the shelf open-source tools and servers will also have options listed here.
Including packages inside other packages as dependencies
nixpkgs.config.packageOverrides = pkgs: {
steam = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
egl-wayland
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
];
};
};
Setting env variables for programs declaratively:
This is an example of how to set an env variable for a specific program and to refer to a specific package as a dependency instead of whatever the default might be set to.
services.ollama.acceleration = "cuda";
services.ollama.package = pkgs.ollama;
services.ollama.enable = true;
services.ollama.environmentVariables = { OLLAMA_LLM_LIBRARY = "cuda";};
Setting preferences/arguments in a program
programs.nano.nanorc = "set linenumbers";
Or setting boot params in kernel declaratively, example setting packet forwarding (router function) in the kernel.
boot.kernel = {
sysctl = {
"net.ipv4.conf.all.forwarding" = true;
"net.ipv6.conf.all.forwarding" = false;
};};
Even the really mundane “idc” crap like NTP and timezones:
networking.timeServers = [ "127.0.0.1" ];
services.ntp = { enable = true; servers = ["127.0.0.1"];};
time.timeZone = "America/Chicago";
Its worth taking a day to read the wiki and at least the basics of package management in nix, otherwise your really missing out on the stability and purity that nix has to offer compared to another off the shelf distro like Fedora.
Thank you for your in depth reply. Do you have a good book or course recommendation for nix dev env setup? Or something about how nix is being used professionally?
I wont recommend courses as they normally cost money but i can recommend another couple of really awesome resources for nixos in particular.
First, The All Mighty Manual.
https://nixos.org/manual/nixos/stable/
Second, the nix.dev book, which is the manual on crack.
Heres the starter section:
https://nix.dev/tutorials/
And lastly, if you are more of a visual learner, this guy on YouTube is really good and the only real good resource on YT for learning nix in particular.
https://www.youtube.com/playlist?list=PLko9chwSoP-15ZtZxu64k_CuTzXrFpxPE
These combined will take you from crawling to a full sprint in a few weeks.
EDIT: Forgot your last mention:
Professional uses, yes.
NixOS devs are actually desired in alot of places these days, not just full stack but NixOS engineers specifically.
Observe:
NixOS Job indeed.com