about summary refs log tree commit diff
path: root/release.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-04-29 06:36:04 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-04-29 06:49:18 +0200
commit29f2e5a8680176ce3407285ce1af702196e6ebb0 (patch)
tree1f0fb1040ff5e630aced8a6eba729535448eb0d4 /release.nix
parent23a7bc6a7590ebced5828e09c09d6e7a39188d74 (diff)
release.nix: Refactor to use patched nixpkgs.
We now use nixpkgsSrc to make sure that Hydra builds will fail as soon
as we hit a reference of <nixpkgs> in either vuizvui of nixpkgs.

This also means, that we don't rewrite all of vuizvui and nixpkgs
anymore and we only really need to rewrite nixos-rebuild.sh.

Although we're using patched nixpkgs for Hydra builds, the release.nix
still has a fallback to <nixpkgs> to make development easier (patching
nixpkgs on every tiny change will take a long time otherwise).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'release.nix')
-rw-r--r--release.nix33
1 files changed, 20 insertions, 13 deletions
diff --git a/release.nix b/release.nix
index 5e40ea59..288dfd76 100644
--- a/release.nix
+++ b/release.nix
@@ -1,15 +1,24 @@
-{ vuizvui ? { outPath  = ./.;
-              revCount = 12345;
-              shortRev = "abcdefg";
-            }
-, nixpkgs ? { outPath  = import ./nixpkgs-path.nix;
-              revCount = 12345;
-              shortRev = "abcdefg";
-            }
+{ vuizvui ? { outPath  = ./.; revCount = 12345; shortRev = "abcdefg"; }
+, nixpkgsSrc ? null
 , supportedSystems ? [ "i686-linux" "x86_64-linux" ]
 }:
 
 let
+  nixpkgsRevCount = nixpkgsSrc.revCount or 12345;
+  nixpkgsShortRev = nixpkgsSrc.shortRev or "abcdefg";
+
+  nixpkgs = let
+    patchedNixpkgs = (import nixpkgsSrc {}).stdenv.mkDerivation {
+      src = nixpkgsSrc;
+      phases = [ "unpackPhase" "installPhase" ];
+      installPhase = ''
+        sed -i -re 's!<nixpkgs([^>]*)>!<vuizvui/nixpkgs\1>!g' \
+          nixos/modules/installer/tools/nixos-rebuild.sh
+        cp -r . "$out"
+      '';
+    };
+  in if nixpkgsSrc == null then <nixpkgs> else patchedNixpkgs;
+
   system = "x86_64-linux";
   pkgsUpstream = import nixpkgs { inherit system; };
   root = import ./default.nix { inherit system; };
@@ -35,15 +44,13 @@ in with pkgsUpstream.lib; with builtins; {
     mkChannel = attrs: root.pkgs.mkChannel (rec {
       name = "vuizvui-channel-${attrs.name or "generic"}-${version}";
       version = "${toString vuizvui.revCount}.${vuizvui.shortRev}";
-      pkgsVer = "pre${toString nixpkgs.revCount}.${nixpkgs.shortRev}-vuizvui";
+      pkgsVer = "pre${toString nixpkgsRevCount}.${nixpkgsShortRev}-vuizvui";
       src = vuizvui;
       patchPhase = ''
         cp -r --no-preserve=mode,ownership "${nixpkgs}/" nixpkgs
-        find \( -iname '*.nix' -type f \
-             -o -path ./nixpkgs/nixos/modules/installer/tools/nixos-rebuild.sh \
-             \) -exec sed -i -re 's!<nixpkgs([^>]*)>!<vuizvui/nixpkgs\1>!g' {} +
         echo -n "$pkgsVer" > nixpkgs/.version-suffix
-        echo -n ${nixpkgs.rev or nixpkgs.shortRev} > nixpkgs/.git-revision
+        echo -n ${nixpkgs.rev or nixpkgsShortRev} > nixpkgs/.git-revision
+        echo './nixpkgs' > nixpkgs-path.nix
         touch .update-on-nixos-rebuild
       '';
     } // removeAttrs attrs [ "name" ]);