![Community banner](https://infosec.pub/pictrs/image/7802a65e-7a9e-4adf-9d24-130233203920.png)
![nixos](https://infosec.pub/pictrs/image/4db9ff39-0dbe-4989-8ecb-565be8faf70b.png?format=webp&thumbnail=48)
NixOS
- [Help] Python Packaging Issue: How to link libnvrtc.so.12 and libnvrtc-b51b459d.so to torch-bin?discourse.nixos.org Python Packaging Issue: How to link libnvrtc.so.12 and libnvrtc-b51b459d.so to torch-bin
I’m trying to package a repo I used to use in Windows Subsystem for Linux. I’m about to resort to podman, but I’m so close to getting it to work in Nix. The original repo is here: GitHub - neonbjb/tortoise-tts: A multi-voice TTS system trained with an emphasis on quality My fork uses poetry2nix her...
- Has someone deployed Kafka on their NixOS system? I could use some help doing it the "nix" waydiscourse.nixos.org How to setup Kafka Server on Nixos
I found some settings on NixOS Search I’ve added these to my configuration.nix: environment.systemPackages = with pkgs; [ apacheKafka ]; services.apache-kafka = { enable = true; settings = { "broker.id" = 0; "log.dirs" = [ "/tmp/kafka_logs" ]; listeners = ["PLAI...
- Making a development shell for an AI/GPU Accelerated python project with nix flakes, poetry/poetry2nix, and pypi
Went through the pain of packaging a python project on Nixos. Here's some issues I hit, and how I got lucky resolving them. I feel the most reliable way of doing this in the future is to use docker and just imperatively build.
Here's how I got web drivers, AI dependencies, gpu dependencies, and an api dependency bundled together into an ephemeral shell for python development, on NixOS 23.11
-
Start with setting up poetry2nix
-
Get the template flake by running
nix flake init --template github:nix-community/poetry2nix
-
in the flake.nix, sometimes changing
projectDir = self
toprojectDir = ./.
fixed some issues -
in your terminal, run
nix develop .
to build the poetry app with python packages described inpyproject.toml
-
By default, just poetry and python latest should be installed. the dependencies for the project (which gets reflected in the pyproject.toml) are updated with
poetry add
, such aspoetry add numpy selenium scikit-learn
-
Exit out of the ephemeral shell from
nix develop .
, and rerun to have poetry2nix rebuild and link the newly declared packages
Poetry2nix has worked pretty well for the more obscure python packages, but failed in others. For example,
sentence-transformers
would depend onmaturin
, which would fail to linksetuptools
. If poetry doesn't work, you can try and get the package from nixpkgs, or specify sha256s from pypi.orgHere's an example of what I added to my flake.nix to get gpu acceleration, sentence-transfomers, firefox drivers for selenium, and other packages poetry failed to setup:
packages = [ pkgs.poetry pkgs.python311Packages.sentence-transformers pkgs.firefox pkgs.python311Packages.openai pkgs.python311Packages.yt-dlp pkgs.python311Packages.pyopencl ];
was added to this flake.nix, as in,
```nix { description = "Application packaged using poetry2nix";
inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; poetry2nix = { url = "github:nix-community/poetry2nix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, flake-utils, poetry2nix }: flake-utils.lib.eachDefaultSystem (system: let # see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples. pkgs = nixpkgs.legacyPackages.${system}; inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication; in { packages = { myapp = mkPoetryApplication { projectDir = ./.; }; default = self.packages.${system}.myapp; }; devShells.default = pkgs.mkShell { inputsFrom = [ self.packages.${system}.myapp ]; packages = [ pkgs.poetry pkgs.python311Packages.sentence-transformers pkgs.firefox pkgs.python311Packages.openai pkgs.python311Packages.yt-dlp pkgs.python311Packages.pyopencl ]; nativeBuildInputs = [( pkgs.python311Packages.buildPythonPackage rec { pname = "serpapi"; version = "0.1.5"; src = pkgs.python311Packages.fetchPypi { inherit pname version; sha256 = "b9707ed54750fdd2f62dc3a17c6a3fb7fa421dc37902fd65b2263c0ac765a1a5"; }; } )]; }; }); } ```
There was one package (serpapi), which was not in nixpkgs, and poetry failed as well. Adding this to native build inputs got serpapi installed
nativeBuildInputs = [( pkgs.python311Packages.buildPythonPackage rec { pname = "serpapi"; version = "0.1.5"; src = pkgs.python311Packages.fetchPypi { inherit pname version; sha256 = "b9707ed54750fdd2f62dc3a17c6a3fb7fa421dc37902fd65b2263c0ac765a1a5"; }; } )];
All in all, it works, and I have no doubt I've made a reproducible environment. What attracts me is I've never had an easier time setting up cuda/cudnn/tensorrt/... system drivers have been near effortless, and much faster to setup than on debian. Tools like sentence-transformers and torch default to packages which leverage the GPU.
What pushes me away, is I've had failures in each of the three methods for specifying package dependencies, even though one of the three eventually was the fix for integrating the dependencies into my shell. For now, I'll stick with it, but it's hard for me to suggest to a team we use this in development
- How to setup unreal engine 5.3.2 on NixOS, and fix compile failures from Setup.sh: required file not founddiscourse.nixos.org UE compile failures on latest nix
I’ve got it to at least link appropriately. Here’s what I did, not sure if using steam-run is all I needed to do, but I did all three of the following in this thread https://www.reddit.com/r/NixOS/comments/17kwkgv/switched_from_nobara_to_nixos_my_opinion_so_far/ Unreal Engine and Godot Engine nee...
- What's that thing with --extra-experimental-features?
So I tried to follow some tutorial about flakes, but it seems these are extra-experimental still.
I am using NixOS 23.11 with Nix 2.18.1 in a VM (those are the most recent stable versions, right?).
Trying around I already found out that instead of eg.
nix flake update
I have to use--extra-experimental-features
two times to get this simple command:nix --extra-experimental-features nix-command --extra-experimental-features flakes flake update
Searching the web I found several different things that people put into their/etc/nixos/configuration.nix
to enable this globally, but none of those worked for me. I assume there is still a way to do this - can someone please tell me the correct syntax for Nix 2.18.1?What makes things worse is that I cannot start playing around with home-manager and flakes, because
home-manager switch flake .
seems to usenix flake
internally, which leads to errors instead of results. - Getting started with NixOS - looking for tutorials
I heard a lot about the concepts of nix and NixOS and I'd love to try it.
After installing the VirtualBox demo, I keep getting stuck with every tiny step I take, though.
So I was wondering if there are any tutorials for beginners that you can recommend?
I couldn't find anything on the internet - everything that looks like a tutorial presumes a lot of things everybody seems to know about nix, so no need to explain those.
Where can I find those explanations to make the first baby steps with NixOS?
To put it in other words: Where is NixOS for dummies?
- Can We Nixify Lemmy's Dev Environment?
cross-posted from: https://infosec.pub/post/9428674
I had the (perhaps foolishly ambitious) idea of creating a rolling fork of Lemmy with the intent of modifying the codebase for use in an open source pub sub implementation of retail inventory. But I have to get standard Lemmy working first...and I like to use Nix for everything I do in the dev world (where feasible).
So, I forked the repo and was immediately brought into dev environment hell.
They only offer a choice between:
A.) Docker B.) Ansible C.) Building from scratch.
Two hours of fighting with the scratch build instructions and I eventually had to admit defeat due to some vague dependencies (and general malaise). Though I have completely flakified my Purescript and Haskell dev environments, I have found Rust to be a lot more challenging even on simple projects.
Anyway, I decided to come here to ask: **How easy would it be to flakify the Lemmy repo to add a fourth build option for those of us in the Nix world? **
Can I reference the build instructions from nixpkgs to get close to my intended goal? I need all of the help I can get. Be as pedantic or defeatist as you will. I currently have no skin in this game and merely want to help the Lemmy devs welcome people that are more nixy like myself (if nothing else).
- Say Goodbye to Containers | Ephemeral Environments with Nix Shell
YouTube Video
Click to view this content.
- Replacing docker/podman with Nixos?
I setup a next.js project with pkgs.mkshell, and used nix develop to automatically build the project. However, when I leave the shell, the files persist. How should/can(?) I setup my shell.nix so that files in the directory it drops down into are automatically removed when leaving the ephemeral shell?
- How to get KDE Plasma 6?
Hey guys, I'm pretty new to Nix and NixOS and one of the reasons I installed it is because I know there's some way to install the KDE 6 Beta before the official stable release. I wanted to use the kde2nix overlay, but appearantely KDE 6 has been merged into the official nixpkgs repository. How do I switch from Plasma 5 to 6? I'm already on the unstable channel if that matters.
Thanks in advance.
- Could Nix os be like active directory on Linux?
So I've been looking into Nix and it seems like a pretty cool way of managing machines. However, I'm curious about how well it can manage user authentication. Theoretically one should be able to setup the equivalent of roaming profiles with rsync and some sort of authentication server but I haven't seen a lot of information on this topic.
Anyone used Nix in a group or company setting? If so, how did it work?
- Nixpkgs merge bot testing and plandiscourse.nixos.org Nixpkgs merge bot testing and plan
After receiving a lot of concerned feedback in a previous attempt, it’s time to clear things up and give it another chance. Starting today, the Nixpkgs merge bot will be enabled in dry-run mode. This means that it is not privileged to actually merge anything at all just yet, and instead only print...
- how to / best practices for setting up and tracking a Python project with nix flakes
I want to start a new project, and I want to try to handle all the reproducibility / "containerization" in nix instead of dockerfiles. I see some examples online but I think they're including more uncommon procedures and/or don't do things the "nix" way.
What's the right way to manage a simple python project? Should I just make a derivation.nix for use in nix-shell -p and have the ephemeral shell be my container? Can/should I do it with nix flakes instead? What would a simple nix flake look like that:
pulls an initial python repo from github
possibly executes whatever build instructions might be included
extends other system packages or other versions of the same python package,
has local area network access,
and GPU access
- How to enable system theme for Firefox?
cross-posted from: https://feddit.de/post/7895009 >I'm a semi-recent NixOS user and one thing that bothers me since the beginning is that when I change the Gnome theme (between light and dark), Firefox doesn't adapt. The system theme in Firefox is enabled, but it always displays the light theme, no matter what theme is selected in Gnome. > > Internet search, including searching through NixOS discourse, packages, options and Nixpkgs repo surfaced a solution. > > Any ideas or tips how to achieve system theme integration for Firefox on NixOS? > > NixOS 23.11 / Gnome 45 / sway
- [hyprland] My NixOS Configuration
Plenty of nix'd config, nix-colors theming for most applications. I've only been using linux for around 6 months, NixOS has really clicked with me.
My config might be sub-optimal in areas, but its gone through some heavy changes since its inception.
- Installing NixOS made my Windows Dual Boot fail
I've probably parsed dozens of pages now, including the "Dual boot NixOS and Windows" page on nixos.wiki, and not really sure what the best steps are since most seem to leverage the fact that everything is on a single partition. My windows lives on a physically separate drive than NixOS, so osprober does not detect the windows partition at all. I tried to go down the route of grub-mkconfig but that doesn't seem to be a nix package and I couldn't mount my Windows bootloader as it is NTFS. Is this even possible with this configuration?
My next step was going to be to physically disconnect each of my disks/NVME, nuke everything bit by bit, then only connect the disks I want and install each OS with it's specific disk connected.
- NixCon North America 2024 is happening on March 14th and 15th in CA, USA. | Call for Proposalschaos.social NixOS (@nixos_org@chaos.social)
Attached: 1 image 🗓️ Mark your calendars! NixCon North America 2024 is happening on March 14th and 15th in CA, USA. Submit your talk or workshop proposal before December 31, 2023, 11:59 PM PST. Be a part of this exciting event! More details at: https://discourse.nixos.org/t/nixcon-na-2024-call-for...
cross-posted from: https://programming.dev/post/7531089
> 🗓️ Mark your calendars! NixCon North America 2024 is happening on March 14th and 15th in CA, USA. Submit your talk or workshop proposal before December 31, 2023, 11:59 PM PST. Be a part of this exciting event! More details at: https://discourse.nixos.org/t/nixcon-na-2024-call-for-proposals/36491 > > > !
- Can you setup garbage collection to delete every other generation or every other N generations after a certain limit has been reached?
I see you can delete everything older than some period of time, but what if I want some older than a year? Or should it be interpreted that: whatever build configuration was used, it is tested thoroughly at that point, and it would be better to rebuild from a nix configuration stored on git?
- First Time NixOS setup help installing basic apps, dependencies, and themes
Edit: my issues came from copying source .nix configurations for the pig manager, not configurations that I would include on my computer. Finding how to include what where was much easier with search.nixos.org
Hi, I've finally cleansed my system of windows and switched fully into nix. I want to learn this OS the right way, but have ran into some noob troubles. Any help would be greatly appreciated. Ideally, these changes are things I would include in my configuration.nix
- How to install electrum wallet on nixos? I found this default.nix for electrum and thought it would be as easy as
nix-build default.nix
but was mistaken. It says " cannot evaluate a function that has an argument without a value ('fetchurl') Nix attempted to evaluate a function as a top level expression" but on a later line that value is inputted to the function (if I understand right)
>
src = fetchurl { url = "https://download.electrum.org/${version}/Electrum-${version}.tar.gz"; sha256 = "sha256-BxxC1xVKToUjgBo4mEeK9Tdhbd/+doHcTTJsXDtaELg="; };
- How to install KVantum Theme Manager? I was following this guide and tried to add gcc/g++ and the x11 package dependencies but I get undefined variables for the x11 libraries. Some recommend using stdenv.mkDerivations but I haven't used that much nix before so I'm not certain if I should be going down that rabbit hole
- How to install electrum wallet on nixos? I found this default.nix for electrum and thought it would be as easy as
- New Nix Wiki: NixLang Wiki
Came across a new nix wiki attempt. The announcement post is made on discourse with high skepticism.
But I really like it for two reasons:
- For now, its incredibly informal and the barrier to entry is low. And because I can make edits directly in the web interface, it felt easy to contribute.
- The creator mentions wanting this to be like the Arch wiki. In other words, contain information useful to nix users, but not necessarily nix specifically.
I was able to contribute a new article about distrobox, a tool I discovered and made a post about here a month or so ago.
Maybe we don't "need" another wiki, but the opportunity to contribute really made this one stand out to me. In case you all might want to contribute or learn something, I thought I would share.
- What should manage your xsession?
I'm conflicted on what should handle my login manager, desktop environment, and window manager. What are the pros and cons of doing it from a nixos configurations versus a home manager configuration?
- Flakes use in home manager help required
I want to use Plasma-manager in my system. I have enabled flakes in configurations. Now what to do to use it. The output generated by tool rc2nix can be copied through terminal but when i put that in home.nix , it says that plasma is not available which is true but then how do I use this tool. flake file.
- Providing Runtime Secrets to NixOS Services with Agenixlgug2z.com Providing Runtime Secrets to NixOS Services
In my last post, I shared how to get a working instance of Nitter deployed on NixOS, but requested advice on how to best automatically provision the guest_accounts.json runtime secret file on the target server. A number of folks reached out to me on Mastodon (thanks @vt52@ioc.exchange, @aynish@merve...
- Search (and install) previous versions of nix packages easily
I've made a fun little project inspired by this (except it's not updated any more).
It provides easy instructions for installing old versions of packages, it takes them straight from the official nixpkgs repo.
Example: https://history.nix-packages.com/package/dotnet-sdk_3/3.1.426 (.NET SDK 3.1 actually prompted the creation of this tool, I needed it for one old project).
Each detail page provides instructions on how to install the package using
nix-shell
,nix-shell
withshell.nix
file,configuration.nix
andnix-env
.The design is based on https://search.nixos.org (because I suck at graphical design).
Do let me know what you think!
- Need to run something and nix just isn't cutting it? No worries, distrobox will save the day!
I made a post a while ago asking what you do when NixOS isn't cutting it. You need a package that isn't available as a flatpak/appimage or already in nixpkgs. You don't want to build from source, because it's either too difficult or too time consuming. One suggestion was containerization or virtual machines, but those seemed too cumbersome. Well, distrobox is the tool that fixes it.
Distrobox is a shell script that wraps over docker/podman to run a container of a distribution of your choice. But it does it behind a very high level API, and integrates the container environment seemlessly with your host environment. It is seriously as easy as this, if you need to install something with apt inside debian.
$ distrobox create -n my_debian --image debian:latest $ distrobox enter my_debian
And bang, your in a debian container and it won't even feel like it. It automatically integrates your shell environment and maps your root directory inside the container (or something like that.) You seriously wouldn't know unless youneofetch
. Best part is that since everything is in the nix store, every program in your environment should work, for the most part, inside this container. I've not noticed problems yet.Tada!
apt
is available in this environment and you can install what you need. Then you can run it while inside the container. From the host machine, outside the container, you can run it directly too. Say you installed programX
in debian:$ distrobox enter my_debian -- X
And it will just run the command and send you back to the host machine.In the case of docker, you can type
docker ps
and it will show you your debian imagemy_debian
listed.There's two more things I want to do to really polish this workflow. The first is to change my shell prompt so I know that I'm actually in debian without typing neofetch! Inside the box the variable
CONTAINER_ID
is set and the hostname is modified. I've adjusted my starship prompt to look like this when inside the box:distrobox:my_debian ~ $
And lastly, I really want to blur the lines. If I install X in debian, I want to just call it directly from the host asX
, not invoke my debian instance withdistrobox enter
.When you type
X
and the program is missing, bash (and fish and zsh I'm sure) runs a hook that you can look at by typing$ declare -p -f command_not_found_handle
By overriding this, you could first have it try the inside container if it can't find the application in the host container, like so.command_not_found_handle () { distrobox enter my_debian -- $@ }
This is not a perfect solution, but I'm still experimenting with how to integrate this both seamlessly and also not accidentally run things inside debian and not realize it. If you have suggestions for how to improve handling calling commands from the outside environment, please share. Best case might just be adding aliases for programs explicitly. For example, `alias X=distrobox enter my_debian -- X.Anyway, distrobox is the solution! This is one more barrier removed that was preventing me from moving my main computer over to NixOS. I'm so happy to have found this and wanted to share.
- Any flutter devs got a build environment working?
I was trying to use a flake with nix-pkg to set up a flutter dev environment but it just wouldn't stick, and a lot of the examples online are quite old and not documented well for a nix noob like myself.
Cheers folks!
- Setting Up a NixOS 23.05 Development VM on Hetzner Cloud with nixos-anywhere
YouTube Video
Click to view this content.
- A sane, batteries-included starter template for running NixOS on WSL
YouTube Video
Click to view this content.
- How to setup nixos with external encrypted raid
My server is currently running fedora and it has a encrypted raid attatched. Now i wanna move my server to nixos but i cant find anything on how to automount it. Any advice ? Thanks for your time and have a nice day!
- Let NixOS or Home-Manager manage X, not both
I've been spending a couple weeks unable to modify my system, because using my window manager was ungodly slow (like 1fps.) Luckily NixOS lets you pick a previous generation to load so I could make changes, build a new generation, and try again.
It took me too long to find, but I realized I had both the x session managed by both nixos and home manager. Removing this fixed the problem. I assume this had 2 xsessions open and they were competing for resources or something. Be cautious! :)
- How do I share my flakes for external projects?
Every now and then I see a program that doesn't have a default.nix or flake.nix in the source, doesn't have an entry in nixpkgs, and otherwise can't find a derivation for. So I write them myself.
What's the best way to share these? Should I contribute to nixpkgs? (does this count if I'm making flakes?) Do I maintain a single repo for each program? Or do I create a repo with a collection of flakes? Something else?
- How is the situation of nix/nix-darwin/home-manager on macOS?
Used nix last year but dropped it after home-manager decided to unlink the apps from the Applications directory.
How is the current situation on usability of nix-Darwin + home-manager + brew?
Packages still fails to get indexed correctly in spotlight? I really like a fully repro environment but the fact that the usu ability was low bothered me a lot.
- How do you manage the software on your personal workstation?
I recently wanted to try out (aider)[https://aider.chat], and ran into a problem that I continually run into: how do I install one-off, experimental software into my environment, without being a nix master, or spending an extreme amount of time on every new package.
In this case, it is a new python package available in pip. It isn't available in nixpkgs, and isn't nixified. pip2nix doesn't work on arm64 Macs (bug here)[https://github.com/nix-community/pip2nix/issues/88], so I can't use that to try and create a flake that works with this package. It isn't using poetry, so poetry2nix is out.
How are you dealing with this problem? Are you all experts in nix, and writing flakes for every piece of software that you want to play around with? Do you have a "dirty" part of your environment that you install this kind of stuff into? (I looked into using pipx to install this, however that (also has a bug)[https://github.com/NixOS/nixpkgs/issues/171429] in nixpkgs.)
Thoughts?
- [Solved] Help with PHP and Composer
Hi there! I'm trying to make php and composer work. I have this in
environment.systemPackages
:(pkgs.php82.buildEnv { extensions = ({ enabled, all }: enabled ++ (with all; [ xdebug redis ])); extraConfig = '' memory_limit=2G xdebug.mode=debug ''; }) php82Extensions.redis
The problem is that while running
php -m
correctly prints that redis extension is installed,composer
does not, because it uses a different php:file $(which php)
prints the path/nix/store/igx8j4qjxy9jyj8kjyccwarnzqq5vsml-php-with-extensions-8.2.9/bin/php
cat $(which composer)
shows that it's a wrapper for'/nix/store/lv4prxa52zifr54ws56iz3b9kdhs1b5w-php-with-extensions-8.2.9/bin/php' --add-flags '/nix/store/avqj0662f4gg2s875zlbbjajx6fm6bl0-php-composer-2.5.5/libexec/composer/composer.phar'
Note that the path to php is different. Is there any way to correct it on my side? I'd like to avoid having to install composer manually
- What have you been working on?
Hi all, I've been getting into nix lately (I've been posting here frequently) and wanted to know what projects everyone is working on. Are you trying to integrate nix into an existing project? Contribute to nixpkgs? Experiment with your configs?
- Using Nix to Declare Your Browser!m.youtube.com Using Nix to Declare Your Browser!
Discord server: https://discord.gg/AqHbaeK43bFirefox-addons flake: https://gitlab.com/rycee/nur-expressions/-/tree/master/pkgs/firefox-addons?ref_type=headsC...
Short video from Vimjoyer on how to setup a firefox install using home manager and flakes. In particular, the focus of this video was how to use an external flake as a source for firefox extensions, since they aren't available in nixpkgs.
- Building websites using Nix Flakes and Zola
I came across this article when wondering how to integrate the "building" aspect of nix (that is, not just a devshell) with static websites or other projects that involve some output that is not an executable.
This article also talks about adding inputs from GitHub that aren't necessarily flakes. I've used this myself to pull some example configurations for certain programs that I haven't felt like tinkering with myself yet.
- If you're worried about the transition to NixOS, try home-manager.
I'm been wanting to move over my main desktop for almost a year now. But from 3+ years of tinkering, installing applications, and configurations Ive been super hesitant. The jump from Ubuntu to NixOS would be a big one. I have a laptop running nixos thats given me some exposure to the nix language, but when it comes to my main rig, I still have the worry of "what if something I need wont be available?" and "what if I forget something?"
Well I finally tried home manager and wow, its the absolute perfect way to slowly transition to nixos. I'm slowly going through my package managers (cargo, npm, pip, apt, snap) and checking for applications that I can just drop into my home.nix. And every now and then I see an app I cant install (say, vtracer from cargo, very cool app). Well, I just make a mark and eventually I'll build my own derivation around it.
Home manager has been easing my worries as I make the transition. For those of you also unsure, I recommend integrating with home manager. You can do such small jumps at a time, no need to go full blown nix all at once.