mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-24 06:19:11 +00:00
modules: restructure private modules directory
This commit is contained in:
parent
23d466dea6
commit
7bb0b0dd1f
@ -8,15 +8,15 @@ let
|
|||||||
config' = import <config> { };
|
config' = import <config> { };
|
||||||
lib = pkgs.lib.extend (import <config/lib/extras/extend-lib.nix>);
|
lib = pkgs.lib.extend (import <config/lib/extras/extend-lib.nix>);
|
||||||
|
|
||||||
modules = import <config/modules/nixos> { inherit lib; isInternal = true; };
|
|
||||||
hmModules = import <config/modules/home-manager> { inherit lib; isInternal = true; };
|
|
||||||
extraArgs = {
|
extraArgs = {
|
||||||
nix-colors = import <nix-colors> { };
|
nix-colors = import <nix-colors> { };
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
import <nixpkgs/nixos/lib/eval-config.nix> {
|
import <nixpkgs/nixos/lib/eval-config.nix> {
|
||||||
inherit lib;
|
inherit lib;
|
||||||
modules = modules ++ extraModules ++ [
|
modules = extraModules ++ [
|
||||||
|
<config/modules/nixos>
|
||||||
|
<config/modules/nixos/_private>
|
||||||
<home-manager/nixos>
|
<home-manager/nixos>
|
||||||
<disko/module.nix>
|
<disko/module.nix>
|
||||||
<sops-nix/modules/sops>
|
<sops-nix/modules/sops>
|
||||||
@ -37,7 +37,9 @@ import <nixpkgs/nixos/lib/eval-config.nix> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
home-manager.sharedModules = hmModules ++ [
|
home-manager.sharedModules = [
|
||||||
|
<config/modules/home-manager>
|
||||||
|
<config/modules/home-manager/_private>
|
||||||
<sops-nix/modules/home-manager/sops.nix>
|
<sops-nix/modules/home-manager/sops.nix>
|
||||||
({ config, lib, ... }: {
|
({ config, lib, ... }: {
|
||||||
_module.args = extraArgs;
|
_module.args = extraArgs;
|
||||||
|
@ -39,32 +39,32 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# This is to be used by the NixOS `home-manager.sharedModules` anyways.
|
# This is to be used by the NixOS `home-manager.sharedModules` anyways.
|
||||||
sharedModules =
|
sharedModules = [
|
||||||
# Import our own custom modules from here..
|
# 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.
|
# ...plus a bunch of third-party modules.
|
||||||
++ [
|
inputs.sops-nix.homeManagerModules.sops
|
||||||
inputs.sops-nix.homeManagerModules.sops
|
inputs.nix-index-database.hmModules.nix-index
|
||||||
inputs.nix-index-database.hmModules.nix-index
|
|
||||||
|
|
||||||
# The default shared config for our home-manager configurations. This
|
# The default shared config for our home-manager configurations. This
|
||||||
# is also to be used for sharing modules among home-manager users from
|
# is also to be used for sharing modules among home-manager users from
|
||||||
# NixOS configurations with `nixpkgs.useGlobalPkgs` set to `true` so
|
# NixOS configurations with `nixpkgs.useGlobalPkgs` set to `true` so
|
||||||
# avoid setting nixpkgs-related options here.
|
# avoid setting nixpkgs-related options here.
|
||||||
({ pkgs, config, lib, ... }: {
|
({ pkgs, config, lib, ... }: {
|
||||||
# Set some extra, yeah?
|
# Set some extra, yeah?
|
||||||
_module.args = defaultExtraArgs;
|
_module.args = defaultExtraArgs;
|
||||||
|
|
||||||
manual = lib.mkDefault {
|
manual = lib.mkDefault {
|
||||||
html.enable = true;
|
html.enable = true;
|
||||||
json.enable = true;
|
json.enable = true;
|
||||||
manpages.enable = true;
|
manpages.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
home.stateVersion = lib.mkDefault "23.11";
|
home.stateVersion = lib.mkDefault "23.11";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
standaloneConfigModules = [
|
standaloneConfigModules = [
|
||||||
defaultNixConf
|
defaultNixConf
|
||||||
@ -83,6 +83,6 @@
|
|||||||
|
|
||||||
flake = {
|
flake = {
|
||||||
# Extending home-manager with my custom modules, if anyone cares.
|
# Extending home-manager with my custom modules, if anyone cares.
|
||||||
homeModules.default = import ../../modules/home-manager { inherit lib; };
|
homeModules.default = ../../modules/home-manager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -88,94 +88,90 @@
|
|||||||
# Only use imports as minimally as possible with the absolute
|
# Only use imports as minimally as possible with the absolute
|
||||||
# requirements of a host. On second thought, only on flakes with
|
# requirements of a host. On second thought, only on flakes with
|
||||||
# optional NixOS modules.
|
# optional NixOS modules.
|
||||||
sharedModules =
|
sharedModules = [
|
||||||
# Append with our custom NixOS modules from the modules folder.
|
# Import our custom modules.
|
||||||
import ../../modules/nixos { inherit lib; isInternal = true; }
|
../../modules/nixos
|
||||||
|
../../modules/nixos/_private
|
||||||
|
|
||||||
# Then, make the most with the modules from the flake inputs. Take
|
inputs.nix-index-database.nixosModules.nix-index
|
||||||
# note importing some modules such as home-manager are as part of the
|
inputs.sops-nix.nixosModules.sops
|
||||||
# declarative host config so be sure to check out
|
inputs.disko.nixosModules.disko
|
||||||
# `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
|
|
||||||
|
|
||||||
defaultNixConf
|
defaultNixConf
|
||||||
|
|
||||||
# The default shared configuration for the entire list of hosts for
|
# The default shared configuration for the entire list of hosts for
|
||||||
# this cluster. Take note to only set as minimal configuration as
|
# this cluster. Take note to only set as minimal configuration as
|
||||||
# possible since we're also using this with the stable version of
|
# possible since we're also using this with the stable version of
|
||||||
# nixpkgs.
|
# nixpkgs.
|
||||||
({ options, config, lib, pkgs, ... }: {
|
({ options, config, lib, pkgs, ... }: {
|
||||||
# Initialize some of the XDG base directories ourselves since it is
|
# Initialize some of the XDG base directories ourselves since it is
|
||||||
# used by NIX_PROFILES to properly link some of them.
|
# used by NIX_PROFILES to properly link some of them.
|
||||||
environment.sessionVariables = {
|
environment.sessionVariables = {
|
||||||
XDG_CACHE_HOME = "$HOME/.cache";
|
XDG_CACHE_HOME = "$HOME/.cache";
|
||||||
XDG_CONFIG_HOME = "$HOME/.config";
|
XDG_CONFIG_HOME = "$HOME/.config";
|
||||||
XDG_DATA_HOME = "$HOME/.local/share";
|
XDG_DATA_HOME = "$HOME/.local/share";
|
||||||
XDG_STATE_HOME = "$HOME/.local/state";
|
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
|
# Find Nix files with these! Even if nix-index is already enabled, it
|
||||||
# is better to make it explicit.
|
# is better to make it explicit.
|
||||||
programs.command-not-found.enable = false;
|
programs.command-not-found.enable = false;
|
||||||
programs.nix-index.enable = true;
|
programs.nix-index.enable = true;
|
||||||
|
|
||||||
# BOOOOOOOOOOOOO! Somebody give me a tomato!
|
# BOOOOOOOOOOOOO! Somebody give me a tomato!
|
||||||
services.xserver.excludePackages = with pkgs; [ xterm ];
|
services.xserver.excludePackages = with pkgs; [ xterm ];
|
||||||
|
|
||||||
# Append with the default time servers. It is becoming more unresponsive as
|
# Append with the default time servers. It is becoming more unresponsive as
|
||||||
# of 2023-10-28.
|
# of 2023-10-28.
|
||||||
networking.timeServers = [
|
networking.timeServers = [
|
||||||
"europe.pool.ntp.org"
|
"europe.pool.ntp.org"
|
||||||
"asia.pool.ntp.org"
|
"asia.pool.ntp.org"
|
||||||
"time.cloudflare.com"
|
"time.cloudflare.com"
|
||||||
] ++ options.networking.timeServers.default;
|
] ++ options.networking.timeServers.default;
|
||||||
|
|
||||||
# Disable channel state files. This shouldn't break any existing
|
# Disable channel state files. This shouldn't break any existing
|
||||||
# programs as long as we manage them NIX_PATH ourselves.
|
# programs as long as we manage them NIX_PATH ourselves.
|
||||||
nix.channel.enable = lib.mkDefault false;
|
nix.channel.enable = lib.mkDefault false;
|
||||||
|
|
||||||
# Set several paths for the traditional channels.
|
# Set several paths for the traditional channels.
|
||||||
nix.nixPath = lib.mkIf config.nix.channel.enable
|
nix.nixPath = lib.mkIf config.nix.channel.enable
|
||||||
(lib.mapAttrsToList
|
(lib.mapAttrsToList
|
||||||
(name: source:
|
(name: source:
|
||||||
let
|
let
|
||||||
name' = if (name == "self") then "config" else name;
|
name' = if (name == "self") then "config" else name;
|
||||||
in
|
in
|
||||||
"${name'}=${source}")
|
"${name'}=${source}")
|
||||||
inputs
|
inputs
|
||||||
++ [
|
++ [
|
||||||
"/nix/var/nix/profiles/per-user/root/channels"
|
"/nix/var/nix/profiles/per-user/root/channels"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
# Please clean your temporary crap.
|
# Please clean your temporary crap.
|
||||||
boot.tmp.cleanOnBoot = lib.mkDefault true;
|
boot.tmp.cleanOnBoot = lib.mkDefault true;
|
||||||
|
|
||||||
# We live in a Unicode world and dominantly English in technical fields so we'll
|
# We live in a Unicode world and dominantly English in technical fields so we'll
|
||||||
# have to go with it.
|
# have to go with it.
|
||||||
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
||||||
|
|
||||||
# Enabling some things for sops.
|
# Enabling some things for sops.
|
||||||
programs.gnupg.agent = lib.mkDefault {
|
programs.gnupg.agent = lib.mkDefault {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableSSHSupport = true;
|
enableSSHSupport = true;
|
||||||
};
|
};
|
||||||
services.openssh.enable = lib.mkDefault true;
|
services.openssh.enable = lib.mkDefault true;
|
||||||
|
|
||||||
# It's following the 'nixpkgs' flake input which should be in unstable
|
# It's following the 'nixpkgs' flake input which should be in unstable
|
||||||
# branches. Not to mention, most of the system configurations should
|
# branches. Not to mention, most of the system configurations should
|
||||||
# have this attribute set explicitly by default.
|
# have this attribute set explicitly by default.
|
||||||
system.stateVersion = lib.mkDefault "23.11";
|
system.stateVersion = lib.mkDefault "23.11";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
flake = {
|
flake = {
|
||||||
# Listing my public NixOS modules if anyone cares.
|
# Listing my public NixOS modules if anyone cares.
|
||||||
nixosModules.default = import ../../modules/nixos { inherit lib; };
|
nixosModules.default = ../../modules/nixos;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* 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.
|
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).
|
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.
|
* As such, public modules are not allowed to use the private library and modules.
|
||||||
Only the private modules can.
|
Only the private modules can.
|
||||||
|
8
modules/home-manager/_private/default.nix
Normal file
8
modules/home-manager/_private/default.nix
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./profiles/desktop.nix
|
||||||
|
./profiles/dev.nix
|
||||||
|
./profiles/editors.nix
|
||||||
|
./profiles/i18n.nix
|
||||||
|
];
|
||||||
|
}
|
@ -1,11 +1,5 @@
|
|||||||
{ lib
|
{
|
||||||
|
imports = [
|
||||||
# Import the private modules
|
|
||||||
, isInternal ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
modules = [
|
|
||||||
./files/mutable-files.nix
|
./files/mutable-files.nix
|
||||||
./programs/pop-launcher.nix
|
./programs/pop-launcher.nix
|
||||||
./services/archivebox.nix
|
./services/archivebox.nix
|
||||||
@ -17,12 +11,4 @@ let
|
|||||||
./services/plover.nix
|
./services/plover.nix
|
||||||
./services/yt-dlp.nix
|
./services/yt-dlp.nix
|
||||||
];
|
];
|
||||||
privateModules = [
|
}
|
||||||
./profiles/desktop.nix
|
|
||||||
./profiles/dev.nix
|
|
||||||
./profiles/editors.nix
|
|
||||||
./profiles/i18n.nix
|
|
||||||
];
|
|
||||||
in
|
|
||||||
modules
|
|
||||||
++ (lib.optionals isInternal privateModules)
|
|
||||||
|
13
modules/nixos/_private/default.nix
Normal file
13
modules/nixos/_private/default.nix
Normal file
@ -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
|
||||||
|
];
|
||||||
|
}
|
@ -1,11 +1,5 @@
|
|||||||
{ lib
|
{
|
||||||
|
imports = [
|
||||||
# Include the private modules.
|
|
||||||
, isInternal ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
modules = [
|
|
||||||
./programs/blender.nix
|
./programs/blender.nix
|
||||||
./programs/cardboard-wm.nix
|
./programs/cardboard-wm.nix
|
||||||
./programs/distrobox.nix
|
./programs/distrobox.nix
|
||||||
@ -20,17 +14,4 @@ let
|
|||||||
./services/yt-dlp.nix
|
./services/yt-dlp.nix
|
||||||
./workflows
|
./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)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user