From 326da0f7e83c7172457d0c30101e68da90f480f1 Mon Sep 17 00:00:00 2001 From: Jean-Pierre PRUNARET Date: Fri, 22 Jul 2016 14:16:20 +0200 Subject: [PATCH] ajout header + utilisation --- activation-manuelle/auto-upgrade.nix | 10 +++++++--- activation-manuelle/fail2ban.nix | 8 ++++++-- activation-manuelle/laptop.nix | 8 ++++++-- activation-manuelle/locate.nix | 8 ++++++-- activation-manuelle/nix-serve-client.nix | 2 ++ activation-manuelle/nix-serve-server.nix | 10 +++++++--- activation-manuelle/print.nix | 8 ++++++-- activation-manuelle/swap.nix | 8 ++++++-- activation-manuelle/users.nix | 5 ++++- 9 files changed, 50 insertions(+), 17 deletions(-) diff --git a/activation-manuelle/auto-upgrade.nix b/activation-manuelle/auto-upgrade.nix index fa61df3..4c2637a 100644 --- a/activation-manuelle/auto-upgrade.nix +++ b/activation-manuelle/auto-upgrade.nix @@ -1,8 +1,12 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Automatic update & automatic clean - system.autoUpgrade.enable = config.r6d.config-generator.auto-upgrade; - nix.gc.automatic = config.r6d.config-generator.auto-upgrade; + system.autoUpgrade.enable = cfg.auto-upgrade; + nix.gc.automatic = cfg.auto-upgrade; } diff --git a/activation-manuelle/fail2ban.nix b/activation-manuelle/fail2ban.nix index 2340d60..9f28547 100644 --- a/activation-manuelle/fail2ban.nix +++ b/activation-manuelle/fail2ban.nix @@ -1,9 +1,13 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Gestion de fail2ban - services = pkgs.lib.mkIf config.r6d.config-generator.fail2ban { + services = mkIf cfg.fail2ban { fail2ban = { enable = true; jails = { diff --git a/activation-manuelle/laptop.nix b/activation-manuelle/laptop.nix index 6a08edc..fdbd5db 100644 --- a/activation-manuelle/laptop.nix +++ b/activation-manuelle/laptop.nix @@ -1,6 +1,10 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Gestion spécifique pour PC portable - powerManagement.cpuFreqGovernor = pkgs.lib.mkIf config.r6d.config-generator.laptop "powersave"; + powerManagement.cpuFreqGovernor = mkIf cfg.laptop "powersave"; } diff --git a/activation-manuelle/locate.nix b/activation-manuelle/locate.nix index 072d930..a27e977 100644 --- a/activation-manuelle/locate.nix +++ b/activation-manuelle/locate.nix @@ -1,11 +1,15 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { imports = [ ]; services.locate = { - enable = config.r6d.config-generator.locate; + enable = cfg.locate; interval = "hourly"; }; } diff --git a/activation-manuelle/nix-serve-client.nix b/activation-manuelle/nix-serve-client.nix index 910bbc5..fa83547 100644 --- a/activation-manuelle/nix-serve-client.nix +++ b/activation-manuelle/nix-serve-client.nix @@ -1,7 +1,9 @@ { config, lib, pkgs, ... }: + let inherit (lib) mkIf mkMerge; profiles = config.r6d.profiles; + cfg = config.r6d.config-generator; computers = config.r6d.computers; in { nix = mkIf config.r6d.config-generator.nix-serve-client { diff --git a/activation-manuelle/nix-serve-server.nix b/activation-manuelle/nix-serve-server.nix index 686f8c0..86dfea6 100644 --- a/activation-manuelle/nix-serve-server.nix +++ b/activation-manuelle/nix-serve-server.nix @@ -1,8 +1,12 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Cache http pour le store - services.nix-serve.enable = config.r6d.config-generator.nix-serve-server; - networking.firewall.allowedTCPPorts = pkgs.lib.mkIf config.r6d.config-generator.nix-serve-server [ 5000 ]; + services.nix-serve.enable = cfg.nix-serve-server; + networking.firewall.allowedTCPPorts = mkIf cfg.nix-serve-server [ 5000 ]; } diff --git a/activation-manuelle/print.nix b/activation-manuelle/print.nix index f176b6e..5c0735b 100644 --- a/activation-manuelle/print.nix +++ b/activation-manuelle/print.nix @@ -1,8 +1,12 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Enable CUPS to print documents. - services.printing = pkgs.lib.mkIf config.r6d.config-generator.print { + services.printing = mkIf cfg.print { enable = true; drivers = [ pkgs.samsung-unified-linux-driver diff --git a/activation-manuelle/swap.nix b/activation-manuelle/swap.nix index ea92882..1318e2d 100644 --- a/activation-manuelle/swap.nix +++ b/activation-manuelle/swap.nix @@ -1,10 +1,14 @@ { config, pkgs, ... }: -{ +with pkgs.lib; + +let + cfg = config.r6d.config-generator; +in { # Gestion du swap # https://en.wikipedia.org/wiki/Swappiness - boot.kernel.sysctl = pkgs.lib.mkIf config.r6d.config-generator.swap { + boot.kernel.sysctl = mkIf cfg.swap { # le swap est activé (!= 0) # le swap est utilisé lorsque (100 - x) % de la mémoire est déja allouée "vm.swappiness" = 10; diff --git a/activation-manuelle/users.nix b/activation-manuelle/users.nix index 0a2e9e0..33a215c 100644 --- a/activation-manuelle/users.nix +++ b/activation-manuelle/users.nix @@ -1,12 +1,15 @@ { config, pkgs, ... }: +with pkgs.lib; + let + cfg = config.r6d.config-generator; profiles = config.r6d.profiles; in { security.sudo.wheelNeedsPassword = !(profiles.isPrunetwork && profiles.isServer); - users.extraUsers.jpierre03 = pkgs.lib.mkIf profiles.isPrunetwork + users.extraUsers.jpierre03 = mkIf profiles.isPrunetwork { isNormalUser = true; createHome = true; home = "/home/jpierre03";