Nix / NixOS

2616 readers
26 users here now

Main links

Videos

founded 2 years ago
MODERATORS
1
 
 

Forgive me if this is not the place to ask this question. If that is the case, I would appreciate some help finding the best place to ask.

I wish to start hacking together a wayland compositor in C and I figured wlroots would be a reasonable place to start. I'm using NixOS with flakes and wish to make a dev shell. Here is the flake.nix that I wrote and figured would work:

# flake.nix
{
  description = "wayland compositor";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      devShells."${system}".default =
        (pkgs.mkShell {
          buildInputs = with pkgs; [
            # c tools
            clang-tools
            gcc
            glibc
            gnumake
            gdb
            # wayland tools
            wayland
            wayland-protocols
            wayland-scanner
            wlroots
          ];
        });
    };
}

The problem I am having is that I have to include wlroots headers using:

# some c file
#include <wlroots-0.19/wlr/backend.h>
# note the prefix "wlroots-0.19/"

which differs from how other projects include the shared library on a non-NixOS system. For example, in tinywl, the example compositor in the wlroots repo, wlroots headers are included like this:

# tinywl.c
#include <wlr/backend.h>

Furthermore, even if I do include wlroots headers using the first path, I am unable to build anything since those headers have includes like in tinywl.c.

I might be a little bit out of my depth and that's okay, but I was hoping to have fun hacking together a wayland compositor.

Any help would be greatly appreciated.

2
3
 
 

Currently in the process of writing this, but I felt like the current progress already has some stuff worth sharing. I'd be happy for some feedback and possible improvements!

4
 
 

Everything you need to know about declarative containers in NixOS with a simple example to demonstrate logging in, mounting volumes and forwarding ports.

It's a really elegant way to isolate different services running on a single server. Very well written!

5
 
 

Here it is https://codeberg.org/gmg/concoctions/src/branch/main/sh-scripts/nixos-rebuild

(if you try it and find any bugs, please let me know)

edit: I didn't realize the screenshot shows just instead of nixos-rebuild... that runs a script ("recipe") that calls nixos-rebuild so the output shown is from the (wrapped) nixos-rebuild

6
7
8
 
 

I'm trying to get my scripts to have precedence over the home manager stuff.

Do you happen to know how to do that?

(not sure it's relevant, but I'm using home-manager in tumbleweed, not nixos)


edit:

Thanks for the replies - I finally got time to investigate this properly so here's a few notes (hopefully useful for someone somehow).

~/.nix-profile/bin is added (prepended) to the path by the files in /nix/var/nix/profiles/default/etc/profile.d/, sourced every time my shell (fish, but it should be the same for others) starts (rg -L nix/profiles /etc 2> /dev/null for how they are sourced).

The path I set in homemanager (via home.sessionPath, which is added (prepended) to home.sessionSearchVariables.PATH) ends up in .nix-profile/etc/profile.d/hm-session-vars.sh, which is sourced via ~/.profile once per session (I think? certainly not when I start fish or bash). This may be due to how I installed home-manager... I don't recall.

So... the solution is to set the path again in my shell (possibly via programs.fish.shellInitLast - I din't check yet).

9
5
submitted 2 weeks ago* (last edited 2 weeks ago) by mobsenpai@lemmy.world to c/nix@programming.dev
 
 

[SOLVED] Exact problem as this archwiki forum post

I have also tried everything and at last here I am asking for any help, otherwise I don't think I would be able to continue using Linux on this laptop. I've tried everything from changing the kernel package to enabling all firmwares to using every kernel parameter I can find everything, nothing says any error or something anywhere. Only error i can find is hci device capabilities -22

Edit: The patch i needed was to add the driver info in btusb.c file. In nixos this is how you do it

  boot = {
    kernelPatches = [
      {
        name = "add-realtek-8852ce-btusb";
        patch = ./btusb.patch;
      }
    ];
}

first what you should do is git clone the linux kernel version you are using check using uname -r for me it was 6.12.(whatever, doesn't matter)

git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git v6.12

then find the btusb.c file in drivers/bluetooth/ and add the line

{ USB_DEVICE(0x13d3, 0x3612), .driver_info = BTUSB_REALTEK |
BTUSB_WIDEBAND_SPEECH },

after these lines

static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x0cb8, 0xc558), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },

