dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit c6366c7191472ca87ed1c179dfa28c7b5255fcaf parent 0db709fcf5ac89ac0ff39daad072e427473a594e Author: maydayv7 <maydayv7@gmail.com> Date: Sun, 17 Dec 2023 17:12:05 +0530 refactor: Multiple Changes + Don't expose `nixosModules`: Doesn't make sense to expose them as individual units as they are inter-dependent + Rename `user.home` --> `user.homeConfig` + Move `modules/user/passwords` --> `users/passwords`
Diffstat:
31 files changed, 66 insertions(+), 80 deletions(-)
diff --git a/README.md b/README.md @@ -76,8 +76,8 @@ github:maydayv7/dotfiles ├───apps │ └───x86_64-linux │ ├───default: app +│ ├───install: app │ └───nixos: app -├───channels: package repositories ├───checks │ └───x86_64-linux │ ├───Device-gnome: derivation 'nixos-rebuild' @@ -104,19 +104,10 @@ github:maydayv7/dotfiles ├───nixosConfigurations │ ├───futura: NixOS configuration │ └───vortex: NixOS configuration -├───nixosModule: NixOS module -├───nixosModules -│ ├───apps: NixOS module -│ ├───base: NixOS module -│ ├───gui: NixOS module -│ ├───hardware: NixOS module -│ ├───nix: NixOS module -│ ├───secrets: NixOS module -│ ├───shell: NixOS module -│ └───user: NixOS module ├───overlays ├───packages │ └───x86_64-linux +│ ├───install: package 'install' │ └───nixos: package 'nixos' ├───templates │ └───default: template: My NixOS Configuration @@ -124,9 +115,6 @@ github:maydayv7/dotfiles └───Windows: Virtual Machine ``` -- `checks`: custom configuration checks -- `channels`: configured system package repositories - </details> ``` @@ -138,6 +126,7 @@ github:maydayv7/dotfiles │ ├── systems.nix │ └── vm ├── users +│ └── passwords ├── secrets ├── shells ├── checks @@ -159,7 +148,6 @@ github:maydayv7/dotfiles ├── nix ├── shell └── user - └── passwords ``` - `flake.nix`: toplevel configuration file and repository version control @@ -265,7 +253,7 @@ _Note that the `install` script automatically creates and labels all the require | SWAP Area | swap | swap | 4G | | DATA Partition | Files | ZFS | 10G | -> **Note:** +> [!Note] > For the `advanced` filesystem scheme only #### Procedure @@ -326,7 +314,7 @@ This repository makes use of [`GitHub Actions`](./checks/github/workflows) in or ### Home Manager -The [`home-manager`](https://github.com/nix-community/home-manager) module is used in tandem with the system configuration in order to define user-specific configuration. The `config.user.home` option has been declared in [`modules/user/default.nix`](./modules/user/default.nix) independent of the original module, from which the final configuration is built, in order to prevent infinite recursion while configuring multiple users per system. The system `config` can be accessed using the `sys` parameter in `home-manager` modules +The [`home-manager`](https://github.com/nix-community/home-manager) module is used in tandem with the system configuration in order to define user-specific configuration. The `config.user.homeConfig` option has been declared in [`modules/user/default.nix`](./modules/user/default.nix) independent of the original module, from which the final configuration is built, in order to prevent infinite recursion while configuring multiple users per system. The system `config` can be accessed using the `sys` parameter in `home-manager` modules ## Links diff --git a/devices/README.md b/devices/README.md @@ -4,7 +4,7 @@ The `devices` directory contains the core definitions for multiple PCs and vario #### Additional Options -These are the options that can be used in addition to the ones exposed by the `nixosModules`: +These are the options that can be used in addition to the ones exposed by the [`modules`](../modules/README.md): - `description`: System Description (to add to `config.system.nixos.label`) - `timezone`: System Time Zone - Ex. `"Asia/Kolkata"` @@ -13,5 +13,5 @@ These are the options that can be used in addition to the ones exposed by the `n - `kernelModules`: Additional Kernel Modules (to add to `config.boot.initrd.availableKernelModules`) - Ex. `[ "nvme" ]` - `imports`: Additional Configuration Files to import - Ex. `[ ./hardware-configuration.nix ]` - `format`: Generates Output for Specified Target Format (See [this](https://github.com/nix-community/nixos-generators#supported-formats) for the list of supported formats) -- `user` or `users` (---> `config.user.settings` <`home` ---> `homeConfig`>): Used to specify Device User/Multiple Users per Device - Ex. `users = [ { name "1"; } { name = "2"; } ]` +- `user` or `users` (---> `config.user.settings`): Used to specify Device User/Multiple Users per Device - Ex. `users = [ { name "1"; } { name = "2"; } ]` - `update`: Enable Automatic System Upgrades - Ex. `weekly` diff --git a/devices/flake.nix b/devices/flake.nix @@ -34,7 +34,7 @@ in { description = "Default User"; minimal = true; shells = null; - password = readFile ../modules/user/passwords/default; + password = readFile ../users/passwords/default; }; })) (map.modules.name ../modules/gui/desktop)) // {default = self.installMedia.xfce;}; diff --git a/flake.nix b/flake.nix @@ -164,7 +164,7 @@ systems = import inputs.systems; ## Custom Library Functions ## - lib = map.modules ./lib (file: import file lib); + lib = map.modules ./lib (file: import file lib) // {nixpkgs = lib;}; ## Configuration Template ## templates.default = with inputs.filters.lib; { diff --git a/modules/README.md b/modules/README.md @@ -1,8 +1,8 @@ ### Custom Configuration Modules -The `modules` directory contains custom-made pure Flakes-compatible configuration modules, which form the very core of my configuration for multiple PCs and various use-cases (If you have a working NixOS install, you can check it out using `github:maydayv7/dotfiles#nixosModules`). The following is a summary of all the present configuration options exposed by the particular module: +The `modules` directory contains custom-made pure Flakes-compatible configuration modules, which form the very core of my configuration for multiple PCs and various use-cases. The following is a summary of all the present configuration options exposed by the particular module: -[`nixosModules`](./default.nix) - +Configuration [Builder](./configuration.nix) - [`apps`](./apps): Module that configures various apps and/or environments - @@ -51,7 +51,7 @@ The `modules` directory contains custom-made pure Flakes-compatible configuratio - `groups`: Additional User Groups - Ex. `[ "wheel" ]` - `persist`: User Files to Preserve across Reboots (while using `advanced` File System Layout) - - `home`: User Home Configuration (Alias for `home-manager.users.${username}`) - + - `homeConfig`: Shared User Home Configuration (Alias for `home-manager.users.${username}`) - - `credentials`: Individual User Credentials - - `name`: Alternative (Work) User Name - `fulname`: Full User Name diff --git a/modules/apps/discord.nix b/modules/apps/discord.nix @@ -13,7 +13,7 @@ in { user = { persist.directories = [".config/BetterDiscord" ".config/discord"]; - home.home = { + homeConfig.home = { # Plugins file.".config/BetterDiscord/plugins" = { source = files.proprietary.discord; diff --git a/modules/apps/firefox.nix b/modules/apps/firefox.nix @@ -17,7 +17,7 @@ in { user = { persist.directories = [".cache/mozilla/firefox" ".mozilla/firefox"]; - home = { + homeConfig = { # File Associations xdg.mimeApps.defaultApplications = util.build.mime files.xdg.mime { browser = ["firefox.desktop"]; diff --git a/modules/apps/git/default.nix b/modules/apps/git/default.nix @@ -22,7 +22,7 @@ # Settings user = { persist.directories = [".config/gh"]; - home = { + homeConfig = { imports = [./user.nix]; # Hooks diff --git a/modules/apps/office.nix b/modules/apps/office.nix @@ -57,7 +57,7 @@ in { ".cache/zoom" ]; - home.home.file = { + homeConfig.home.file = { # Document Templates "Templates" = { source = files.templates; diff --git a/modules/apps/vscode.nix b/modules/apps/vscode.nix @@ -17,7 +17,7 @@ in { user = { persist.directories = [".config/Code" ".vscode"]; - home = { + homeConfig = { xdg.mimeApps.defaultApplications = util.build.mime files.xdg.mime { text = ["code.desktop"]; }; diff --git a/modules/configuration.nix b/modules/configuration.nix @@ -5,7 +5,6 @@ inherit (inputs) self; util = self.lib; inherit (self) files; - inherit (lib) fileContents makeOverridable mkIf; inherit (builtins) @@ -13,6 +12,7 @@ getAttr hashString map + removeAttrs replaceStrings substring ; @@ -50,12 +50,11 @@ in { autologin ? false, shell ? "bash", shells ? [], - home ? {}, + homeConfig ? {}, minimal ? false, }: { user.settings."${name}" = { - inherit name description uid autologin minimal; - homeConfig = home; + inherit name description uid autologin minimal homeConfig; extraGroups = groups; hashedPassword = mkIf (password != "") password; initialHashedPassword = mkIf (password == "") ""; @@ -82,7 +81,7 @@ in { # Modulated Configuration Imports imports = imports - ++ (attrValues self.nixosModules) + ++ attrValues (removeAttrs (util.map.modules ./. import) ["configuration"]) ++ map user' ( if (user != null) then [user] @@ -101,7 +100,7 @@ in { environment.systemPackages = [pkgs.custom.install]; # Disabled Modules - user.home = lib.mkForce {}; + user.homeConfig = lib.mkForce {}; sops.secrets = lib.mkForce {}; } ] diff --git a/modules/flake.nix b/modules/flake.nix @@ -1,4 +0,0 @@ -{util, ...}: { - ## Custom Configuration Modules ## - flake.nixosModules = builtins.removeAttrs (util.map.modules ./. import) ["configuration"]; -} diff --git a/modules/gui/desktop/gnome.nix b/modules/gui/desktop/gnome.nix @@ -9,7 +9,7 @@ with files; let inherit (config.gui) desktop; inherit (lib) mkIf mkForce mkMerge; - exists = app: builtins.elem app config.environment.systemPackages; + exists = app: builtins.elem app config.apps.list; in { ## GNOME Desktop Configuration ## config = mkIf (desktop == "gnome" || desktop == "gnome-minimal") (mkMerge [ @@ -63,7 +63,7 @@ in { }; ## User Configuration - user.home = { + user.homeConfig = { # Dconf Keys imports = [gnome.dconf]; @@ -96,32 +96,34 @@ in { video = ["io.github.celluloid_player.Celluloid.desktop"]; }; - home.file = { - # GTK+ Bookmarks - ".config/gtk-3.0/bookmarks".text = gtk.bookmarks; - - # Action Menu - ".config/guillotine.json".source = gnome.menu; + home.file = + { + # GTK+ Bookmarks + ".config/gtk-3.0/bookmarks".text = gtk.bookmarks; - # Window Tiling Stylesheet - ".config/forge/stylesheet/forge/stylesheet.css".source = gnome.tiling; + # Action Menu + ".config/guillotine.json".source = gnome.menu; - # Discord DNOME Theme - ".config/BetterDiscord/data/stable/custom.css" = - mkIf (exists pkgs.discord) - {text = ''@import "https://raw.githack.com/GeopJr/DNOME/dist/DNOME.css";'';}; + # Window Tiling Stylesheet + ".config/forge/stylesheet/forge/stylesheet.css".source = gnome.tiling; - # Firefox GNOME Theme - ".mozilla/firefox/default/chrome/userChrome.css".text = ''@import "${pkgs.custom.firefox-gnome-theme}/userChrome.css";''; - ".mozilla/firefox/default/chrome/userContent.css".text = firefox.theme; + # Firefox GNOME Theme + ".mozilla/firefox/default/chrome/userChrome.css".text = ''@import "${pkgs.custom.firefox-gnome-theme}/userChrome.css";''; + ".mozilla/firefox/default/chrome/userContent.css".text = firefox.theme; - # Workaround for NixOS/nixpkgs/47340 - ".mozilla/native-messaging-hosts/org.gnome.chrome_gnome_shell.json".source = "${pkgs.chrome-gnome-shell}/lib/mozilla/native-messaging-hosts/org.gnome.chrome_gnome_shell.json"; - }; + # Workaround for NixOS/nixpkgs/47340 + ".mozilla/native-messaging-hosts/org.gnome.chrome_gnome_shell.json".source = "${pkgs.chrome-gnome-shell}/lib/mozilla/native-messaging-hosts/org.gnome.chrome_gnome_shell.json"; + } + // + ## 3rd Party Apps Configuration + { + # Discord DNOME Theme + ".config/BetterDiscord/data/stable/custom.css" = + mkIf (exists "discord") {text = ''@import "https://raw.githack.com/GeopJr/DNOME/dist/DNOME.css";'';}; + }; - ## 3rd Party Apps Configuration # Code Editor - programs.vscode = mkIf (exists pkgs.vscode) { + programs.vscode = mkIf (exists "vscode") { extensions = [pkgs.vscode-extensions.piousdeer.adwaita-theme]; userSettings = { "workbench.colorTheme" = "Adwaita Dark"; diff --git a/modules/gui/desktop/xfce.nix b/modules/gui/desktop/xfce.nix @@ -8,7 +8,7 @@ }: with files; let inherit (config.gui) desktop wallpaper; - exists = app: builtins.elem app config.environment.systemPackages; + exists = app: builtins.elem app config.app.list; inherit (lib) mapAttrs' mkIf mkForce mkMerge nameValuePair replaceStrings; # GTK+ Theme @@ -118,7 +118,7 @@ in { }; ## User Configuration - user.home = { + user.homeConfig = { # GTK+ Theming stylix.targets.xfce.enable = false; gtk = @@ -169,7 +169,7 @@ in { ## 3rd Party Apps Configuration # Code Editor - programs.vscode = mkIf (exists pkgs.vscode) { + programs.vscode = mkIf (exists "vscode") { extensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [ { name = "arc-dark"; diff --git a/modules/gui/theme.nix b/modules/gui/theme.nix @@ -46,7 +46,7 @@ in { } ); - user.home.stylix.targets = { + user.homeConfig.stylix.targets = { bat.enable = true; vscode.enable = false; }; diff --git a/modules/gui/xorg.nix b/modules/gui/xorg.nix @@ -1,7 +1,7 @@ {files, ...}: { ## XORG Configuration ## config = { - user.home.xresources.extraConfig = files.xorg; + user.homeConfig.xresources.extraConfig = files.xorg; services.xserver = { enable = true; autorun = true; diff --git a/modules/hardware/README.md b/modules/hardware/README.md @@ -10,7 +10,7 @@ To configure Secure Boot, first install the system by using the `efi` loader, th _If the `advanced` filesystem scheme is used, the keys need to be created after `/etc/secureboot` is persisted_ -> **Note:** +> [!Note] > Secure Boot is only supported in EFI Mode ### File System diff --git a/modules/hardware/laptop.nix b/modules/hardware/laptop.nix @@ -16,7 +16,7 @@ in { ''; # Audio - user.home.home.file.".config/autostart/audio-tweaks.desktop".text = '' + user.homeConfig.home.file.".config/autostart/audio-tweaks.desktop".text = '' [Desktop Entry] Type=Application Name=audio-tweaks diff --git a/modules/nix/index.nix b/modules/nix/index.nix @@ -8,7 +8,7 @@ ## Package Indexer ## config = lib.mkIf config.nix.index { - user.home = { + user.homeConfig = { imports = [inputs.index.hmModules.nix-index]; programs.nix-index-database.comma.enable = true; }; diff --git a/modules/shell/default.nix b/modules/shell/default.nix @@ -61,7 +61,7 @@ in { directories = [".local/share/direnv"]; }; - home = { + homeConfig = { programs = listToAttrs (map (shell: nameValuePair shell diff --git a/modules/user/default.nix b/modules/user/default.nix @@ -22,7 +22,7 @@ types ; - inherit (config.user) groups home settings; + inherit (config.user) groups homeConfig settings; # Merged Sets Type mergedAttrs = mkOptionType { @@ -39,14 +39,14 @@ in { modules = if (all (value: value.minimal) (attrValues settings)) then [{home.stateVersion = config.system.stateVersion;}] - else home; + else homeConfig; }); }; # Configuration Options user = { - home = mkOption { - description = "User Home Configuration"; + homeConfig = mkOption { + description = "Shared User Home Configuration"; type = mergedAttrs; default = {}; }; diff --git a/modules/user/home.nix b/modules/user/home.nix @@ -14,7 +14,7 @@ XDG_BIN_HOME = "$HOME/.local/bin"; }; - user.home = { + user.homeConfig = { imports = [../../users]; # Package Configuration diff --git a/modules/user/passwords/.keep b/modules/user/passwords/.keep diff --git a/modules/user/security.nix b/modules/user/security.nix @@ -10,6 +10,7 @@ inherit (config.sops) secrets; inherit (config.user) settings; enable = all (value: value.minimal) (attrValues settings); + directory = ../../users/passwords; in { ## Security Settings ## config = { @@ -20,7 +21,7 @@ in { then (mkForce {}) else util.map.secrets { - directory = ./passwords; + inherit directory; neededForUsers = true; }; @@ -69,7 +70,7 @@ in { group = "users"; extraGroups = ["wheel"]; useDefaultShell = true; - initialHashedPassword = readFile ./passwords/default; + initialHashedPassword = readFile (directory + "/default"); }; }; }; diff --git a/secrets/README.md b/secrets/README.md @@ -1,5 +1,5 @@ ### Credentials -The authentication credentials are managed using [`sops-nix`](https://github.com/Mic92/sops-nix) at `secrets`. The [`sops`](https://github.com/mozilla/sops) encrypted secrets (using GPG authentication) are stored at multiple places, like in this directory, as well as [`modules/user/passwords`](../modules/user/passwords). User passwords are made using the command `mkpasswd -m sha-512` and specified using the `hashedPasswordFile` option. The `sops` encrypted secrets are of `binary` format (and have the extension `.secret`) and can be conveniently managed using the [`nixos`](../scripts/README.md) `secret` command. The `keys` directory contains the _public_ User GPG Keys which are automatically imported +The authentication credentials are managed using [`sops-nix`](https://github.com/Mic92/sops-nix) at `secrets`. The [`sops`](https://github.com/mozilla/sops) encrypted secrets (using GPG authentication) are stored at multiple places, like in this directory, as well as [`users/passwords`](../users/passwords). User passwords are made using the command `mkpasswd -m sha-512` and specified using the `hashedPasswordFile` option. The `sops` encrypted secrets are of `binary` format (and have the extension `.secret`) and can be conveniently managed using the [`nixos`](../scripts/README.md) `secret` command. The `keys` directory contains the _public_ User GPG Keys which are automatically imported To create a secret, use the `nixos secret create` command, and append the directory along with requisite access permissions to the `secrets.yaml` file. Device-specific secrets are automatically imported, if a directory (with the same name as the device `HOSTNAME`) containing them is present in this directory diff --git a/secrets/secrets.yaml b/secrets/secrets.yaml @@ -6,7 +6,7 @@ creation_rules: key_groups: - pgp: - *v7 - - path_regex: modules/user/passwords/.*$ + - path_regex: users/passwords/.*$ key_groups: - pgp: - *v7 diff --git a/users/README.md b/users/README.md @@ -1,5 +1,5 @@ ### Users -The `users` directory contains the individual user-specific configurations for multiple users (of a single PC or multiple ones). To add a new user, simply create a configuration file for it (name of the file/directory must be the same as the `username` of the user) and write down the configuration using the `home-manager` module [options](https://mipmip.github.io/home-manager-option-search/). The configuration is automatically imported, if present. Do not forget to create a `USERNAME.secret` file (using `nixos secret create`) in [`modules/user/passwords`](../modules/user/passwords/) containing the user password +The `users` directory contains the individual user-specific configurations for multiple users (of a single PC or multiple ones). To add a new user, simply create a configuration file for it (name of the file/directory must be the same as the `username` of the user) and write down the configuration using the `home-manager` module [options](https://mipmip.github.io/home-manager-option-search/). The configuration is automatically imported, if present. Do not forget to create a `USERNAME.secret` file (using `nixos secret create`) in [`passwords`](./passwords) containing the user password There is also a `recovery` user defined in the system configuration as a [specialisation](https://nixos.wiki/wiki/Specialisation) diff --git a/modules/user/passwords/default b/users/passwords/default diff --git a/modules/user/passwords/navya.secret b/users/passwords/navya.secret diff --git a/modules/user/passwords/root.secret b/users/passwords/root.secret diff --git a/modules/user/passwords/v7.secret b/users/passwords/v7.secret