From b8c33100286ab307f46d3dfe7adf44008cc59d3e Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 2 May 2020 15:39:07 -0700 Subject: 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. --- nix/default.nix | 14 ++++++++++++++ nix/haskell-overlay.nix | 26 ++++++++++++++------------ nix/nixpkgs.nix | 12 ------------ nix/repl.nix | 1 + nix/sources-overlay.nix | 16 ++++++++++++++++ nix/wemux.nix | 2 +- 6 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 nix/default.nix delete mode 100644 nix/nixpkgs.nix create mode 100644 nix/repl.nix create mode 100644 nix/sources-overlay.nix (limited to 'nix') diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..74917f8 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,14 @@ +let + sources = import ./sources.nix; + nixpkgs = import sources.nixpkgs { + system = "x86_64-linux"; + 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 {}; }) + ]; + }; +in nixpkgs 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/nixpkgs.nix b/nix/nixpkgs.nix deleted file mode 100644 index 864511b..0000000 --- a/nix/nixpkgs.nix +++ /dev/null @@ -1,12 +0,0 @@ -let - sources = import ./sources.nix; - nixpkgs = import sources.nixpkgs { - system = "x86_64-linux"; - overlays = [ - (_: _: { inherit sources; }) - (_: _: { niv = import sources.niv {}; }) - (import ./haskell-overlay.nix) - (_: pkgs: { wemux = pkgs.callPackage ./wemux.nix {}; }) - ]; - }; -in nixpkgs 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 = '' -- cgit v1.2.3