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