diff --git a/flake.lock b/flake.lock index 8ee6076f..e9b93c2a 100644 --- a/flake.lock +++ b/flake.lock @@ -20,7 +20,167 @@ "type": "github" } }, + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "deploy": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "digga", + "latest" + ], + "utils": [ + "digga", + "flake-utils" + ] + }, + "locked": { + "lastModified": 1632822684, + "narHash": "sha256-lt7eayYmgsD5OQwpb1XYfHpxttn43bWo7G7hIJs+zJw=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "9a02de4373e0ec272d08a417b269a28ac8b961b4", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "devshell": { + "locked": { + "lastModified": 1632436039, + "narHash": "sha256-OtITeVWcKXn1SpVEnImpTGH91FycCskGBPqmlxiykv4=", + "owner": "numtide", + "repo": "devshell", + "rev": "7a7a7aa0adebe5488e5abaec688fd9ae0f8ea9c6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "digga": { + "inputs": { + "blank": "blank", + "deploy": "deploy", + "devshell": "devshell", + "flake-utils": "flake-utils", + "flake-utils-plus": "flake-utils-plus", + "home-manager": "home-manager", + "latest": "latest", + "nix": "nix", + "nixlib": [ + "digga", + "nixpkgs" + ], + "nixos-generators": "nixos-generators", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1634161492, + "narHash": "sha256-7OZz7DqAhO+3axY68xsMXAyD+b5gJgVXuKjslTSCM3Y=", + "owner": "divnix", + "repo": "digga", + "rev": "a55450a16d362b6e1c50bb4025aaa604b385d3ba", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "digga", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils-plus": { + "inputs": { + "flake-utils": [ + "digga", + "flake-utils" + ] + }, + "locked": { + "lastModified": 1630859749, + "narHash": "sha256-qkoU2rIbbP2+T0dfcqXW35GCWNsi0Y1IgN9BELmt4Zo=", + "owner": "divnix", + "repo": "flake-utils-plus", + "rev": "a4e267e3fc87e60c5029c6c3855935ff1ff3018e", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "flake-utils-plus", + "type": "github" + } + }, "home-manager": { + "inputs": { + "nixpkgs": [ + "digga", + "nixlib" + ] + }, + "locked": { + "lastModified": 1629347633, + "narHash": "sha256-FGZJ7lmTAMIkjdrh6dIPck5HuB4KMT2GgDV5ZjiCWoc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "bf6b85136b47ab1a76df4a90ea4850871147494a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -40,7 +200,103 @@ "type": "github" } }, + "latest": { + "locked": { + "lastModified": 1632660378, + "narHash": "sha256-sjA8eQlnyDjDLyAyq3XlJmN0nqW0ftl/pb7VnMg86L0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "31ffc50c571e6683e9ecc9dbcbd4a8e9914b4497", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1617481909, + "narHash": "sha256-SqnfOFuLuVRRNeVJr1yeEPJue/qWoCp5N6o5Kr///p4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "148f9b2f586c41b7e36e73009db43ea68c7a1a4d", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "ref": "VERSION_0_8_4", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": [ + "digga", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1630335771, + "narHash": "sha256-eljjEPJdLK3aDskF7qX4YM/6KCq+w9nr+IKhrKW/AIQ=", + "owner": "nixos", + "repo": "nix", + "rev": "50a35860ee9237d341948437c5f70a7f0987d393", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nix", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": [ + "digga", + "nixlib" + ], + "nixpkgs": [ + "digga", + "blank" + ] + }, + "locked": { + "lastModified": 1624973746, + "narHash": "sha256-11JbJRduNwyf556gndGErR5/12ceyHOHBfEuha5Vws4=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "022ef440af8dc237ab1f59fa363cb1e25783ec3e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1628203131, + "narHash": "sha256-jQgXeJ9NQQS0Eobb/qQOvS+RRULkqRikAeXkkFKOPDA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "178da37860823d35e801c7df2f73d7866d3d598a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1637593665, "narHash": "sha256-R7jKS7A+0tZS8qD5pBr1UFcMiTdsw5bfoxgXbYsoWhM=", @@ -59,8 +315,9 @@ "root": { "inputs": { "agenix": "agenix", - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "digga": "digga", + "home-manager": "home-manager_2", + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index b20deb29..790ce798 100644 --- a/flake.nix +++ b/flake.nix @@ -8,11 +8,13 @@ agenix.url = "github:ryantm/agenix"; agenix.inputs.nixpkgs.follows = "nixpkgs"; + + digga.url = "github:divnix/digga"; }; outputs = inputs@{ self, nixpkgs, ... }: let - lib = nixpkgs.lib.extend + libExtended = nixpkgs.lib.extend (final: prev: (import ./lib { inherit inputs; lib = final; })); hostDefaultConfig = { @@ -36,16 +38,17 @@ ''; }; in { - inherit lib; + # Exposes only my library with the custom functions to make it easier to include in other flakes. + lib = import ./lib { inherit inputs; lib = nixpkgs.lib; }; # A list of NixOS configurations from the `./hosts` folder. # It also has some sensible default configurations. nixosConfigurations = - lib.mapAttrs (host: path: lib.mkHost path hostDefaultConfig) (lib.filesToAttr ./hosts); + libExtended.mapAttrs (host: path: libExtended.mkHost path hostDefaultConfig) (libExtended.filesToAttr ./hosts); # We're going to make our custom modules available for our flake. Whether # or not this is a good thing is debatable, I just want to test it. nixosModules = - lib.mapAttrs (_: path: import path) (lib.filesToAttr ./modules); + libExtended.mapAttrs (_: path: import path) (libExtended.filesToAttr ./modules); }; } diff --git a/hosts/ni/default.nix b/hosts/ni/default.nix index b4e9b7a4..57cc1d6e 100644 --- a/hosts/ni/default.nix +++ b/hosts/ni/default.nix @@ -26,12 +26,12 @@ neovim.enable = true; }; themes.a-happy-gnome.enable = true; + users.users = [ "foo-dogsquared" ]; }; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - # Set your time zone. time.timeZone = "Asia/Manila"; @@ -54,12 +54,6 @@ # Enable touchpad support (enabled default in most desktopManager). hardware.opentabletdriver.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.foo-dogsquared = { - isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - }; - # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ git wget brave lf fd ripgrep ]; diff --git a/lib/default.nix b/lib/default.nix index 76ed162b..9102c617 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -8,6 +8,14 @@ in rec { inside of a directory. While it can recurse into directories, it will stop once it detects `default.nix` inside. + Signature: + path -> attrset + Where: + - `path` is the starting point. + Returns: + An attribute set. The keys are the basename of the file or the directory + and the values are the filepath to the Nix file. + !!! Implementation detail is based from https://github.com/divnix/digga/blob/main/src/importers.nix looking at it multiple times for the purpose of familiarizing myself to coding in Nix @@ -42,9 +50,17 @@ in rec { This is only suitable if you intend to use all of the modules in a given directory. + Signature: + path -> attrset + Where: + - `path` is the starting point of the scan. + Returns: + An attribute set. The keys are the basename for each Nix file/directory + and the values are the path to the file. + Examples: - filesToAttrRec ./modules - => { agenix = /home/foo-dogsquared/nixos-config/modules/agenix.nix; archiving = /home/foo-dogsquared/nixos-config/modules/archiving.nix; desktop = /home/foo-dogsquared/nixos-config/modules/desktop.nix; dev = /home/foo-dogsquared/nixos-config/modules/dev.nix; editors = /home/foo-dogsquared/nixos-config/modules/editors.nix; themes = { a-happy-gnome = /home/foo-dogsquared/nixos-config/modules/themes/a-happy-gnome; default = /home/foo-dogsquared/nixos-config/modules/themes/default.nix; }; } + filesToAttrRec ./modules + => { agenix = /home/foo-dogsquared/nixos-config/modules/agenix.nix; archiving = /home/foo-dogsquared/nixos-config/modules/archiving.nix; desktop = /home/foo-dogsquared/nixos-config/modules/desktop.nix; dev = /home/foo-dogsquared/nixos-config/modules/dev.nix; editors = /home/foo-dogsquared/nixos-config/modules/editors.nix; themes = { a-happy-gnome = /home/foo-dogsquared/nixos-config/modules/themes/a-happy-gnome; default = /home/foo-dogsquared/nixos-config/modules/themes/default.nix; }; } */ filesToAttrRec = dir: let @@ -64,6 +80,15 @@ in rec { It will automate some of the things such as making the last component of the path as the hostname. + Signature: + path -> attrset -> NixOS configuration + Where: + - `path` is a path to a Nix file for the host; the basename of the file + is also used as the hostname + - `attrset` is the attribute set to be included in the host configuration + Returns: + An attribute set from the `lib.nixosSystem` from `nixpkgs` flake. + Example: mkHost ./hosts/june {} => { ... } # NixOS configuration attrset diff --git a/modules/desktop.nix b/modules/desktop.nix index 09dd525f..9c10b3fc 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -56,11 +56,35 @@ in { fontconfig = { enable = true; includeUserConf = true; + + defaultFonts = { + monospace = [ "Iosevka" "Source Code Pro" ]; + sansSerif = [ "Source Sans Pro" "Noto Sans" ]; + serif = [ "Source Serif Pro" "Noto Serif" ]; + }; }; fonts = with pkgs; [ + iosevka + # 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 + + # Math fonts + stix-two + xits-math ]; }; }) diff --git a/modules/editors.nix b/modules/editors.nix index b7f36536..77a8f04d 100644 --- a/modules/editors.nix +++ b/modules/editors.nix @@ -20,6 +20,7 @@ in { git ripgrep gnutls + emacs-all-the-icons-fonts # Optional dependencies. fd diff --git a/modules/themes/a-happy-gnome/default.nix b/modules/themes/a-happy-gnome/default.nix index 79bb47f8..17aaccc7 100644 --- a/modules/themes/a-happy-gnome/default.nix +++ b/modules/themes/a-happy-gnome/default.nix @@ -15,6 +15,9 @@ in services.gnome.chrome-gnome-shell.enable = true; environment.systemPackages = with pkgs; [ + # It is required for custom menus in extensions. + gnome-menus + gnomeExtensions.arcmenu gnomeExtensions.x11-gestures gnomeExtensions.gsconnect diff --git a/modules/users.nix b/modules/users.nix new file mode 100644 index 00000000..f222fd28 --- /dev/null +++ b/modules/users.nix @@ -0,0 +1,26 @@ +{ inputs, config, options, lib, ... }: + +let + cfg = config.modules.users; + users = lib.attrNames (lib.filesToAttr ../users); + nonexistentUsers = lib.filter (name: !lib.elem name users) cfg.users; +in +{ + options.modules.users = { + users = lib.mkOption { + default = []; + type = with lib.types; listOf str; + description = "A list of users from the `./users` directory to be included in the NixOS config."; + }; + }; + + imports = [ inputs.home-manager.nixosModules.home-manager ]; + config = lib.mkMerge [ + ({ + assertions = [{ + assertion = (builtins.length nonexistentUsers) > 1; + message = "${lib.concatStringsSep "," users} ${lib.concatStringsSep "," nonexistentUsers} is not found in the directory."; + }]; + }) + ]; +} diff --git a/users/README.adoc b/users/README.adoc new file mode 100644 index 00000000..22fd1ff7 --- /dev/null +++ b/users/README.adoc @@ -0,0 +1,5 @@ += Users +:toc: + +This is where user-specific configurations comes in. +Ideally, diff --git a/users/foo-dogsquared/default.nix b/users/foo-dogsquared/default.nix new file mode 100644 index 00000000..6cf4e767 --- /dev/null +++ b/users/foo-dogsquared/default.nix @@ -0,0 +1,10 @@ +{ + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.foo-dogsquared = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + home-manager.useUserPackages = true; + home-manager.useGlobalPkgs = true; +}