From 2cf96cb1f35460535943598709ad6836a21c058a Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Mon, 29 Nov 2021 17:58:02 +0800 Subject: [PATCH] Format the Nix files --- flake.nix | 2 ++ lib/default.nix | 27 ++++++++++++++------------- modules/desktop.nix | 37 ++++++++++++++++++------------------- modules/users.nix | 39 ++++++++++++++++++++------------------- 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/flake.nix b/flake.nix index 4b922ac7..fdf8f6bc 100644 --- a/flake.nix +++ b/flake.nix @@ -86,5 +86,7 @@ }) (libExtended.filterAttrs (n: v: !libExtended.elem n excludedModules) (libExtended.filesToAttr ./users)); + packages = forAllSystems + (system: import ./pkgs { pkgs = import nixpkgs { inherit system; }; }); }; } diff --git a/lib/default.nix b/lib/default.nix index 55a3000b..287a0c86 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -117,22 +117,23 @@ in rec { ++ (lib.mapAttrsToList (n: v: import v) (filesToAttr ../modules)); }; - /* Return an attribute set of valid users from a given list of users. + /* Return an attribute set of valid users from a given list of users. - Signature: - list -> attrset - Where: - - `list` is a list of usernames as strings - - `attrset` is a set of valid users with the name as the key and the path as the value. - Example: - # Assuming only 'foo-dogsquared' is the existing user. - getUsers [ "foo-dogsquared" "archie" "brad" ] - => { foo-dogsquared = /home/foo-dogsquared/projects/nixos-config/users/foo-dogsquared; } - */ - getUsers = users: + Signature: + list -> attrset + Where: + - `list` is a list of usernames as strings + - `attrset` is a set of valid users with the name as the key and the path as the value. + Example: + # Assuming only 'foo-dogsquared' is the existing user. + getUsers [ "foo-dogsquared" "archie" "brad" ] + => { foo-dogsquared = /home/foo-dogsquared/projects/nixos-config/users/foo-dogsquared; } + */ + getUsers = users: let userModules = filesToAttr ../users; - validUsers = lib.filter (user: lib.elem user (lib.attrNames userModules)) users; + validUsers = + lib.filter (user: lib.elem user (lib.attrNames userModules)) users; in lib.filterAttrs (n: _: lib.elem n validUsers) userModules; /* Create an attribute set from two lists (or a zip). diff --git a/modules/desktop.nix b/modules/desktop.nix index 9c10b3fc..e6138cd1 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -64,28 +64,27 @@ in { }; }; - fonts = with pkgs; - [ - iosevka + fonts = with pkgs; [ + iosevka - # Noto font family - noto-fonts - noto-fonts-cjk - noto-fonts-extra - noto-fonts-emoji + # Noto font family + noto-fonts + noto-fonts-cjk + noto-fonts-extra + noto-fonts-emoji - # Adobe Source font family - source-code-pro - source-sans-pro - source-han-sans - source-serif-pro - source-han-serif - source-han-mono + # Adobe Source font family + source-code-pro + source-sans-pro + source-han-sans + source-serif-pro + source-han-serif + source-han-mono - # Math fonts - stix-two - xits-math - ]; + # Math fonts + stix-two + xits-math + ]; }; }) ]); diff --git a/modules/users.nix b/modules/users.nix index 4f66b94c..bdf8ff31 100644 --- a/modules/users.nix +++ b/modules/users.nix @@ -9,29 +9,28 @@ let nonexistentUsers = lib.filter (name: !lib.elem name users) cfg.users; mkUser = user: path: - let - userModule = import path; - defaultConfig = { - home.username = user; - home.homeDirectory = "/home/${user}"; + let + userModule = import path; + defaultConfig = { + home.username = user; + home.homeDirectory = "/home/${user}"; - xdg.enable = true; + xdg.enable = true; + }; + in { + users.users.${user} = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + home-manager.users.${user} = userModule // defaultConfig; }; - in - { - users.users.${user} = { - isNormalUser = true; - extraGroups = [ "wheel" ]; - }; - home-manager.users.${user} = userModule // defaultConfig; - }; -in -{ +in { options.modules.users = { users = lib.mkOption { - default = []; + default = [ ]; type = with lib.types; listOf str; - description = "A list of users from the `./users` directory to be included in the NixOS config."; + description = + "A list of users from the `./users` directory to be included in the NixOS config."; }; }; @@ -52,7 +51,9 @@ in config = { assertions = [{ assertion = (builtins.length nonexistentUsers) < 1; - message = "${lib.concatMapStringsSep ", " (u: "'${u}'") nonexistentUsers} is not found in the `./users` directory."; + message = "${ + lib.concatMapStringsSep ", " (u: "'${u}'") nonexistentUsers + } is not found in the `./users` directory."; }]; }; }