summaryrefslogtreecommitdiff
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
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.
-rw-r--r--.envrc1
-rw-r--r--Biz/Cloud/hardware.nix1
-rw-r--r--Hero/Prod.nix1
-rw-r--r--Que/Prod.nix1
-rw-r--r--default.nix2
-rw-r--r--nix/default.nix (renamed from nix/nixpkgs.nix)2
-rw-r--r--nix/haskell-overlay.nix26
-rw-r--r--nix/repl.nix1
-rw-r--r--nix/sources-overlay.nix16
-rw-r--r--nix/wemux.nix2
10 files changed, 36 insertions, 17 deletions
diff --git a/.envrc b/.envrc
index 9950962..28b8bda 100644
--- a/.envrc
+++ b/.envrc
@@ -1,4 +1,5 @@
PATH_add $PWD
+export NIX_PATH=$PWD/nix
export BIZ_ROOT=$PWD
export HERO_PORT=3000
export HERO_CLIENT=$BIZ_ROOT/_bild/Hero.Client/static
diff --git a/Biz/Cloud/hardware.nix b/Biz/Cloud/hardware.nix
index 458fd49..20eab30 100644
--- a/Biz/Cloud/hardware.nix
+++ b/Biz/Cloud/hardware.nix
@@ -1,6 +1,5 @@
{ ... }:
{
- imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
boot.loader.grub.device = "/dev/vda";
fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; };
swapDevices = [
diff --git a/Hero/Prod.nix b/Hero/Prod.nix
index 7da2f72..d7ab1fe 100644
--- a/Hero/Prod.nix
+++ b/Hero/Prod.nix
@@ -1,6 +1,5 @@
{ config, pkgs, lib, ... }:
{
- imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
boot.loader.grub.device = "/dev/vda";
fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; };
networking = {
diff --git a/Que/Prod.nix b/Que/Prod.nix
index 138f582..23c6f0a 100644
--- a/Que/Prod.nix
+++ b/Que/Prod.nix
@@ -1,6 +1,5 @@
{ config, pkgs, lib, ... }:
{
- imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
boot.loader.grub.device = "/dev/vda";
fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; };
swapDevices = [
diff --git a/default.nix b/default.nix
index de30805..f274f81 100644
--- a/default.nix
+++ b/default.nix
@@ -1,5 +1,5 @@
let
- nixpkgs = import ./nix/nixpkgs.nix;
+ nixpkgs = import ./nix;
build = import ./nix/build.nix { inherit nixpkgs; };
nixos-mailserver = let ver = "v2.3.0"; in builtins.fetchTarball {
url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/${ver}/nixos-mailserver-${ver}.tar.gz";
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 = ''