now we have made chages to this file right? it will be shows in git diff, so now you should be able to do git diff > btusb.patch this will create a .patch file, now copy this file to wherever folder you put the nixos configuration in, most likely /etc/nixos if not using custom config. Thats it!, now rebuild the configuration and DONE. props to @Maiq.

Author of patch: vedantsg123

I will try to get this patch upstream to not having to do this manually.

10
11
 
 

I'm trying to patch qt5ct and qt6ct with their kde patch, which im doing like so:

  home.packages = with pkgs; [
    kdePackages.qt6ct.overrideAttrs (finalAttrs: previousAttrs: {
      patches = [
        fetchpatch {
          url = "https://aur.archlinux.org/cgit/aur.git/plain/qt6ct-shenanigans.patch?h=qt6ct-kde";
          hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
        }
      ];
    })

    libsForQt5.qt5ct.override {
      patches = [
        fetchpatch {
          url = "https://aur.archlinux.org/cgit/aur.git/plain/qt5ct-shenanigans.patch?h=qt5ct-kde";
          hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
        }
      ];
    }
  ];

but that im getting this error

error: A definition for option `home-manager.users.claymorwan.home.packages."[definition 10-entry 3]"' is not of type `package'. Definition values:
       - In `/nix/store/2p2nainh0h91ijj2724bpg1pc1z8ska5-source/NixOS/modules/home/qt.nix': <function, args: {fetchurl, lib, mkDerivation, qmake, qtbase, qtsvg, qttools}>
12
 
 

My config: https://github.com/Aesistril/nixos-config

I am on Microsoft Surface Pro 9. It requires a custom kernel which needs to be compiled in the case of NixOS.

I added the kernel to my config according to the instructions provided in nix-hardware repo. Then I installed nix package manager on Fedora and started compiling in the background while I did some other work. The idea was to push it to cachix so my NixOS install could pull it without needing to compile.

The problem is kernel being compiled on different installations of nix package manager results in different hashes, even when they are using identical configs. It does not pull from cachix which i am sure i set up correctly.

https://aesis-cache-surface.cachix.org/ is my cache.

As a test I did a full, successful, build. Pushed the results to cachix. mv'd the resulting /nix directory to /nix.success.

/nix/store/yg3hr2jl4bq0c6bkchajnszza9vi9vm8-linux-6.15.9 is the result of nix.success and the version stored in the cache

And after running mv I did a second build. Instead of pulling from cachix; it started building this, which is the same thing but with as different hash.

/nix/store/873nppq3pby37w9jxiw6vbv87fczynx2-linux-6.15.9.drv

And yes the git tree was clean and there was absolutely no warnings during nix build. It just misses the cache for some reason

Unrelatedly, nix pulls gnome-desktop even when my DE is set to KDE. I am not sure why.

13
 
 

I'm currently trying to package a python package called entangled.py, two of its dependencies aren't in the nixpkgs so I also packaged them. Now I'm trying to package the entangled with these two local packages but idk how to actually use them, rn i do this (using buildPythonPackage):

buildPythonPackage rec {
  # ...
  dependencies = [
    py
    filelock
    rich
    rich-argparse
    tomlkit
    copier
    (callPackage ../brei/package.nix)
    pyyaml
    (callPackage ../repl-session/package.nix)
    msgspec
    click
    rich-click
    typeguard
    watchfiles
  ];
  # ...
}

but it returns me this error:

error:
       … while evaluating the attribute 'drvPath'
         at /nix/store/ln4j1iqnnzs2ynx2cr88bdh65fmds2aq-source/lib/customisation.nix:446:7:
          445|     // {
          446|       drvPath =
             |       ^
          447|         assert condition;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: Dependency is not of a valid type: element 7 of propagatedBuildInputs for python3.13-entangled-cli-2.4.

obviously this is only for testing if the package builds and works correctly, i don't want to send a broken package

SOLUTION: kinda stupid of me lol, i need to add an empty set after the path like so: (callPackage path/to/package { }) also if u're using with import <nixpkgs>;, remove that too

14
 
 

TL;DR: Since April 2025, The NixOS Foundation and Framework are officially partnering to improve NixOS support on Framework devices. This formalizes earlier community efforts, enabling selected community members to contribute to testing, documentation, and support for current and future hardware.

15
16
 
 

Just updated my flake inputs for the first time this year and had to tinker for a bit.

The API for persisting files in the home directory changed, now disallowing the persisting directory to point to a home.persistence."/persistentPath/home/paulemeister/" as it now calculates that path automagically, when using home.persistence."/persistentPath

Also now the hm module is automagically imported through the nixos module. Gotta remove the import in you hm config.

It's really nicely done though with assertions. Just a heads up

17
18
 
 

Hi everyone. It has been a while since I started using Linux, so I got at least a nice amount of knowledge on Linux and shell but I can be considered as new when it comes to Nix. I am learning Nix and I have learned enough to move to flakes and set up a very basic home manager configuration but my setup is probably really weird compared to NixOS masters. The problem is my laptop shuts itself down in heavy tasks like gaming (My laptop is trash lol). I assume this is because of overheating because the heat goes really up whenever this happens. Do you guys have any solutions to that? And my second problem is I don't really know how to set up drivers on NixOS but I can tell something is wrong about my gpu drivers. My gpu is AMD Radeon 610M [Integrated] (its pretty trash yeah but its a school laptop) and I want to set up drivers and be able to play games with Proton (So I gotta enable this 32bit thing as well). My cpu is AMD Ryzen 3 7320U (8) @ 4.15 GHz and I have no idea if my cpu needs extra drivers. Any help will be appreciated. Thanks for reading

19
 
 

cross-posted from: https://lemmy.ml/post/40689539

I decided to switch to NixOS on my desktop and so far it's been great, I love being able to build out my config in the Nix file, but there is one thing I've not been able to figure out how to change. After a period of inactivity, the computer suspends (or hibernates?) and basically turns off (all the fans and lights turn off and it disconnects from the network, I don't know if it's saving the state in RAM of the drive). How do I get it to not do that and just lock the desktop and turn off the screen after inactivity? I'm using KDE Plasma and I've tried different kinds of configurations that build successfully but still don't prevent it from going offline.

20
6
submitted 1 month ago* (last edited 1 month ago) by claymorwan@lemmy.blahaj.zone to c/nix@programming.dev
 
 

I'm starting to have a lot of flake inputs in my flake.nix file, and it's starting to get really cluttered. I'm wondering if there's a way to separate my inputs into multiple files so it looks cleaner. I've tried to look it up but couldn't really find anything abt it

Edit: Well as it turns out it's not something possible yet, apparently the flake.nix file isn't parsed like regular nix files and doesn't support stuff like import

21
3
New to Nix (piefed.social)
submitted 1 month ago* (last edited 1 month ago) by Pamboo@piefed.social to c/nix@programming.dev
 
 

I have never installed a nix package on Steam Deck under SteamOS before. I followed his instructions from this website , everything is ok without problem, then I installed an app with this command nix-env -iA nixpkgs.mullvad-vpn. When I finish installing an app, I open Mullvad GUI, I see a message

Unable to contact the Mullvad system 
service, your connection might be unsecure. 
Please troubleshoot or send a problem 
report by clicking the "Learn more" button.  

I don't know how to fix this issue

My Nix version is 2.32.4 and my SteamOS version is 3.7.13

22
23
 
 

Related HN thread discussing NixOS:

24
25
6
submitted 2 months ago* (last edited 2 months ago) by claymorwan@lemmy.blahaj.zone to c/nix@programming.dev
 
 

I've been trying to run native linux games with lutris but can't get it to work. As far as ik, i can either use steam-app in my termianl, which works, or I can use nix-ld which i did setup and also works when running the game's executable from the terminal

I've setup nix-ld like so:

  programs.nix-ld = {
      enable = true;

      libraries = [(pkgs.runCommand "steamrun-lib" {}
  "mkdir $out; ln -s ${pkgs.steam-run.fhsenv}/usr/lib64 $out/lib")];
};

But for some reasons, when running the game's executable in lutris, it just fails instantly, and I'm kinda out of ideas, if anyone knows what to do that'd be real helpful please

Edit: Ok well apparently it just solved itself ??? I realized i could install lutis using programs.lutris.enable = true; instead of just putting it in home.packages, and apparently it fixed the issue. Idk why or how but ig if u use home manager, insall lutris like so

view more: next ›