• [^] # Re: suckmore

    Posté par . En réponse à la dépêche Donnez moi un NixOS à ronger. Évalué à 1.

    Je pense pas.
    Un binaire peut-être linké en statique mais tu mets rarement la conf dans un binaire.

    Nix et Nixos te permettent de faire un "contexte".

    Par exemple, pour mon réseau local j'ai un grafana et plusieurs node prometheus. J'a

    J'ai une configuration firefox avec des extensions, des bookmarks, des moteurs de recherche :
    { config, lib, pkgs, ... }:
    2 │ let
    3 │ nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
    4 │ inherit pkgs;
    5 │ };
    6 │ in
    7 │ {
    8 │ programs.firefox = {
    9 │ enable = true ;
    10 │ profiles.default = {
    11 │ isDefault = true ;
    12 │ extensions = lib.mkIf config.programs.firefox.enable
    13 │ (with nur.repos.rycee.firefox-addons; [
    14 │ french-dictionary
    15 │ i-dont-care-about-cookies
    16 │ ublock-origin
    17 │ privacy-badger
    18 │ keepassxc-browser
    19 │ clearurls
    20 │ decentraleyes
    21 │ floccus
    22 │ ]);
    23 │ search = {
    24 │ force = true;
    25 │ default = "Google";
    26 │ engines = {
    27 │ "Nix Packages" = {
    28 │ urls = [{
    29 │ template = "https://search.nixos.org/packages";
    30 │ params = [
    31 │ { name = "type"; value = "packages"; }
    32 │ { name = "query"; value = "{searchTerms}"; }
    33 │ ];
    34 │ }];
    35 │ icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
    36 │ definedAliases = [ "@np" ];
    37 │ };
    38 │ "NixOS Wiki" = {
    39 │ urls = [{ template = "https://nixos.wiki/index.php?search={searchTerms}"; }];
    40 │ iconUpdateURL = "https://nixos.wiki/favicon.png";
    41 │ updateInterval = 24 * 60 * 60 * 1000;
    42 │ definedAliases = [ "@nw" ];
    43 │ };
    44 │ "Wikipedia (en)".metaData.alias = "@wiki";
    45 │ "Google".metaData.hidden = false;
    46 │ "Amazon.com".metaData.hidden = true;
    47 │ "Bing".metaData.hidden = true;
    48 │ "eBay".metaData.hidden = true;
    49 │ };
    50 │ };
    51 │
    52 │ bookmarks = [
    53 │ {

    Côté serveur, je vais faire un fichier nix, avec par exemple toute ma conf nginx. C'est à dire que je vais avoir dedans le fait de vouloir avoir nginx mais aussi les vhost. Le tout dans un git :

    config, pkgs, ... }:
    2 │
    3 │ {
    4 │ # Activation de nginx
    5 │ services = {
    6 │ nginx = {
    7 │ enable = true;
    8 │
    9 │ virtualHosts = {
    10 │ "atlanticaweb.fr" = {
    11 │ root = "/srv/www/mondomaine.fr";
    12 │ enableACME = true;
    13 │ forceSSL = true;
    14 │ };
    15 │ # Redirection www vers domaine nu
    16 │ "www.mondomaine.fr" = {
    17 │ enableACME = true;
    18 │ forceSSL = true;
    19 │ globalRedirect = "mondomaine.fr";
    20 │ };
    21 │ "git.atlanticaweb.fr" = {
    22 │ enableACME = true;
    23 │ forceSSL = true;
    24 │
    25 │ locations."/" = {
    26 │ proxyPass = "http://localhost:3001";
    27 │ proxyWebsockets = true;
    28 │ extraConfig = ''
    29 │ proxy_set_header Host $host;
    30 │ proxy_set_header X-Real-IP $remote_addr;
    31 │ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    32 │ proxy_set_header X-Forwarded-Proto $scheme;
    33 │ '';
    34 │ };
    35 │ };
    36 │ "bookmark.mondomaine.fr" = {
    37 │ enableACME = true;
    38 │ forceSSL = true;
    39 │
    40 │ locations."/" = {
    41 │ proxyPass = "http://localhost:8080";
    42 │ proxyWebsockets = true;
    43 │ extraConfig = ''
    44 │ proxy_set_header Host $host;
    45 │ proxy_set_header X-Real-IP $remote_addr;
    46 │ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    47 │ proxy_set_header X-Forwarded-Proto $scheme;
    48 │ '';
    49 │ };
    50 │ };