Nix / NixOS

2752 readers
2 users here now

Main links

Videos

founded 3 years ago
MODERATORS
26
27
28
29
 
 

long story short: i have a surface tablet with an sd card in it. id like the sd card to hold /nix. i cant seem to rsync without (im guessing the links are expanding) the bigger drive (sdcard) filling up. thank you

30
 
 

I've got a local unstable package and I want it to always be at the latest commit from its source's upstream. For that I added passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; }; in the package, but when I build the package/install it, it doesn't update.

I don't wanna have to manually update the source's rev and hash, maybe I'm just not using it right ?

This is the package: https://codeberg.org/claymorwan/dotfiles/src/commit/9ca46a651a16a5dc85f35d3c0d19bcd03d692fdd/NixOS/pkgs/fluxer/default.nix

And this is how I install it in my config: https://codeberg.org/claymorwan/dotfiles/src/commit/9ca46a651a16a5dc85f35d3c0d19bcd03d692fdd/NixOS/modules/home/Packages/default.nix#L41

31
32
1
submitted 2 months ago* (last edited 2 months ago) by hallettj@leminal.space to c/nix@programming.dev
 
 

My wife brought home a TV from a thrift store. So I took the easy route of setting up a media center to make it play videos. I already had a headless Jellyfin server running on a small Beelink computer. I connected that to the TV, installed Kodi, installed the Yatse remote control app on my phone, and we're all set.

It took me some research and trial and error to get the remote control app connected with Zeroconf auto discovery working. So I thought I'd share what I learned. Here is my entire Kodi module:

{ pkgs, ... }:

{
  # Enable a graphical shell
  services.xserver.enable = true;

  services.xserver.desktopManager.kodi = {
    enable = true;
    package = pkgs.kodi.withPackages (
      kodiPackages: with kodiPackages; [
        jellyfin
        netflix
      ]
    );
  };

  # To view plugins available in nixpkgs run:
  #
  # $ nix repl
  # > pkgs = import <nixpkgs> {}
  # > builtins.attrNames pkgs.kodiPackages
  #
  # Or search for plugins on https://search.nixos.org/, and in the left-sidebar
  # under "Package sets" click "kodiPackages"

  services.displayManager.autoLogin = {
    enable = true;
    user = "kodi";
  };

  users.users.kodi.isNormalUser = true;

  # Allow reboot and shut down from Kodi UI
  security.polkit = {
    enable = true;
    extraConfig = /* javascript */ ''
      polkit.addRule(function(action, subject) {
        if (
          (
            action.id == "org.freedesktop.login1.reboot" ||
            action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
            action.id == "org.freedesktop.login1.power-off" ||
            action.id == "org.freedesktop.login1.power-off-multiple-sessions"
          )
          && subject.user == "kodi"
        ) {
          return polkit.Result.YES;
        }
      });
    '';
  };

  # Allow access to web UI & remote control API
  networking.firewall = {
    allowedTCPPorts = [
      8010 # the port I configured for "allow remote control via HTTP"
      9090 # also event server?
    ];
    allowedUDPPorts = [
      9777 # event server
    ];
  };

  # Allows Kodi to advertise to remote control apps using Zeroconf.
  services.avahi = {
    enable = true;
    publish.enable = true;
    publish.userServices = true;
  };
}

Kodi is a graphical shell. Like I said, this box was previously headless; so I enabled Kodi as my DE and set it up to automatically log in.

To make the remote control work there are some necessary settings changes to make in the Kodi UI. I had to connect a keyboard temporarily to set this up:

  • Go to Settings > Services
  • Enable General > Announce services to other systems (for Zeroconf auto discovery)
  • In Control enable:
    • Allow remote control via HTTP (match port number in NixOS firewall settings)
    • Allow remote control from applications on this system
    • Allow remote control from applications on other systems
  • I'm not sure if this is needed, but the Yatse docs recommend these settings in UPnP / DLNA for "some streaming cases":
    • Share my libraries
    • Allow remote control via UPnP

Declarative settings would be nicer, but there doesn't seem to be a NixOS module that does that yet. It's the same situation with Jellyfin.

33
34
 
 

NixOS config walkthrough around 7min mark.

35
36
37
 
 

A follow-up to my post last week, the title is a bit unfortunate but it is what it is.

Anyhow, here I set up a repository that defines one host using the dendritic approach in a very simple manner (plus another one before to introduce how flake-parts does this). It uses the package and service defined in another repository in Part 1, also linked in this post.

It only goes into the basics and is already long enough in my opinion, but I tried to write everything down to start with a clean base from scratch. There is a lot of room for improvement, but it should get the basics right.

38
 
 

I'm using xdg.dataFile in order to install krita plugin, the issue is that krita plugin need to have their content placed in the `~/.local/share/krita/pykrita" and cannot be put in subfolder. For now I'm doing

  xdg.dataFile = {
    "krita/pykrita" = {
      enable = true;
      source = pkgs.fetchFromGitHub {
        owner = "veryprofessionaldodo";
        repo = "Krita-UI-Redesign";
        rev = "df37ade2334b09ca30820286e3e16c26b0fbb4f8";
        hash = "sha256-kGs1K2aNIiQq//W8IQ2JX4iyXq43z2I/WnI8aJjg8Yk=";
      };
      recursive = true;
    };
  };

It's fine when i use a single plugin, but when a use multiple plugins i gotta use multiple fetchers which im not sure how to do. tried to do source = <fetcher 1> + <fetcher 2> which surprisingly builds but then the home-manager service fails

39
40
 
 

RESOLVED: see the edit at the bottom of the post for the solution.

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.

EDIT: Per this comment I just needed to add pkg-config to my flake and use pkg-config --cflags wlroots-0.19 to get the right flags for my C compiler. The program still failed to build but only because wlroots depends on the pixman library, so once I included that in the flake as well, compilation succeeded. My flake looks like this now:

{
  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 {
          packages = with pkgs; [
            # for wayland
            pixman
            wlroots
            wayland
            wayland-protocols
            wayland-scanner
            # for c
            pkg-config
            clang-tools
            gcc
            glibc
            gnumake
            gdb
          ];
        });
    };
}
41
42
 
 

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!

43
 
 

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!

44
 
 

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

45
46
47
 
 

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).

48
1
submitted 4 months ago* (last edited 4 months 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.

49
50
 
 

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}>
view more: ‹ prev next ›