mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
home-manager/state: refactor and add paths and ports sub-option
Similarly structured to the NixOS module to make it consistent, yay.
This commit is contained in:
parent
ae06921d64
commit
f6c70a278b
@ -60,7 +60,7 @@ in
|
||||
topdirs = "~/Downloads ~/Documents ~/library";
|
||||
"skippedNames+" =
|
||||
let
|
||||
inherit (config.state) ignoreDirectories;
|
||||
inherit (config.state.paths) ignoreDirectories;
|
||||
in
|
||||
lib.concatStringsSep " " ignoreDirectories;
|
||||
|
||||
|
@ -10,7 +10,7 @@ in
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{
|
||||
state.ignoreDirectories = [
|
||||
state.paths.ignoreDirectories = [
|
||||
"node_modules" # For Node projects.
|
||||
"result" # For Nix builds.
|
||||
"target" # For Rust builds.
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
imports = [
|
||||
./extra-arguments.nix
|
||||
./state.nix
|
||||
./state
|
||||
./suites/desktop.nix
|
||||
./suites/dev.nix
|
||||
./suites/editors.nix
|
||||
|
@ -1,37 +0,0 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.state = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = with lib.types; attrsOf anything;
|
||||
options = {
|
||||
ignoreDirectories = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
A state variable holding a list of directory names to be excluded
|
||||
in processes involving walking through directories (e.g., desktop
|
||||
indexing).
|
||||
'';
|
||||
default = [ ];
|
||||
example = [
|
||||
"node_modules"
|
||||
".direnv"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
A set of values to be held in the home-manager configuration. Pretty much
|
||||
used for anything that requires consistency or deduplicate the source of
|
||||
truth for module values.
|
||||
'';
|
||||
example = {
|
||||
sampleValue = 10;
|
||||
dev.ignoreDirectories = [
|
||||
".git"
|
||||
"node_modules"
|
||||
".direnv"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
28
modules/home-manager/_private/state/default.nix
Normal file
28
modules/home-manager/_private/state/default.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./ports.nix
|
||||
./paths.nix
|
||||
];
|
||||
|
||||
options.state = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = with lib.types; attrsOf anything;
|
||||
default = { };
|
||||
};
|
||||
description = ''
|
||||
A set of values to be held in the home-manager configuration. Pretty much
|
||||
used for anything that requires consistency or deduplicate the source of
|
||||
truth for module values.
|
||||
'';
|
||||
example = {
|
||||
sampleValue = 10;
|
||||
paths.ignoreDirectories = [
|
||||
".git"
|
||||
"node_modules"
|
||||
".direnv"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
27
modules/home-manager/_private/state/paths.nix
Normal file
27
modules/home-manager/_private/state/paths.nix
Normal file
@ -0,0 +1,27 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.state =
|
||||
let
|
||||
pathsSubmodule = { lib, ... }: {
|
||||
options = {
|
||||
paths = lib.mkOption {
|
||||
type = with lib.types; attrsOf (listOf path);
|
||||
default = { };
|
||||
description = ''
|
||||
Set of paths to hold as a single source of truth for path-related
|
||||
settings throughout the whole home environment.
|
||||
'';
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
ignoreDirectories = [ "''${config.home.homeDirectory}/Nodes" ];
|
||||
ignorePaths = [ ".gitignore" "node_modules" "result" ];
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in lib.mkOption {
|
||||
type = lib.type.submodule pathsSubmodule;
|
||||
};
|
||||
}
|
64
modules/home-manager/_private/state/ports.nix
Normal file
64
modules/home-manager/_private/state/ports.nix
Normal file
@ -0,0 +1,64 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
supportedProtocols = [ "tcp" "udp" ];
|
||||
in
|
||||
{
|
||||
options.state =
|
||||
let
|
||||
portRangeType = {
|
||||
options = {
|
||||
from = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
description = ''
|
||||
The start of the range of TCP/UDP ports to be taken over.
|
||||
'';
|
||||
};
|
||||
|
||||
to = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
description = ''
|
||||
The end of the range of TCP/UDP ports to be taken over.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
portValueModule = { lib, ... }: {
|
||||
options = {
|
||||
protocols = lib.mkOption {
|
||||
type = with lib.types; listOf (enum supportedProtocols);
|
||||
description = ''
|
||||
Indicates the type of protocol of the service.
|
||||
'';
|
||||
default = [ "tcp" "udp" ];
|
||||
example = [ "tcp" ];
|
||||
};
|
||||
|
||||
value = lib.mkOption {
|
||||
type = with lib.types; either port (submodule portRangeType);
|
||||
description = ''
|
||||
The port number itself.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
portsSubmodule = { lib, ... }: {
|
||||
options = {
|
||||
ports = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule portValueModule);
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
gonic.value = 4629;
|
||||
mopidy.value = 6034;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in lib.mkOption {
|
||||
type = lib.types.submodule portsSubmodule;
|
||||
};
|
||||
}
|
@ -20,7 +20,7 @@ in {
|
||||
({
|
||||
# Contains a dev-adjacent list of directory names to be ignored usually
|
||||
# used in walking through directories.
|
||||
state.ignoreDirectories = [
|
||||
state.paths.ignoreDirectories = [
|
||||
".git"
|
||||
".direnv"
|
||||
];
|
||||
@ -171,7 +171,7 @@ in {
|
||||
programs.eza = {
|
||||
enable = true;
|
||||
extraOptions = let
|
||||
ignoreDirectories = lib.concatStringsSep "|" config.state.ignoreDirectories;
|
||||
ignoreDirectories = lib.concatStringsSep "|" config.state.paths.ignoreDirectories;
|
||||
in [
|
||||
"--group-directories-first"
|
||||
"--header"
|
||||
|
Loading…
Reference in New Issue
Block a user