From 94e969abd96b77deac98210e9146602f994b87de Mon Sep 17 00:00:00 2001 From: derped Date: Fri, 6 Sep 2019 11:38:02 +0200 Subject: [PATCH] Code cleanup. --- config/networking.nix | 4 +--- config/users.nix | 8 ++++---- pkgs/pkgsets.nix | 8 ++++---- services/openssh.nix | 3 +-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/config/networking.nix b/config/networking.nix index e7a2912..bcdb93a 100644 --- a/config/networking.nix +++ b/config/networking.nix @@ -1,8 +1,6 @@ { config, ... }: -let - firewallcfg = config.machine.firewall; -in { +{ networking = { hostName = config.machine.hostName; }; diff --git a/config/users.nix b/config/users.nix index b13341b..6399ec5 100644 --- a/config/users.nix +++ b/config/users.nix @@ -14,12 +14,12 @@ let description = "Administrative user ${user.name}."; group = user.name; extraGroups = [ "audio" "wheel" "network" ] - ++ (if config.services.xserver.enable then [ "input" ] else []) - ++ (if config.services.printing.enable then [ "cups" "lp" ] else []) - ++ (if config.virtualisation.docker.enable then [ "docker"] else []); + ++ (optional config.services.xserver.enable "input") + ++ (optionals config.services.printing.enable [ "cups" "lp" ]) + ++ (optional config.virtualisation.docker.enable "docker"); shell = "${pkgs.zsh}/bin/zsh"; passwordFile = "${config.machine.secretPath}/${user.name}"; - openssh.authorizedKeys.keyFiles = if config.services.openssh.enable then [ "${config.machine.secretPath}/${user.name}.pub" ] else []; + openssh.authorizedKeys.keyFiles = optional config.services.openssh.enable "${config.machine.secretPath}/${user.name}.pub"; }; }; diff --git a/pkgs/pkgsets.nix b/pkgs/pkgsets.nix index 30da455..b27a9dc 100644 --- a/pkgs/pkgsets.nix +++ b/pkgs/pkgsets.nix @@ -4,7 +4,7 @@ with lib; let cfg = config.machine; - optPkgs = package: pkgstring: optionals (elem pkgstring cfg.pkgs) package; + optPkgs = package: pkgstring: optionals (elem pkgstring cfg.pkgs) (toList package); gitpkgs = import /nixpkgs {}; stablepkgs = import {}; @@ -278,13 +278,13 @@ let in { environment.systemPackages = base ++ (optPkgs dict "dict") - ++ (optPkgs [emacs] "emacs") + ++ (optPkgs emacs "emacs") ++ (optPkgs extra "extra") ++ (optPkgs mail_utils "mailutils") ++ (optPkgs cpp "cpp") - ++ (optPkgs [haskell] "haskell") + ++ (optPkgs haskell "haskell") ++ (optPkgs java "java") - ++ (optPkgs [python3] "python3") + ++ (optPkgs python3 "python3") ++ (optPkgs rustpkgs "rustpkgs") ++ (optPkgs server "server") ++ (optPkgs uniProgs "uniProgs") diff --git a/services/openssh.nix b/services/openssh.nix index 340372e..4114e3c 100644 --- a/services/openssh.nix +++ b/services/openssh.nix @@ -16,8 +16,7 @@ mkIf (elem "openssh" config.machine.services) { passwordAuthentication = false; permitRootLogin = "no"; extraConfig = let users = concatMapStrings (user: "${user.name} ") config.machine.administrators - + (if config.services.gitea.enable then (config.services.gitea.user + " ") else "") - + (if config.services.nix-serve.enable then "nix-ssh" else ""); + + (optionalString config.services.gitea.enable (config.services.gitea.user + " ")); in '' UsePAM no AllowUsers ${users}