[Nix-dev] PATCH: nixos-checkout type gitsvn

Florian Friesdorf flo at chaoflow.net
Sun Jan 2 18:38:04 CET 2011


implementation for a gitsvn type, works as a drop-in replacement for
type=svn.

example usage:
https://github.com/chaoflow/nixos-configurations/blob/master/chaoflow-lenovo-x200s.nix#L155

currently rebase the currently checked out branch on top of svn trunk.
This enables managing of local changes with git while keeping track of
svn trunk via nixos-checkout.

-- 
Florian Friesdorf <flo at chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-------------- next part --------------
From 7619110a9eb520c3abe3ae7b7390aad1a5cd03d5 Mon Sep 17 00:00:00 2001
From: Florian Friesdorf <flo at chaoflow.net>
Date: Thu, 30 Dec 2010 21:09:19 +0100
Subject: [PATCH 1/3] nixos-checkout gitsvn support

---
 modules/installer/tools/nixos-checkout.nix |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/modules/installer/tools/nixos-checkout.nix b/modules/installer/tools/nixos-checkout.nix
index 313e8de..9b91540 100644
--- a/modules/installer/tools/nixos-checkout.nix
+++ b/modules/installer/tools/nixos-checkout.nix
@@ -55,6 +55,7 @@ let
       default = {
         svn = { valid = "[ -d .svn ]"; env = [ pkgs.coreutils pkgs.subversion ]; };
         git = { valid = "[ -d .git ]"; env = [ pkgs.coreutils pkgs.git pkgs.gnused /*  FIXME: use full path to sed in nix-pull */ ]; };
+        gitsvn = { valid = "[ -d .git/svn ]"; env = [ pkgs.coreutils pkgs.git pkgs.gnused pkgs.subversion ]; };
       };
       description = ''
         Defines, for each supported version control system
@@ -111,6 +112,28 @@ let
     [ -d ${t} ] || { echo "git initialize failed to create target directory ${t}"; exit 1; }
     ${update}'';
     }
+    else  if attrs.type == "gitsvn" then # sanity check for existing attrs
+      let
+        a = {
+          # add gitsvn defaults
+          url = "https://svn.nixos.org/repos/nix/${repo}";
+	   # XXX: same default target as svn: good/bad?
+          target = "/etc/nixos/${repo}";
+          initialize = "git svn clone -s ${a.url} ${a.target}";
+          # splitting this in fetch and rebase -l helps to recover partly cloned repo
+          update = "git svn fetch && git svn rebase -l";
+        } // attrs;
+        t = escapeShellArg a.target;
+      in
+      rec {
+        inherit (a) type target;
+        default =  if a ? default then a.default else false;
+        update = "cd ${t} && ${a.update}";
+        initialize =  ''
+          cd $(dirname ${t}) && ${a.initialize}
+          [ -d ${t} ] || { echo "gitsvn initialize failed to create target directory ${t}"; exit 1; }
+          ${update}'';
+      }
     else throw "unkown repo type ${attrs.type}";
 
   # apply prepareRepoAttrs on each repo definition
-- 
1.7.3.2



More information about the nix-dev mailing list