summaryrefslogtreecommitdiff
path: root/nix/sources-overlay.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-05-02 15:39:07 -0700
committerBen Sima <ben@bsima.me>2020-05-02 15:39:07 -0700
commitb8c33100286ab307f46d3dfe7adf44008cc59d3e (patch)
tree95a822b141fd2e08c03a8eb90dc72121c22ad0a4 /nix/sources-overlay.nix
parent93718f88d65d1fc4322fbd42804dfabc9128e4cd (diff)
Auto-overlay niv sources
This is somewhat experimental, the idea is automatically set the sources from my niv pinned deps. It seems to work, so I'll keep at it and see if I can improve it as issues come up.
Diffstat (limited to 'nix/sources-overlay.nix')
-rw-r--r--nix/sources-overlay.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/nix/sources-overlay.nix b/nix/sources-overlay.nix
new file mode 100644
index 0000000..b19bb34
--- /dev/null
+++ b/nix/sources-overlay.nix
@@ -0,0 +1,16 @@
+_: pkgs:
+
+rec {
+ pinnedDeps = builtins.attrNames
+ (builtins.removeAttrs pkgs.sources ["__functor"]);
+ overridePinnedDeps = builder: pkgs.lib.genAttrs pinnedDeps builder;
+
+ # Modifies a derivation with our source and version, keeping old build
+ # rules. This will fail if build steps have changed, or if no build
+ # rules are available upstream..
+ overrideSource = name: pkgs.${name}.overrideAttrs (old: old // rec {
+ name = "${name}-${version}";
+ version = pkgs.sources.${name}.version or pkgs.sources.${name}.rev;
+ src = pkgs.sources.${name};
+ });
+}