summaryrefslogtreecommitdiff
path: root/Biz/Bild/Functions.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-08 16:02:03 -0400
committerBen Sima <ben@bsima.me>2024-04-10 19:56:46 -0400
commitaa5f12a5a2365a35f17becc66cf7a67fa86a4440 (patch)
treee43c059973558ea0b1687525e00789c353491460 /Biz/Bild/Functions.nix
parent544d75a47e85d2b334267a43ba065bb69538ad75 (diff)
Reorganize and update nixpkgs upstreams
This patch does a few things: 1. Switches from nixpkgs-unstable to nixos-unstable{,-small}, simply because nixpkgs-unstable is not in cache.nixos.org, but nixos-unstable is, and -small is the same but requires all tests to pass. So we should prefer nixos-unstable-small, whenever possible. 2. Reorganizes the nixpkgs import code such that Nixpkgs.nix returns an attrset of all the nixpkgs that I want to use, rather than putting other nixpkgs branches into the main one as an overlay. This is much simpler and explicit, but it meant I had to change a lot of usages throughtout the nix codebase. 3. As a consequence of 2, moves the overlays into separate files so they can be re-used across nixpkgs branches.
Diffstat (limited to 'Biz/Bild/Functions.nix')
-rw-r--r--Biz/Bild/Functions.nix33
1 files changed, 33 insertions, 0 deletions
diff --git a/Biz/Bild/Functions.nix b/Biz/Bild/Functions.nix
new file mode 100644
index 0000000..b725a00
--- /dev/null
+++ b/Biz/Bild/Functions.nix
@@ -0,0 +1,33 @@
+_: super: {
+ # Given a generic `builder`, will generate an attrset for all the packages
+ # pinned by `deps` with `builder` applied to the package. This attrset can
+ # then be merged with the rest of the packages in the set as part of an
+ # overlay or overrides.
+ overridePinnedDeps = builder:
+ super.lib.genAttrs (builtins.attrNames super.sources) builder;
+
+ # Modifies a derivation with our source and version, keeping super build
+ # rules. This will fail if build steps have changed, or if no build
+ # rules are available upstream.
+ overrideSource = depName:
+ if super ? "${depName}" && super.${depName} ? overrideAttrs then
+ super.${depName}.overrideAttrs (attrs:
+ attrs // rec {
+ version =
+ super.sources.${depName}.version or super.sources.${depName}.rev;
+ src = super.sources.${depName};
+ })
+ else
+ null;
+
+ # Simply override the 'src' attr on a drv. This is meant to be a simpler
+ # alternative to 'overrideSource' above. In an overaly, use it like:
+ # mypkg = super.overrideSource super.mypkg super.sources.mypkg;
+ overrideSrc = dep: src:
+ dep.overrideAttrs (attrs:
+ attrs // {
+ version = src.version or src.rev;
+ src = src;
+ });
+}
+