mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-03-13 18:19:00 +00:00
Restructure the modules
While it is easier to maintain the modules by prefixing them all with `modules`, it is not easy when used from other flakes and/or modules. This is my attempt on making it easier with appropriate namespaces. Update home-manager user from the restructure
This commit is contained in:
parent
4e7338686e
commit
6b481a163a
@ -7,7 +7,7 @@
|
||||
];
|
||||
|
||||
# My custom configuration with my custom modules starts here.
|
||||
modules = {
|
||||
profiles = {
|
||||
agenix.enable = true;
|
||||
archiving.enable = true;
|
||||
desktop = {
|
||||
@ -24,10 +24,6 @@
|
||||
virtualization.enable = true;
|
||||
neovim.enable = true;
|
||||
};
|
||||
themes = {
|
||||
disableLimit = true;
|
||||
themes.a-happy-gnome.enable = true;
|
||||
};
|
||||
users.users.foo-dogsquared.settings = {
|
||||
extraGroups = [ "wheel" "audio" "docker" "podman" "network-manager" ];
|
||||
hashedPassword =
|
||||
@ -36,7 +32,11 @@
|
||||
createHome = true;
|
||||
home = "/home/foo-dogsquared";
|
||||
};
|
||||
hardware-setup.backup-archive.enable = true;
|
||||
};
|
||||
hardware-setup.backup-archive.enable = true;
|
||||
themes = {
|
||||
disableLimit = true;
|
||||
themes.a-happy-gnome.enable = true;
|
||||
};
|
||||
|
||||
# Use the systemd-boot EFI boot loader.
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Enables all of my usual setup for desktop-oriented stuff.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.desktop;
|
||||
let cfg = config.profiles.desktop;
|
||||
in {
|
||||
options.modules.desktop = {
|
||||
options.profiles.desktop = {
|
||||
enable = lib.mkEnableOption "installations of desktop apps";
|
||||
graphics.enable =
|
||||
lib.mkEnableOption "installations of graphics-related apps";
|
@ -2,9 +2,9 @@
|
||||
# If you're looking for text editors, go to `./editors.nix`.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.dev;
|
||||
let cfg = config.profiles.dev;
|
||||
in {
|
||||
options.modules.dev = {
|
||||
options.profiles.dev = {
|
||||
enable =
|
||||
lib.mkEnableOption "foo-dogsquared's user-specific development setup";
|
||||
shell.enable =
|
@ -7,9 +7,9 @@
|
||||
# for me is not worth to maintain.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.editors;
|
||||
let cfg = config.profiles.editors;
|
||||
in {
|
||||
options.modules.editors = {
|
||||
options.profiles.editors = {
|
||||
neovim.enable = lib.mkEnableOption "foo-dogsquared's Neovim setup with Nix";
|
||||
emacs.enable = lib.mkEnableOption "foo-dogsquared's (Doom) Emacs setup";
|
||||
};
|
||||
@ -51,6 +51,7 @@ in {
|
||||
|
||||
## :lang org +roam2
|
||||
sqlite
|
||||
anystyle-cli
|
||||
];
|
||||
})
|
||||
];
|
@ -1,9 +1,9 @@
|
||||
# Instant setup for using internationalized languages.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.i18n;
|
||||
let cfg = config.profiles.i18n;
|
||||
in {
|
||||
options.modules.i18n.enable =
|
||||
options.profiles.i18n.enable =
|
||||
lib.mkEnableOption "fcitx5 as input method engine";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
@ -1,8 +1,8 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.research;
|
||||
let cfg = config.profiles.research;
|
||||
in {
|
||||
options.modules.research.enable =
|
||||
options.profiles.research.enable =
|
||||
lib.mkEnableOption "my usual toolbelt for research";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
@ -16,5 +16,7 @@ in {
|
||||
yt-dlp # The general purpose video downloader.
|
||||
zotero # It's actually good at archiving despite not being a researcher myself.
|
||||
];
|
||||
|
||||
services.syncthing.enable = true;
|
||||
};
|
||||
}
|
41
modules/home-manager/services/archivebox.nix
Normal file
41
modules/home-manager/services/archivebox.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.archivebox;
|
||||
in {
|
||||
options.services.archivebox = {
|
||||
enable = lib.mkEnableOption "Archivebox service";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
description = "The port number to be used for the server at localhost.";
|
||||
default = 8000;
|
||||
example = 8888;
|
||||
};
|
||||
|
||||
archivePath = lib.mkOption {
|
||||
type = with lib.types; either path str;
|
||||
description = "The path of the Archivebox archive.";
|
||||
example = "\${config.xdg.dataHome}/archivebox";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ pkgs.archivebox ];
|
||||
systemd.user.services.archivebox-server = {
|
||||
Unit = {
|
||||
Description = "Archivebox server for ${cfg.archivePath}";
|
||||
After = "network.target";
|
||||
Documentation = [ "https://docs.archivebox.io/" ];
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
|
||||
Service = {
|
||||
ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${toString cfg.port}";
|
||||
WorkingDirectory = cfg.archivePath;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.bleachbit;
|
||||
let cfg = config.services.bleachbit;
|
||||
in {
|
||||
options.modules.bleachbit = {
|
||||
options.services.bleachbit = {
|
||||
enable = lib.mkEnableOption "automated cleanup with Bleachbit";
|
||||
startAt = lib.mkOption {
|
||||
type = lib.types.str;
|
@ -3,14 +3,14 @@
|
||||
|
||||
# TODO: Make this a generic service.
|
||||
# There are multiple external storage drives now.
|
||||
let cfg = config.modules.hardware-setup.backup-archive;
|
||||
let cfg = config.hardware-setup.backup-archive;
|
||||
in {
|
||||
options.modules.hardware-setup.backup-archive.enable = lib.mkEnableOption
|
||||
options.hardware-setup.backup-archive.enable = lib.mkEnableOption
|
||||
"external hard drive and automated backup service with BorgBackup";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [{
|
||||
assertion = config.modules.agenix.enable;
|
||||
assertion = config.profiles.agenix.enable;
|
||||
message = "Agenix module is not enabled.";
|
||||
}];
|
||||
|
||||
@ -34,7 +34,8 @@ in {
|
||||
];
|
||||
};
|
||||
|
||||
modules.services.borgmatic.jobs.external-storage = {
|
||||
# This uses the custom borgmatic NixOS service.
|
||||
services.borgmatic.jobs.external-storage = {
|
||||
startAt = "04/6:00:00";
|
||||
configPath = config.age.secrets.external-backup-borgmatic-settings.path;
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
# A module that automates setting up agenix for your system.
|
||||
{ inputs, lib, options, config, system, ... }:
|
||||
|
||||
let cfg = config.modules.agenix;
|
||||
let cfg = config.profiles.agenix;
|
||||
in {
|
||||
options.modules.agenix.enable =
|
||||
options.profiles.agenix.enable =
|
||||
lib.mkEnableOption "agenix-related config on your system";
|
||||
|
||||
imports = [ inputs.agenix.nixosModules.age ];
|
@ -1,9 +1,9 @@
|
||||
# All of your embarrassing moments, marked here forever.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.archiving;
|
||||
let cfg = config.profiles.archiving;
|
||||
in {
|
||||
options.modules.archiving.enable =
|
||||
options.profiles.archiving.enable =
|
||||
lib.mkEnableOption "installation of various archiving tools";
|
||||
|
||||
# This is not going to set BorgBackup NixOS services for you.
|
@ -3,9 +3,9 @@
|
||||
# That can be found in the `themes` module.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.desktop;
|
||||
let cfg = config.profiles.desktop;
|
||||
in {
|
||||
options.modules.desktop = {
|
||||
options.profiles.desktop = {
|
||||
enable =
|
||||
lib.mkEnableOption "all desktop-related services and default programs";
|
||||
audio.enable =
|
||||
@ -40,6 +40,7 @@ in {
|
||||
|
||||
(lib.mkIf cfg.audio.enable {
|
||||
# Enable the preferred audio workflow.
|
||||
sound.enable = false;
|
||||
hardware.pulseaudio.enable = false;
|
||||
security.rtkit.enable = true;
|
||||
services.pipewire = {
|
@ -1,9 +1,9 @@
|
||||
# The module for anything dev-related.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.dev;
|
||||
let cfg = config.profiles.dev;
|
||||
in {
|
||||
options.modules.dev = {
|
||||
options.profiles.dev = {
|
||||
enable = lib.mkEnableOption
|
||||
"configurations of foo-dogsquared's barebones requirement for a development environment.";
|
||||
shell.enable = lib.mkEnableOption
|
@ -7,10 +7,10 @@
|
||||
{ inputs, config, options, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.modules.users;
|
||||
cfg = config.profiles.users;
|
||||
users = lib.attrNames cfg.users;
|
||||
homeManagerUserModules = lib.getUsers "home-manager" users;
|
||||
homeManagerModules = lib.filesToAttr ../home-manager;
|
||||
homeManagerModules = lib.filesToAttr ../../home-manager;
|
||||
|
||||
homeManagerUsers = lib.attrNames homeManagerUserModules;
|
||||
nonexistentUsers = lib.filter (name: !lib.elem name homeManagerUsers) users;
|
||||
@ -33,7 +33,7 @@ let
|
||||
|
||||
mapUsers = f: lib.mapAttrs f cfg.users;
|
||||
in {
|
||||
options.modules.users = {
|
||||
options.profiles.users = {
|
||||
users = lib.mkOption {
|
||||
default = { };
|
||||
description = ''
|
@ -2,7 +2,7 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.modules.services.borgmatic;
|
||||
cfg = config.services.borgmatic;
|
||||
|
||||
jobOption = { name, config, ... }: {
|
||||
options = {
|
||||
@ -27,7 +27,7 @@ let
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.modules.services.borgmatic = {
|
||||
options.services.borgmatic = {
|
||||
jobs = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule jobOption);
|
||||
description = "borgmatic jobs with each bearing a configuration file to be used.";
|
||||
|
@ -4,15 +4,15 @@
|
||||
# See https://github.com/NixOS/nixpkgs/issues/54150 for more details.
|
||||
let
|
||||
name = "a-happy-gnome";
|
||||
cfg = config.modules.themes.themes.a-happy-gnome;
|
||||
dconf = pkgs.gnome3.dconf;
|
||||
customDconfDb = pkgs.stdenv.mkDerivation {
|
||||
name = "${name}-dconf-db";
|
||||
buildCommand = "${dconf}/bin/dconf compile $out ${./config/dconf}";
|
||||
};
|
||||
cfg = config.themes.themes.a-happy-gnome;
|
||||
in
|
||||
{
|
||||
options.modules.themes.themes.a-happy-gnome.enable = lib.mkEnableOption "'A happy GNOME', foo-dogsquared's configuration of GNOME desktop environment";
|
||||
options.themes.themes.a-happy-gnome.enable = lib.mkEnableOption "'A happy GNOME', foo-dogsquared's configuration of GNOME desktop environment";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.xserver.enable = true;
|
||||
|
@ -3,9 +3,9 @@
|
||||
# You can also show your desktop being modularized like this.
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
let cfg = config.modules.themes;
|
||||
let cfg = config.themes;
|
||||
in {
|
||||
options.modules.themes.disableLimit = lib.mkOption {
|
||||
options.themes.disableLimit = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
|
@ -26,8 +26,7 @@
|
||||
};
|
||||
|
||||
# My custom modules.
|
||||
modules = {
|
||||
bleachbit.enable = true;
|
||||
profiles = {
|
||||
i18n.enable = true;
|
||||
dev = {
|
||||
enable = true;
|
||||
@ -42,4 +41,12 @@
|
||||
};
|
||||
research.enable = true;
|
||||
};
|
||||
|
||||
services = {
|
||||
archivebox = {
|
||||
enable = true;
|
||||
archivePath = "%h/library/archives";
|
||||
};
|
||||
bleachbit.enable = true;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user