diff options
author | Ben Sima <ben@bsima.me> | 2020-05-02 15:39:07 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-05-02 15:39:07 -0700 |
commit | b8c33100286ab307f46d3dfe7adf44008cc59d3e (patch) | |
tree | 95a822b141fd2e08c03a8eb90dc72121c22ad0a4 /nix | |
parent | 93718f88d65d1fc4322fbd42804dfabc9128e4cd (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')
-rw-r--r-- | nix/default.nix (renamed from nix/nixpkgs.nix) | 2 | ||||
-rw-r--r-- | nix/haskell-overlay.nix | 26 | ||||
-rw-r--r-- | nix/repl.nix | 1 | ||||
-rw-r--r-- | nix/sources-overlay.nix | 16 | ||||
-rw-r--r-- | nix/wemux.nix | 2 |
5 files changed, 34 insertions, 13 deletions
diff --git a/nix/nixpkgs.nix b/nix/default.nix index 864511b..74917f8 100644 --- a/nix/nixpkgs.nix +++ b/nix/default.nix @@ -5,6 +5,8 @@ let overlays = [ (_: _: { inherit sources; }) (_: _: { niv = import sources.niv {}; }) + (import ./sources-overlay.nix) + (_: pkgs: pkgs.overridePinnedDeps pkgs.overrideSource) (import ./haskell-overlay.nix) (_: pkgs: { wemux = pkgs.callPackage ./wemux.nix {}; }) ]; diff --git a/nix/haskell-overlay.nix b/nix/haskell-overlay.nix index e384b4f..1afea87 100644 --- a/nix/haskell-overlay.nix +++ b/nix/haskell-overlay.nix @@ -1,24 +1,26 @@ -_: nixpkgs: +_: pkgs: +let + cabalBuilder = self: name: self.callCabal2nix name pkgs.sources.${name} {}; +in { - haskell = nixpkgs.haskell // { - packages = nixpkgs.haskell.packages // { - ghc865 = nixpkgs.haskell.packages.ghc865.override (old: { - overrides = with nixpkgs.pkgs.haskell.lib; self: super: { - clay = self.callCabal2nix "clay" nixpkgs.sources.clay {}; - miso = self.callCabal2nix "miso" nixpkgs.sources.miso {}; + haskell = pkgs.haskell // { + packages = pkgs.haskell.packages // { + ghc865 = pkgs.haskell.packages.ghc865.override (old: { + overrides = with pkgs.pkgs.haskell.lib; self: super: + pkgs.overridePinnedDeps (cabalBuilder self) // { wai-middleware-metrics = dontCheck super.wai-middleware-metrics; }; }); - ghcjs = nixpkgs.haskell.packages.ghcjs.override (old: { - overrides = with nixpkgs.haskell.lib; self: super: { + ghcjs = pkgs.haskell.packages.ghcjs.override (old: { + overrides = with pkgs.haskell.lib; self: super: + pkgs.overridePinnedDeps (cabalBuilder self) // { QuickCheck = dontCheck super.QuickCheck; base-compat-batteries = dontCheck super.http-types; - clay = dontCheck (self.callCabal2nix "clay" claySrc {}); + clay = dontCheck super.clay; comonad = dontCheck super.comonad; - jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" "${nixpkgs.sources.jsaddle}/jsaddle-warp" {}); + jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" "${pkgs.sources.jsaddle}/jsaddle-warp" {}); http-types = dontCheck super.http-types; - miso = self.callCabal2nix "miso" nixpkgs.sources.miso {}; network-uri= dontCheck super.network-uri; scientific = dontCheck super.scientific; # takes forever servant = dontCheck super.servant; diff --git a/nix/repl.nix b/nix/repl.nix new file mode 100644 index 0000000..94edf3a --- /dev/null +++ b/nix/repl.nix @@ -0,0 +1 @@ +{ nixpkgs = import ./.; } 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}; + }); +} diff --git a/nix/wemux.nix b/nix/wemux.nix index 4972815..365853f 100644 --- a/nix/wemux.nix +++ b/nix/wemux.nix @@ -1,7 +1,7 @@ { sources, stdenv }: stdenv.mkDerivation rec { - name = "wemux"; + name = "wemux-${version}"; version = "2020.04.03"; src = sources.wemux; installPhase = '' |