From 0dfac33429194a9713a38891aeacab68cc6084ab Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sun, 25 Aug 2024 20:48:08 +0000 Subject: [PATCH] extract & rework backports overlay --- flake.nix | 2 ++ nix/nixos-modules/default.nix | 9 +-------- nix/overlays/backports.nix | 20 ++++++++++++++++++++ nix/overlays/default.nix | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 nix/overlays/backports.nix create mode 100644 nix/overlays/default.nix diff --git a/flake.nix b/flake.nix index 02c6b1d..b6e0d14 100644 --- a/flake.nix +++ b/flake.nix @@ -100,6 +100,8 @@ nixosModules = importFlakeMod ./nix/nixos-modules; + overlays = importFlakeMod ./nix/overlays; + packages = importFlakeModWithSystem ./nix/packages; }; diff --git a/nix/nixos-modules/default.nix b/nix/nixos-modules/default.nix index 0442f49..85ac52d 100644 --- a/nix/nixos-modules/default.nix +++ b/nix/nixos-modules/default.nix @@ -49,14 +49,7 @@ outputs.nixosModules.banananetwork ]; config = { - nixpkgs.overlays = [ - # TODO until 24.11 - (lib.mkIf (!lib.versionAtLeast lib.version "24.11") ( - final: prev: { - inherit ((lib.systemSpecificVars pkgs.system).pkgs_unstable) nixfmt-rfc-style wcurl; - } - )) - ]; + nixpkgs.overlays = lib.singleton outputs.overlays.backports; }; }; diff --git a/nix/overlays/backports.nix b/nix/overlays/backports.nix new file mode 100644 index 0000000..3821df3 --- /dev/null +++ b/nix/overlays/backports.nix @@ -0,0 +1,20 @@ +{ lib, ... }@flakeArg: +{ pkgs_unstable, ... }@systemArg: +final: prev: +let + list = [ + # TODO until 24.11 + "nixfmt-rfc-style" + "wcurl" + ]; + backport = + pkgAttrName: + let + alreadyStable = builtins.hasAttr pkgAttrName prev; + stableSource = lib.warn "consider removing ${pkgAttrName} from backports list as it is now available on stable" prev; + source = if alreadyStable then stableSource else pkgs_unstable; + pkg = builtins.getAttr pkgAttrName source; + in + pkg; +in +lib.genAttrs list backport diff --git a/nix/overlays/default.nix b/nix/overlays/default.nix new file mode 100644 index 0000000..76f0c08 --- /dev/null +++ b/nix/overlays/default.nix @@ -0,0 +1,14 @@ +{ lib, ... }@flakeArg: +let + inherit (lib) systemSpecificVars; + rawImport = path: import path flakeArg; + wrapOverlay = + overlay: final: prev: + overlay (systemSpecificVars prev.system) final prev; + importOverlay = path: wrapOverlay (rawImport path); +in +{ + + backports = importOverlay ./backports.nix; + +}