I've been using NixOS for almost two years and only just now realized I no longer need to be afraid of doing system upgrades right before leaving on a trip…
@jamey True, but for me, this came at the cost of a greater complexity of the commands, since after a year I am still pretty illiterate about how to do some operations: https://otini.chnik.fr/posts/personal-nix-faq.html
@otini Oh, no argument from me: NixOS is not (yet?) something I recommend generally. For my needs personally I'm delighted with it though. 😁
Regarding your question, "How can I get the Nix directory (containing the code and Nix files) of a package?" I'm not sure exactly what you want, but I use `nix-locate` all the time and it might help you. Otherwise perhaps you're looking for some combination of `nix-instantiate` and `nix-store --query`?
@jamey Mm, I'm not sure. These seem to deal more with the Nix store derivations. But I didn't know about these commands, so it's still interesting :)
Andrew's answer looks more like what I wanted to know: https://functional.cafe/@amiloradovsky/102151442863503462
@otini Oh! If that's what you meant, then since Nix 2.0 you can run `nix edit nixpkgs.hello` to bring up the Nix expression for the `hello` package in your preferred editor. Or if you have a nixpkgs clone you want to change, `nix edit -f path/to/nixpkgs hello`
@jamey Ooh, that's nice! Thank you!
@jamey it's kind of ironic because a few days ago nixos update killed grub on my computer
@pureevil wow, do you know what happened?
@jamey not quite, but my idea is that there were parts of grub from another distro left in /boot. So after an update to grub 2.04 those parts became incompatible with the efi part of the new grub. And everything went to shit.
I fixed it by clearing out /boot/EFI and installing grub from scratch, then using efibootmgr to make grub bootable.
@pureevil sounds like a pain! I'm glad you got it sorted out though.
@jamey the painful part was figuring out what was wrong. NixOS doesn't allow chrooting, and nice sandboxes don't work when you use nixos-enter (something to do with systemd here). In addition, if you boot your system with kexec, Linux doesn't recognize EFI and thus you can't use efibootmgr.
I used rEFInd to start the system and fix it from the inside.
@pureevil I'm sitting here trying to figure out how I would troubleshoot that. For a boot problem, I'd probably boot off install media on a USB stick, I think? And I'm pretty sure I'd be able to run grub-install from the NixOS install media. I dunno! Luckily for me I haven't faced a problem like that for at least a decade I think 😅
@jamey EFI problems are a huge pain in the ass, mostly because many vendors implement EFI incorrectly and test their stuff with Windows only.
@jamey I want to move to Guix but I'm afraid that is a risky move.
@ekaitz_zarraga Move to Guix from Nix or from something else? I haven't tried Guix but I'd guess if you can handle Nix it'd be fine…
@jamey From KDE-Neon (ubuntu based)
@ekaitz_zarraga Ah, yeah, that'd be a bigger jump. I came from Debian to NixOS and did okay, but I made the switch when I got a new laptop and could just go look at the old one if things went wrong.
@jamey well played! I'm afraid of moving and regretting later... I'm really used to debian based stuff and packaging, and even if i don't really use many software I don't want to make my own packages and stuff and I may find some software missing... I don't know.
@ekaitz_zarraga Yeah, that's totally fair. NixOS has been fantastic for me, but I'm not willing to actively recommend it to anybody.
If you want to just experiment with it, you could get many of the same benefits by installing Nix (or, I assume, Guix, but I haven't tried that) as an additional package manager on your existing Ubuntu install. Find out what software you use isn't packaged and so on without giving up your existing setup.
@jamey I have it installed as package manager but I never use it... :(
I have to use it more with my guile development...
Thanks for your thoughts
@ekaitz_zarraga if you don't mind one more thought: my favorite trick is using this together with https://direnv.net/ to completely define the dev environment for a single directory, independent of any other dev environments I have set up for other directories. It's like Python's virtualenv but for the entire toolchain, not just one language. I love it.
Sure, go ahead! I love to get more info. This is something I need to learn.
What does it provide on addition to `nix shell` or `guix environment`?
@ekaitz_zarraga It's just a small thing but I find it makes a big difference. When you cd into a directory that you've told direnv about, it runs nix-shell or whatever you want for you. When you cd out of it again, it resets the environment to whatever you had before. So it's an extra layer of convenience on top of the tools you mentioned.
@jamey So you can also set environment variables for, for example, say where a database should be located, so you can make it work in an isolate folder?
@ekaitz_zarraga Yeah! I even worked out how to make direnv set up a Postgres database stored locally in the project directory and served over a Unix socket that's also in the project directory, so it doesn't need any special privileges and deleting the project directory deletes everything associated with that project's database too. I've been meaning to write that up somewhere…
@jamey Ping me please if you do it!
I'm very interested.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!