In NixOS, I'm running pipewire 1.0.3 currently. How can I test running 1.0.2 without…
- User
In NixOS, I'm running pipewire 1.0.3 currently. How can I test running 1.0.2 without changing the whole system to boot a previous config?
- Assistant
To test an older version of Pipewire, or any package, on NixOS without reverting your entire system configuration, you can take a customized approach. For Pipewire 1.0.2, here are a few strategies you could use, noting that precise version numbers might require adjustments based on the availability in your Nixpkgs channel or overlays.
1. nix-shell
A
nix-shellis a great tool for creating temporary environments. This approach is useful for running software without installing it system-wide. However, for a service like Pipewire, which integrates deeply with the system, anix-shellmight not provide a full test environment as it would for simpler applications. Despite that, you can try to usenix-shellwith a specific version by creating a customshell.nixfile or directly from the command line, specifying the older package version you wish to test, assuming you have a definition or overlay for the older version.For a simple application, the approach could look like this, but remember, for Pipewire, this is more illustrative than practical:
nix-shell -p 'pkgs.pipewire.override { version = "1.0.2"; }'This command assumes you have an override or custom derivation for Pipewire 1.0.2.
2. Using Nix Environments
Nix environments, created with
nix-env, allow for installing packages in a user's environment without affecting the global system state.nix-env -iA nixos.pipewire_1_0_2This command assumes there is an attribute
pipewire_1_0_2available in your Nix channels or overlays pointing to the 1.0.2 version. You might need to create a custom package expression if this is not the case.3. Custom Overlay
An overlay can modify or add packages within your Nixpkgs collection. You can create an overlay to include Pipewire 1.0.2 specifically. Here is a small example of what the overlay file could look like:
self: super: { pipewire_1_0_2 = super.pipewire.overrideAttrs (oldAttrs: rec { version = "1.0.2"; src = super.fetchurl { url = "mirror://pipewire/pipewire-${version}.tar.gz"; sha256 = "0y8..."; # Proper sha256 for the 1.0.2 source tarball }; }); }Add this overlay to your Nix configuration (e.g., in
/etc/nixos/configuration.nixor your user's Nix configuration), and then you can install Pipewire 1.0.2 usingnix-envor test it in anix-shell.4. System Rollback for Testing
Although you mentioned not wanting to change your system configuration, for completeness, NixOS does offer the ability to rollback system generations. This doesn't install the package for a test but allows you to "test" the system at a point in time when the older version was in use. Use
sudo nix-env --list-generations, followed bysudo nix-env --switch-generation <generation number>to rollback. Remember, this affects the whole system.A Note on Desktop and System Services
Testing different versions of a system service like Pipewire isn't as straightforward as other packages because of how it integrates with the system. Swapping the version might require adjusting the system configuration and possibly restarting the service or even your session. Keep this in mind as you attempt to test different versions.
If your motivation is testing for development, debugging, or similar purposes, consider also setting up a NixOS VM or container for a more isolated environment. This might offer a more stable ground for your experiments without affecting your primary system.