Implement hybrid package management: stable + selective unstable
- Add nixpkgs-unstable input to flake.nix - Configure specialArgs to pass pkgs-unstable to all system configs - Update desktop/dev.nix to use windsurf from unstable packages - Create comprehensive documentation in README-hybrid-packages.md - Enable selective use of cutting-edge packages while maintaining system stability Usage: Add pkgs-unstable parameter to any .nix file and use pkgs-unstable.package-name Example: pkgs-unstable.windsurf for latest Windsurf editor
This commit is contained in:
parent
21830a1ba7
commit
c6430c0443
4 changed files with 149 additions and 2 deletions
117
README-hybrid-packages.md
Normal file
117
README-hybrid-packages.md
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# Hybrid Package Management: Stable + Unstable
|
||||
|
||||
This NixOS configuration uses a hybrid approach where the system runs on the stable NixOS 24.05 branch but can selectively use packages from the unstable branch when needed.
|
||||
|
||||
## How It Works
|
||||
|
||||
The `flake.nix` includes both stable and unstable nixpkgs inputs:
|
||||
|
||||
```nix
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-24.05"; # Stable base
|
||||
nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; # Unstable packages
|
||||
# ... other inputs
|
||||
};
|
||||
```
|
||||
|
||||
The unstable packages are made available to all system configurations via `specialArgs`:
|
||||
|
||||
```nix
|
||||
nixosConfigurations = {
|
||||
framework = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
pkgs-unstable = import nixpkgs-unstable {
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
};
|
||||
modules = [ /* ... */ ];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## Using Unstable Packages
|
||||
|
||||
### In System Configuration Files
|
||||
|
||||
To use an unstable package in any `.nix` configuration file:
|
||||
|
||||
1. **Add `pkgs-unstable` to the function parameters:**
|
||||
```nix
|
||||
{ config, pkgs, pkgs-unstable, ... }:
|
||||
```
|
||||
|
||||
2. **Use the unstable package:**
|
||||
```nix
|
||||
environment.systemPackages = with pkgs; [
|
||||
# Stable packages
|
||||
firefox
|
||||
git
|
||||
|
||||
# Unstable packages
|
||||
pkgs-unstable.windsurf
|
||||
pkgs-unstable.some-other-package
|
||||
];
|
||||
```
|
||||
|
||||
### Example: Current Usage
|
||||
|
||||
See `desktop/dev.nix` for a working example:
|
||||
|
||||
```nix
|
||||
{ config, pkgs, pkgs-unstable, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
# Stable packages
|
||||
nodejs
|
||||
rpi-imager
|
||||
|
||||
# Unstable packages
|
||||
pkgs-unstable.windsurf # Use windsurf from unstable
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
## When to Use Unstable Packages
|
||||
|
||||
Use unstable packages when:
|
||||
- A package is not available in the stable branch
|
||||
- You need a newer version with specific features or bug fixes
|
||||
- You're developing with cutting-edge tools
|
||||
|
||||
## Benefits of This Approach
|
||||
|
||||
1. **System Stability**: Core system components use stable, well-tested packages
|
||||
2. **Package Availability**: Access to the latest packages when needed
|
||||
3. **Selective Updates**: Choose which packages to get from unstable
|
||||
4. **Easy Maintenance**: Clear separation between stable and unstable dependencies
|
||||
|
||||
## Adding New Unstable Packages
|
||||
|
||||
To add a new unstable package:
|
||||
|
||||
1. Find the configuration file where you want to add the package
|
||||
2. Ensure the file accepts `pkgs-unstable` parameter
|
||||
3. Add `pkgs-unstable.package-name` to the appropriate list
|
||||
4. Test with `nixos-rebuild dry-run --flake .#framework`
|
||||
5. Apply with `nixos-rebuild switch --flake .#framework`
|
||||
|
||||
## Updating Packages
|
||||
|
||||
- **Stable packages**: Updated when you update the flake lock
|
||||
- **Unstable packages**: Updated when you run `nix flake update`
|
||||
|
||||
To update only unstable packages:
|
||||
```bash
|
||||
nix flake lock --update-input nixpkgs-unstable
|
||||
```
|
||||
|
||||
## Current Unstable Packages in Use
|
||||
|
||||
- `windsurf` - Modern code editor (in `desktop/dev.nix`)
|
||||
|
||||
---
|
||||
|
||||
This hybrid approach gives you the stability of NixOS stable with the flexibility to use cutting-edge packages when needed.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, ... }:
|
||||
{ config, pkgs, pkgs-unstable, ... }:
|
||||
|
||||
{
|
||||
|
||||
|
|
@ -6,6 +6,7 @@ environment.systemPackages = with pkgs; [
|
|||
(python3.withPackages(ps: with ps; [ pandas requests python-dotenv pip uv ]))
|
||||
nodejs
|
||||
rpi-imager
|
||||
pkgs-unstable.windsurf # Use windsurf from unstable packages
|
||||
];
|
||||
|
||||
programs.nix-ld.enable = true;
|
||||
|
|
|
|||
16
flake.lock
generated
16
flake.lock
generated
|
|
@ -52,6 +52,21 @@
|
|||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1753694789,
|
||||
"narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dc9637876d0dcc8c9e5e22986b857632effeb727",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"plasma-manager": {
|
||||
"inputs": {
|
||||
"home-manager": [
|
||||
|
|
@ -80,6 +95,7 @@
|
|||
"home-manager": "home-manager",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"plasma-manager": "plasma-manager"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
flake.nix
15
flake.nix
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/release-24.05";
|
||||
|
|
@ -15,10 +16,16 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixos-hardware, home-manager, plasma-manager }: {
|
||||
outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, plasma-manager }: {
|
||||
nixosConfigurations = {
|
||||
framework = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
pkgs-unstable = import nixpkgs-unstable {
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
};
|
||||
modules = [
|
||||
home-manager.nixosModules.home-manager
|
||||
nixos-hardware.nixosModules.framework-16-7040-amd
|
||||
|
|
@ -36,6 +43,12 @@
|
|||
};
|
||||
aurora = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
pkgs-unstable = import nixpkgs-unstable {
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
};
|
||||
modules = [
|
||||
home-manager.nixosModules.home-manager
|
||||
./systems/common.nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue