How to try a PR

Good day,

3 day old Nixos newbie here…
How can I try a PR that has not yet been merged? I’m after this one: nixos/plasma5: make it run using systemd and wayland by peterhoeg · Pull Request #117102 · NixOS/nixpkgs · GitHub

I’ve tried following this guide :

(snippet from configuration.nix)

  nixpkgs.config = {
    packageOverrides = pkgs: {
      pr117102 = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/2103b62c9f5a3657c8ea588730e3079a67164cdb.tar.gz") { config = config.nixpkgs.config; };
    };
  };

  environment.systemPackages = with pkgs; [
    vim
    wget
    curl
    firefox
    htop
    pr117102.plasma5
  ];

But nixos-rebuild switch complains about

error: attribute 'plasma5' missing at /etc/nixos/configuration.nix:125:5

Which is exactly the pr117102.plasma5 line.
Judging by the PR, I see that it changes module, not a package but not sure how config nixos to use the module source from the PR.

Any help will be greatly appreciated.

1 Like

Just leave your config as is and run

nixos-rebuild -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/pull/117102/head.tar.gz ...

This PR is quite old though and still targets 20.09, so your configuration might need a little adaptation.

3 Likes

Thanks for replying.

Running this now and indeed it pulls bunch of older stuff which is not what I’m after.
In the one-before-last comment in the PR, they say ‘Plasma with Wayland works wonderfully here with latest unstable and this PR applied’.

I’m already on the latest unstable as of yesterday. How can I try the same setup? - the latest unstable + PR.

I would say the best way is to rebase PR against NixOS version you want and then run

nixos-rebuild -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/pull/117102/head.tar.gz ...

I have written this page Nixpkgs/Reviewing changes - NixOS Wiki

4 Likes

Save this as nixpkgs-pr.nix

# Idea by Bas van Dijk (https://www.youtube.com/watch?v=J4DgATIjx9E)
{ pr }:
let
  pkgs = import <nixpkgs> {};
  patches = [
    (builtins.fetchurl {
      url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/${pr}.patch";
    })
  ];
in pkgs.runCommand "nixpkgs-PR${pr}" { inherit patches; } ''
  cp -R ${pkgs.path} $out
  chmod -R +w $out
  for p in $patches; do
    echo "Applying patch $p"
    patch -d $out -p1 < "$p"
  done
''

and then use

nixos-rebuild -I nixpkgs="$(nix-build nixpkgs-pr.nix --argstr pr 117102)" ...

Maybe this will become more ergonomic in the future:

4 Likes

Thanks everyone for the answers. Eventually @Artturin’s way worked.

What I did is forked current nixpkgs, cherry-picked the PR commit, and then used the tarball URL as per Artturin guide.

Simply passing my tarball URL as -I http... to nixos-rebuild... kept complaining that it can’t recognize new module options introduced by the PR.
So changing the configuration.nix file, besides actually working, has an additional benefit of freeing me from remembering to drag command line switches around.

The relevant snipped from my configuration.nix is below.

  # BEGIN plasma test
  # https://github.com/NixOS/nixpkgs/pull/117102
  # https://discourse.nixos.org/t/how-to-try-a-pr/15410/5
  disabledModules = [ "services/x11/desktop-managers/plasma5.nix" ];

  imports = let
    pkgsReview = builtins.fetchTarball {
      url = "https://github.com/haizaar/nixpkgs/archive/plasma_systemd_21_11.tar.gz";
    #pkgsReview = ../nixpkgs;
    };
  in [
    (import "${pkgsReview}/nixos/modules/services/x11/desktop-managers/plasma5.nix")
    ./hardware-configuration.nix
  ];
  services.xserver.desktopManager.plasma5.runUsingSystemd = true;
  services.xserver.displayManager.sessionPackages = [
    (pkgs.plasma-workspace.overrideAttrs
      (old: { passthru.providedSessions = [ "plasmawayland" ]; }))
  ];
  # END plasma test

@Artturin With your method (and this example) I’m only overriding a single plasma5 module, right? The rest of definition will be taken from the current nix channel, right?

Yes

Posts must be atleast 20 characters

Maybe an RFC has to be written to promote the proper solution (patching nix flake inputs) until somebody with the appropriate skills in C++ is willing to pick this up?

The possibilites of working around the root problem unfortunately are endless.

1 Like

by patching flake inputs i assume you mean nixos: fix cross-compiling by using buildPackages for build-time lndir by ju1m · Pull Request #142273 · NixOS/nixpkgs · GitHub