Skip to content

Instantly share code, notes, and snippets.

@ivanbrennan
Created July 12, 2018 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanbrennan/4c188d45e75439762b89aef71a1b52c2 to your computer and use it in GitHub Desktop.
Save ivanbrennan/4c188d45e75439762b89aef71a1b52c2 to your computer and use it in GitHub Desktop.
# prepare nix files on "nix" branch
git checkout -b nix
# tuck everything except shell.nix under a nix/ directory
mkdir -p nix
# generate nix expressions for dependencies
nix-shell --packages bundler --run 'bundle lock'
nix-shell --packages bundix --run 'bundix --gemset=nix/gemset.nix'
# pin nixpkgs
cat > nix/nixpkgs.nix <<EOF
import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/be1461fc0ab29c45c69e7b2c2097c887750e4fe0.tar.gz";
sha256 = "1fdlnfipa3qpyzqqqy3cf5zicgj6chwmd40yz8n60nil8qi6452w";
})
EOF
# write shell.nix
vim shell.nix
# write an init script that can bootstrap nix support in a fresh repo
vim nix/init.sh
# commit with bootstrap instructions
git add shell.nix nix/
git commit -m 'initial nix support
To initialize nix support in a local repo, run:
tmpDir=$(mktemp --tmpdir -d fakeproject-nix.XXXXXX)
git clone --depth 1 --branch nix \
git@github.com:ivanbrennan/fakeproject.git $tmpDir
$tmpDir/nix/init.sh
rm -rf $tmpDir && unset tmpDir
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment