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