|
|
|
@ -5,7 +5,38 @@ utilisateur = "raito" # À remplacer avec root ou votre nom d'utilisateur.
|
|
|
|
|
|
|
|
|
|
c = Connection(nom_hote, user=utilisateur)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generer_nix():
|
|
|
|
|
squelette = """
|
|
|
|
|
# This file is managed by Fabric, do not edit.
|
|
|
|
|
{ pkgs, ... }:
|
|
|
|
|
{
|
|
|
|
|
%s
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
nix_conf = """
|
|
|
|
|
# On se lance un petit service de courses à la maison.
|
|
|
|
|
services.grocy = {
|
|
|
|
|
enable = true;
|
|
|
|
|
hostName = "votre.tld"; # Vous pouvez utiliser un DynDNS ! e.g. https://dns.he.net/
|
|
|
|
|
};
|
|
|
|
|
security.acme.acceptTerms = true; # On accepte les termes du contrat de Let's Encrypt.
|
|
|
|
|
security.acme.email = "vous@mail.tld"; # Email pour les alertes de Let's Encrypt.
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 443 ]; # Ports à ouvrir!
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return squelette % nix_conf
|
|
|
|
|
|
|
|
|
|
print('[+] Regardons le nom d\'hôte')
|
|
|
|
|
c.run('hostname')
|
|
|
|
|
print('[+] Regardons les informations du noyau et de la machine')
|
|
|
|
|
c.run('uname -a')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fabric_managed_contents = generer_nix()
|
|
|
|
|
with open("/tmp/fabric.nix", "w") as f:
|
|
|
|
|
f.write(fabric_managed_contents)
|
|
|
|
|
c.put('/tmp/fabric.nix', '/tmp/fabric.nix')
|
|
|
|
|
c.run('sudo mv /tmp/fabric.nix /etc/nixos/fabric-managed.nix', pty=True)
|
|
|
|
|
c.run('sudo nixos-rebuild switch', pty=True)
|
|
|
|
|