]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/scripts/setup
3 RemoteRepo
="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Mes_Sites/Paul"
4 DeploymentUuid
="cef694f3-081d-11e9-b31f-0242ec186adf"
6 if ! which nix
2>/dev
/null
>/dev
/null
; then
8 nix is needed, please install it:
9 > curl https://nixos.org/nix/install | sh
10 (or any other way handled by your distribution)
15 if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_REMOTE" \
16 -o -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
18 Two environment variables are needed to setup the password store:
19 NIXOPS_CONFIG_PASS_SUBTREE_PATH : path where the subtree will be imported
20 NIXOPS_CONFIG_PASS_SUBTREE_REMOTE : remote name to give to the repository
25 if ! pass
$NIXOPS_CONFIG_PASS_SUBTREE_PATH > /dev
/null
2>/dev
/null
; then
27 /!\ This will modify your password store to add and import a subtree
28 with the specific passwords files. Choose a path that doesn’t exist
29 yet in your password store.
30 > pass git remote add $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE $RemoteRepo
31 > pass git subtree add --prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master
32 Later, you can use pull_environment and push_environment scripts to
33 update the passwords when needed
37 if [ "$y" = "y" -o "$y" = "Y" ]; then
38 pass git remote add
$NIXOPS_CONFIG_PASS_SUBTREE_REMOTE $RemoteRepo
39 pass git subtree add
--prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master
46 if [ ! -f /etc
/ssh
/ssh_rsa_key_nixops
]; then
48 The key to access private git repositories (websites hosted by the
49 server) needs to be accessible to nix builders. It will be put in
50 /etc/ssh/ssh_rsa_key_nixops (sudo right is needed for that)
51 > pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/SshKey | sudo tee /etc/ssh/ssh_rsa_key_nixops > /dev/null
52 > pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/SshKey.pub | sudo tee /etc/ssh/ssh_rsa_key_nixops.pub > /dev/null
53 > sudo chmod u=r,go-rwx /etc/ssh/ssh_rsa_key_nixops
54 > sudo chown nixbld1:nixbld /etc/ssh/ssh_rsa_key_nixops /etc/ssh/ssh_rsa_key_nixops.pub
58 if [ "$y" = "y" -o "$y" = "Y" ]; then
59 if ! id
-u nixbld1
2>/dev
/null
>/dev
/null
; then
60 echo "User nixbld1 seems inexistant, did you install nix?"
65 # Don’t forward it directly to tee, it would break ncurse pinentry
66 key
=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/SshKey)
67 echo "$key" | sudo
tee /etc
/ssh
/ssh_rsa_key_nixops
> /dev
/null
68 sudo
chmod u
=r
,go
=- /etc
/ssh
/ssh_rsa_key_nixops
69 pubkey
=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/SshKey.pub)
70 echo "$pubkey" | sudo
tee /etc
/ssh
/ssh_rsa_key_nixops.pub
> /dev
/null
71 sudo
chmod a
=r
/etc
/ssh
/ssh_rsa_key_nixops.pub
72 sudo chown nixbld1
:nixbld
/etc
/ssh
/ssh_rsa_key_nixops
/etc
/ssh
/ssh_rsa_key_nixops.pub
80 if ! which nixops
2>/dev
/null
>/dev
/null
; then
84 If it fails, please check that $HOME/.nix-profile/bin is in your PATH.
88 if [ "$y" = "y" -o "$y" = "Y" ]; then
90 if ! which nixops
2>/dev
/null
>/dev
/null
; then
91 echo "Installation failed, please check that $HOME/.nix-profile/bin is in your path."
100 DIR
="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev
/null
2>&1 && pwd )"
101 export NIXOPS_STATE="$(dirname $DIR)/state
/eldiron.nixops
"
102 export NIXOPS_DEPLOYMENT="$DeploymentUuid"
104 if ! nixops info 2>/dev/null >/dev/null; then
106 Importing deployment file into nixops:
110 if [ "$y" = "y
" -o "$y" = "Y
" ]; then
111 deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment)
112 echo "$deployment" | nixops import
114 nixops modify "$(dirname $DIR)/eldiron.nix
"
123 Please make sure you’re using scripts/nixops_wrap when deploying