diff --git a/apps/run-workflow-with-vm/configuration.nix b/apps/run-workflow-with-vm/configuration.nix index 03186894..a1088e71 100644 --- a/apps/run-workflow-with-vm/configuration.nix +++ b/apps/run-workflow-with-vm/configuration.nix @@ -8,15 +8,15 @@ let config' = import { }; lib = pkgs.lib.extend (import ); - modules = import { inherit lib; isInternal = true; }; - hmModules = import { inherit lib; isInternal = true; }; extraArgs = { nix-colors = import { }; }; in import { inherit lib; - modules = modules ++ extraModules ++ [ + modules = extraModules ++ [ + + @@ -37,7 +37,9 @@ import { ]; config = { - home-manager.sharedModules = hmModules ++ [ + home-manager.sharedModules = [ + + ({ config, lib, ... }: { _module.args = extraArgs; diff --git a/configs/flake-parts/home-manager.nix b/configs/flake-parts/home-manager.nix index d26c4e25..f5c61be5 100644 --- a/configs/flake-parts/home-manager.nix +++ b/configs/flake-parts/home-manager.nix @@ -39,32 +39,32 @@ }; # This is to be used by the NixOS `home-manager.sharedModules` anyways. - sharedModules = + sharedModules = [ # Import our own custom modules from here.. - import ../../modules/home-manager { inherit lib; isInternal = true; } + ../../modules/home-manager + ../../modules/home-manager/_private # ...plus a bunch of third-party modules. - ++ [ - inputs.sops-nix.homeManagerModules.sops - inputs.nix-index-database.hmModules.nix-index + inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index - # The default shared config for our home-manager configurations. This - # is also to be used for sharing modules among home-manager users from - # NixOS configurations with `nixpkgs.useGlobalPkgs` set to `true` so - # avoid setting nixpkgs-related options here. - ({ pkgs, config, lib, ... }: { - # Set some extra, yeah? - _module.args = defaultExtraArgs; + # The default shared config for our home-manager configurations. This + # is also to be used for sharing modules among home-manager users from + # NixOS configurations with `nixpkgs.useGlobalPkgs` set to `true` so + # avoid setting nixpkgs-related options here. + ({ pkgs, config, lib, ... }: { + # Set some extra, yeah? + _module.args = defaultExtraArgs; - manual = lib.mkDefault { - html.enable = true; - json.enable = true; - manpages.enable = true; - }; + manual = lib.mkDefault { + html.enable = true; + json.enable = true; + manpages.enable = true; + }; - home.stateVersion = lib.mkDefault "23.11"; - }) - ]; + home.stateVersion = lib.mkDefault "23.11"; + }) + ]; standaloneConfigModules = [ defaultNixConf @@ -83,6 +83,6 @@ flake = { # Extending home-manager with my custom modules, if anyone cares. - homeModules.default = import ../../modules/home-manager { inherit lib; }; + homeModules.default = ../../modules/home-manager; }; } diff --git a/configs/flake-parts/nixos.nix b/configs/flake-parts/nixos.nix index 371d757a..914b18f9 100644 --- a/configs/flake-parts/nixos.nix +++ b/configs/flake-parts/nixos.nix @@ -88,94 +88,90 @@ # Only use imports as minimally as possible with the absolute # requirements of a host. On second thought, only on flakes with # optional NixOS modules. - sharedModules = - # Append with our custom NixOS modules from the modules folder. - import ../../modules/nixos { inherit lib; isInternal = true; } + sharedModules = [ + # Import our custom modules. + ../../modules/nixos + ../../modules/nixos/_private - # Then, make the most with the modules from the flake inputs. Take - # note importing some modules such as home-manager are as part of the - # declarative host config so be sure to check out - # `hostSpecificModule` function as well as the declarative host setup. - ++ [ - inputs.nix-index-database.nixosModules.nix-index - inputs.sops-nix.nixosModules.sops - inputs.disko.nixosModules.disko + inputs.nix-index-database.nixosModules.nix-index + inputs.sops-nix.nixosModules.sops + inputs.disko.nixosModules.disko - defaultNixConf + defaultNixConf - # The default shared configuration for the entire list of hosts for - # this cluster. Take note to only set as minimal configuration as - # possible since we're also using this with the stable version of - # nixpkgs. - ({ options, config, lib, pkgs, ... }: { - # Initialize some of the XDG base directories ourselves since it is - # used by NIX_PROFILES to properly link some of them. - environment.sessionVariables = { - XDG_CACHE_HOME = "$HOME/.cache"; - XDG_CONFIG_HOME = "$HOME/.config"; - XDG_DATA_HOME = "$HOME/.local/share"; - XDG_STATE_HOME = "$HOME/.local/state"; - }; + # The default shared configuration for the entire list of hosts for + # this cluster. Take note to only set as minimal configuration as + # possible since we're also using this with the stable version of + # nixpkgs. + ({ options, config, lib, pkgs, ... }: { + # Initialize some of the XDG base directories ourselves since it is + # used by NIX_PROFILES to properly link some of them. + environment.sessionVariables = { + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_DATA_HOME = "$HOME/.local/share"; + XDG_STATE_HOME = "$HOME/.local/state"; + }; - _module.args = defaultExtraArgs; + _module.args = defaultExtraArgs; - # Find Nix files with these! Even if nix-index is already enabled, it - # is better to make it explicit. - programs.command-not-found.enable = false; - programs.nix-index.enable = true; + # Find Nix files with these! Even if nix-index is already enabled, it + # is better to make it explicit. + programs.command-not-found.enable = false; + programs.nix-index.enable = true; - # BOOOOOOOOOOOOO! Somebody give me a tomato! - services.xserver.excludePackages = with pkgs; [ xterm ]; + # BOOOOOOOOOOOOO! Somebody give me a tomato! + services.xserver.excludePackages = with pkgs; [ xterm ]; - # Append with the default time servers. It is becoming more unresponsive as - # of 2023-10-28. - networking.timeServers = [ - "europe.pool.ntp.org" - "asia.pool.ntp.org" - "time.cloudflare.com" - ] ++ options.networking.timeServers.default; + # Append with the default time servers. It is becoming more unresponsive as + # of 2023-10-28. + networking.timeServers = [ + "europe.pool.ntp.org" + "asia.pool.ntp.org" + "time.cloudflare.com" + ] ++ options.networking.timeServers.default; - # Disable channel state files. This shouldn't break any existing - # programs as long as we manage them NIX_PATH ourselves. - nix.channel.enable = lib.mkDefault false; + # Disable channel state files. This shouldn't break any existing + # programs as long as we manage them NIX_PATH ourselves. + nix.channel.enable = lib.mkDefault false; - # Set several paths for the traditional channels. - nix.nixPath = lib.mkIf config.nix.channel.enable - (lib.mapAttrsToList - (name: source: - let - name' = if (name == "self") then "config" else name; - in - "${name'}=${source}") - inputs - ++ [ - "/nix/var/nix/profiles/per-user/root/channels" - ]); + # Set several paths for the traditional channels. + nix.nixPath = lib.mkIf config.nix.channel.enable + (lib.mapAttrsToList + (name: source: + let + name' = if (name == "self") then "config" else name; + in + "${name'}=${source}") + inputs + ++ [ + "/nix/var/nix/profiles/per-user/root/channels" + ]); - # Please clean your temporary crap. - boot.tmp.cleanOnBoot = lib.mkDefault true; + # Please clean your temporary crap. + boot.tmp.cleanOnBoot = lib.mkDefault true; - # We live in a Unicode world and dominantly English in technical fields so we'll - # have to go with it. - i18n.defaultLocale = lib.mkDefault "en_US.UTF-8"; + # We live in a Unicode world and dominantly English in technical fields so we'll + # have to go with it. + i18n.defaultLocale = lib.mkDefault "en_US.UTF-8"; - # Enabling some things for sops. - programs.gnupg.agent = lib.mkDefault { - enable = true; - enableSSHSupport = true; - }; - services.openssh.enable = lib.mkDefault true; + # Enabling some things for sops. + programs.gnupg.agent = lib.mkDefault { + enable = true; + enableSSHSupport = true; + }; + services.openssh.enable = lib.mkDefault true; - # It's following the 'nixpkgs' flake input which should be in unstable - # branches. Not to mention, most of the system configurations should - # have this attribute set explicitly by default. - system.stateVersion = lib.mkDefault "23.11"; - }) - ]; + # It's following the 'nixpkgs' flake input which should be in unstable + # branches. Not to mention, most of the system configurations should + # have this attribute set explicitly by default. + system.stateVersion = lib.mkDefault "23.11"; + }) + ]; }; flake = { # Listing my public NixOS modules if anyone cares. - nixosModules.default = import ../../modules/nixos { inherit lib; }; + nixosModules.default = ../../modules/nixos; }; } diff --git a/modules/README.adoc b/modules/README.adoc index b296432f..67cd09e5 100644 --- a/modules/README.adoc +++ b/modules/README.adoc @@ -15,6 +15,7 @@ It's better that we lay this out with a list of guidelines. * Custom modules are typically classified as private and public modules. Private (or internal) modules are simply modules meant to be used in this project and nowhere else. Public modules are meant to be used by others (but not necessarily mean we have to support or maintain these for them). +For convenience, these private modules are stored in `_private` folder of each environment. * As such, public modules are not allowed to use the private library and modules. Only the private modules can. diff --git a/modules/home-manager/_private/default.nix b/modules/home-manager/_private/default.nix new file mode 100644 index 00000000..0c5d7c4e --- /dev/null +++ b/modules/home-manager/_private/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./profiles/desktop.nix + ./profiles/dev.nix + ./profiles/editors.nix + ./profiles/i18n.nix + ]; +} diff --git a/modules/home-manager/profiles/desktop.nix b/modules/home-manager/_private/profiles/desktop.nix similarity index 100% rename from modules/home-manager/profiles/desktop.nix rename to modules/home-manager/_private/profiles/desktop.nix diff --git a/modules/home-manager/profiles/dev.nix b/modules/home-manager/_private/profiles/dev.nix similarity index 100% rename from modules/home-manager/profiles/dev.nix rename to modules/home-manager/_private/profiles/dev.nix diff --git a/modules/home-manager/profiles/editors.nix b/modules/home-manager/_private/profiles/editors.nix similarity index 100% rename from modules/home-manager/profiles/editors.nix rename to modules/home-manager/_private/profiles/editors.nix diff --git a/modules/home-manager/profiles/i18n.nix b/modules/home-manager/_private/profiles/i18n.nix similarity index 100% rename from modules/home-manager/profiles/i18n.nix rename to modules/home-manager/_private/profiles/i18n.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 32c1eff8..80c349cb 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,11 +1,5 @@ -{ lib - - # Import the private modules -, isInternal ? false -}: - -let - modules = [ +{ + imports = [ ./files/mutable-files.nix ./programs/pop-launcher.nix ./services/archivebox.nix @@ -17,12 +11,4 @@ let ./services/plover.nix ./services/yt-dlp.nix ]; - privateModules = [ - ./profiles/desktop.nix - ./profiles/dev.nix - ./profiles/editors.nix - ./profiles/i18n.nix - ]; -in -modules -++ (lib.optionals isInternal privateModules) +} diff --git a/modules/nixos/_private/default.nix b/modules/nixos/_private/default.nix new file mode 100644 index 00000000..a7b7b597 --- /dev/null +++ b/modules/nixos/_private/default.nix @@ -0,0 +1,13 @@ +{ + imports = [ + ./profiles/archiving.nix + ./profiles/browsers.nix + ./profiles/desktop.nix + ./profiles/dev.nix + ./profiles/filesystem.nix + ./profiles/gaming.nix + ./profiles/i18n.nix + ./profiles/server.nix + ./profiles/vpn.nix + ]; +} diff --git a/modules/nixos/profiles/README.adoc b/modules/nixos/_private/profiles/README.adoc similarity index 100% rename from modules/nixos/profiles/README.adoc rename to modules/nixos/_private/profiles/README.adoc diff --git a/modules/nixos/profiles/archiving.nix b/modules/nixos/_private/profiles/archiving.nix similarity index 100% rename from modules/nixos/profiles/archiving.nix rename to modules/nixos/_private/profiles/archiving.nix diff --git a/modules/nixos/profiles/browsers.nix b/modules/nixos/_private/profiles/browsers.nix similarity index 100% rename from modules/nixos/profiles/browsers.nix rename to modules/nixos/_private/profiles/browsers.nix diff --git a/modules/nixos/profiles/desktop.nix b/modules/nixos/_private/profiles/desktop.nix similarity index 100% rename from modules/nixos/profiles/desktop.nix rename to modules/nixos/_private/profiles/desktop.nix diff --git a/modules/nixos/profiles/dev.nix b/modules/nixos/_private/profiles/dev.nix similarity index 100% rename from modules/nixos/profiles/dev.nix rename to modules/nixos/_private/profiles/dev.nix diff --git a/modules/nixos/profiles/filesystem.nix b/modules/nixos/_private/profiles/filesystem.nix similarity index 100% rename from modules/nixos/profiles/filesystem.nix rename to modules/nixos/_private/profiles/filesystem.nix diff --git a/modules/nixos/profiles/gaming.nix b/modules/nixos/_private/profiles/gaming.nix similarity index 100% rename from modules/nixos/profiles/gaming.nix rename to modules/nixos/_private/profiles/gaming.nix diff --git a/modules/nixos/profiles/i18n.nix b/modules/nixos/_private/profiles/i18n.nix similarity index 100% rename from modules/nixos/profiles/i18n.nix rename to modules/nixos/_private/profiles/i18n.nix diff --git a/modules/nixos/profiles/server.nix b/modules/nixos/_private/profiles/server.nix similarity index 100% rename from modules/nixos/profiles/server.nix rename to modules/nixos/_private/profiles/server.nix diff --git a/modules/nixos/profiles/vpn.nix b/modules/nixos/_private/profiles/vpn.nix similarity index 100% rename from modules/nixos/profiles/vpn.nix rename to modules/nixos/_private/profiles/vpn.nix diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 892d0f91..8cfc44ca 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,11 +1,5 @@ -{ lib - - # Include the private modules. -, isInternal ? false -}: - -let - modules = [ +{ + imports = [ ./programs/blender.nix ./programs/cardboard-wm.nix ./programs/distrobox.nix @@ -20,17 +14,4 @@ let ./services/yt-dlp.nix ./workflows ]; - privateModules = [ - ./profiles/archiving.nix - ./profiles/browsers.nix - ./profiles/desktop.nix - ./profiles/dev.nix - ./profiles/filesystem.nix - ./profiles/gaming.nix - ./profiles/i18n.nix - ./profiles/server.nix - ./profiles/vpn.nix - ]; -in -modules -++ (lib.optionals isInternal privateModules) +}