From 9ded51c865c06a59df725f367ecd9961ac51fd9c Mon Sep 17 00:00:00 2001 From: ahmza Date: Wed, 5 Aug 2026 21:27:51 +0100 Subject: [PATCH] changes to move opencode to nixpkgs unstable - more up to date and fixes breaking bugs --- flake.lock | 19 ++++++++++++- flake.nix | 1 + modules/attrs/development/default.nix | 4 ++- modules/dendritic.nix | 3 ++ modules/system/core/default.nix | 1 + modules/system/core/overlays.nix | 40 +++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 modules/system/core/overlays.nix diff --git a/flake.lock b/flake.lock index 10bde67..a574b19 100644 --- a/flake.lock +++ b/flake.lock @@ -66,12 +66,29 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1785828668, + "narHash": "sha256-8fsyqeO+mJqvIzeO4xIpgJe/f7MTbbVTEC6RT6WSXNs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e72e4f299401a3689d4b3d5fc6496b11db7064eb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-file": "flake-file", "flake-parts": "flake-parts", "import-tree": "import-tree", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" } } }, diff --git a/flake.nix b/flake.nix index 356d3d5..d4bbf14 100644 --- a/flake.nix +++ b/flake.nix @@ -11,5 +11,6 @@ }; import-tree.url = "github:vic/import-tree"; nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; }; } diff --git a/modules/attrs/development/default.nix b/modules/attrs/development/default.nix index e92c771..9fa053a 100644 --- a/modules/attrs/development/default.nix +++ b/modules/attrs/development/default.nix @@ -14,7 +14,9 @@ in { imports = modules; environment.systemPackages = with pkgs; [ - opencode + # nixos-26.05 ships 1.15.10 and opencode releases several times a week, + # so it is pinned to unstable. See modules/system/core/overlays.nix. + unstable.opencode devenv jellyfin-tui ]; diff --git a/modules/dendritic.nix b/modules/dendritic.nix index 68befe8..4f5a128 100644 --- a/modules/dendritic.nix +++ b/modules/dendritic.nix @@ -12,5 +12,8 @@ }; import-tree.url = "github:vic/import-tree"; nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; + # Escape hatch for packages that move faster than the stable channel. + # Consumed only through the `unstable` overlay, see modules/system/core/overlays.nix. + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; }; } diff --git a/modules/system/core/default.nix b/modules/system/core/default.nix index 1da10d0..e0475f6 100644 --- a/modules/system/core/default.nix +++ b/modules/system/core/default.nix @@ -12,6 +12,7 @@ user bootloader nix + overlays hardware locale nix-ld diff --git a/modules/system/core/overlays.nix b/modules/system/core/overlays.nix new file mode 100644 index 0000000..5b409f0 --- /dev/null +++ b/modules/system/core/overlays.nix @@ -0,0 +1,40 @@ +{ + self, + inputs, + ... +}: { + # Escape hatch for packages that move faster than the stable channel. + # + # `pkgs.unstable.` resolves against nixos-unstable while the rest of the + # system stays on nixos-26.05. Keep the number of consumers small and prefer + # stable unless there is a concrete reason; every unstable package drags a bit + # of the unstable closure (glibc, stdenv) in alongside the stable one. + # + # Bump with `nix flake update nixpkgs-unstable`. + flake.overlays.unstable = _final: prev: { + unstable = import inputs.nixpkgs-unstable { + inherit (prev.stdenv.hostPlatform) system; + # Carries allowUnfree (set in nix-settings.nix) into the unstable set. + inherit (prev) config; + }; + }; + + # This flake has two independent `pkgs` instances, and the overlay has to be + # registered on both or `pkgs.unstable` would exist in some modules only: + # + # 1. the NixOS module system's `pkgs` - plain modules such as + # modules/features/bun, modules/system/core + # 2. flake-parts' perSystem `pkgs` - modules built with `moduleWithSystem`, + # such as modules/attrs/development, which ignore `nixpkgs.overlays` + flake.nixosModules.overlays = {...}: { + nixpkgs.overlays = [self.overlays.unstable]; + }; + + perSystem = {system, ...}: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [self.overlays.unstable]; + config.allowUnfree = true; + }; + }; +}