2009-05-29 12:24:48 +00:00
|
|
|
# This module generates the nixos-checkout script, which replaces the
|
|
|
|
# NixOS and Nixpkgs source trees in /etc/nixos/{nixos,nixpkgs} with
|
2012-06-04 15:39:07 +00:00
|
|
|
# Git checkouts.
|
2009-05-29 12:24:48 +00:00
|
|
|
|
|
|
|
{config, pkgs, ...}:
|
2009-05-24 18:28:30 +00:00
|
|
|
|
|
|
|
with pkgs.lib;
|
2008-08-26 19:45:06 +00:00
|
|
|
|
2009-05-29 12:24:48 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
nixosCheckout = pkgs.substituteAll {
|
2008-08-26 19:45:06 +00:00
|
|
|
name = "nixos-checkout";
|
2009-05-29 12:24:48 +00:00
|
|
|
dir = "bin";
|
|
|
|
isExecutable = true;
|
2011-04-27 15:34:33 +00:00
|
|
|
src = pkgs.writeScript "nixos-checkout"
|
|
|
|
''
|
2012-05-14 04:12:43 +00:00
|
|
|
#! ${pkgs.stdenv.shell} -e
|
|
|
|
|
|
|
|
prefix="$1"
|
|
|
|
if [ -z "$prefix" ]; then prefix=/etc/nixos; fi
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
cd "$prefix"
|
2011-04-27 15:34:33 +00:00
|
|
|
|
2012-06-04 15:39:07 +00:00
|
|
|
if [ -z "$(type -P git)" ]; then
|
|
|
|
echo "installing Git..."
|
|
|
|
nix-env -iA nixos.pkgs.git || nix-env -i git
|
|
|
|
fi
|
|
|
|
|
2011-04-27 15:34:33 +00:00
|
|
|
# Move any old nixos or nixpkgs directories out of the way.
|
|
|
|
backupTimestamp=$(date "+%Y%m%d%H%M%S")
|
|
|
|
|
2012-06-04 15:57:32 +00:00
|
|
|
if [ -e nixos -a ! -e nixos/.git ]; then
|
2011-04-27 15:34:33 +00:00
|
|
|
mv nixos nixos-$backupTimestamp
|
|
|
|
fi
|
|
|
|
|
2012-06-04 15:57:32 +00:00
|
|
|
if [ -e nixpkgs -a ! -e nixpkgs/.git ]; then
|
2011-04-27 15:34:33 +00:00
|
|
|
mv nixpkgs nixpkgs-$backupTimestamp
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check out the NixOS and Nixpkgs sources.
|
2012-06-04 15:39:07 +00:00
|
|
|
git clone git://github.com/NixOS/nixos.git nixos
|
|
|
|
git clone git://github.com/NixOS/nixpkgs.git nixpkgs
|
2011-04-27 15:34:33 +00:00
|
|
|
'';
|
2008-08-26 19:45:06 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-05-29 12:24:48 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2012-06-04 15:39:07 +00:00
|
|
|
environment.systemPackages = [ nixosCheckout ];
|
2008-08-26 19:45:06 +00:00
|
|
|
}
|