mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 22:11:33 +01:00
refactor: normalize usage of lib and builtins namespaces
This commit is contained in:
parent
043a996319
commit
062fd5de0b
17 changed files with 24 additions and 24 deletions
|
|
@ -14,7 +14,7 @@ let
|
||||||
hostFiles =
|
hostFiles =
|
||||||
"${self}/hosts/${hostName}"
|
"${self}/hosts/${hostName}"
|
||||||
|> lib.filesystem.listFilesRecursive
|
|> lib.filesystem.listFilesRecursive
|
||||||
|> builtins.filter (lib.hasSuffix ".nix");
|
|> lib.filter (lib.hasSuffix ".nix");
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
{ networking = { inherit hostName; }; }
|
{ networking = { inherit hostName; }; }
|
||||||
|
|
@ -46,6 +46,6 @@ in
|
||||||
|> lib.filterAttrs (_: type: type == "directory")
|
|> lib.filterAttrs (_: type: type == "directory")
|
||||||
|> lib.mapAttrs (name: _: mkDeployNode name);
|
|> lib.mapAttrs (name: _: mkDeployNode name);
|
||||||
|
|
||||||
checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
|
checks = lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{ self, lib, ... }:
|
{ self, lib, ... }:
|
||||||
let
|
let
|
||||||
modulesOf = dir: dir |> lib.filesystem.listFilesRecursive |> builtins.filter (lib.hasSuffix ".nix");
|
modulesOf = dir: dir |> lib.filesystem.listFilesRecursive |> lib.filter (lib.hasSuffix ".nix");
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake = {
|
flake = {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|> lib.filterAttrs (_: value: value.config.home-manager.users.seb.custom.sops.enable or false)
|
|> lib.filterAttrs (_: value: value.config.home-manager.users.seb.custom.sops.enable or false)
|
||||||
|> lib.mapAttrsToList (_: value: mkCreationRule value.config.home-manager.users.seb.custom.sops);
|
|> lib.mapAttrsToList (_: value: mkCreationRule value.config.home-manager.users.seb.custom.sops);
|
||||||
|
|
||||||
jsonConfig = { creation_rules = hostCreationRules ++ userCreationRules; } |> builtins.toJSON;
|
jsonConfig = { creation_rules = hostCreationRules ++ userCreationRules; } |> lib.strings.toJSON;
|
||||||
in
|
in
|
||||||
pkgs.runCommand "sops-config" { buildInputs = [ pkgs.yj ]; } ''
|
pkgs.runCommand "sops-config" { buildInputs = [ pkgs.yj ]; } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@
|
||||||
|
|
||||||
# Switch workspace
|
# Switch workspace
|
||||||
${lib.concatMapStringsSep "\n" (n: ''
|
${lib.concatMapStringsSep "\n" (n: ''
|
||||||
bind = SUPER, ${toString n}, focusworkspaceoncurrentmonitor, ${toString n}
|
bind = SUPER, ${builtins.toString n}, focusworkspaceoncurrentmonitor, ${builtins.toString n}
|
||||||
bind = SUPER SHIFT, ${toString n}, movetoworkspacesilent, ${toString n}
|
bind = SUPER SHIFT, ${builtins.toString n}, movetoworkspacesilent, ${builtins.toString n}
|
||||||
'') (lib.range 1 9)}
|
'') (lib.range 1 9)}
|
||||||
|
|
||||||
# Manage session
|
# Manage session
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
"sidebar.revamp" = false;
|
"sidebar.revamp" = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = builtins.readFile "${inputs.betterfox}/user.js";
|
extraConfig = lib.readFile "${inputs.betterfox}/user.js";
|
||||||
};
|
};
|
||||||
|
|
||||||
policies.ExtensionSettings =
|
policies.ExtensionSettings =
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
let
|
let
|
||||||
aliasList = lib.mapCartesianProduct ({ a, b, c }: a + b + c) { a = ["ll" "lt" "l"]; b = ["" "a"]; c = ["" "d" "f"]; };
|
aliasList = lib.mapCartesianProduct ({ a, b, c }: a + b + c) { a = ["ll" "lt" "l"]; b = ["" "a"]; c = ["" "d" "f"]; };
|
||||||
eza = "eza --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary ";
|
eza = "eza --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary ";
|
||||||
convertAliasToCmd = str: eza + (builtins.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str);
|
convertAliasToCmd = str: eza + (lib.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str);
|
||||||
in
|
in
|
||||||
(lib.genAttrs aliasList convertAliasToCmd) // { ls = "l"; };
|
(lib.genAttrs aliasList convertAliasToCmd) // { ls = "l"; };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ in
|
||||||
};
|
};
|
||||||
secrets = lib.mkOption {
|
secrets = lib.mkOption {
|
||||||
type = lib.types.anything;
|
type = lib.types.anything;
|
||||||
default = absoluteSecretsPath |> builtins.readFile |> builtins.fromJSON;
|
default = absoluteSecretsPath |> lib.readFile |> lib.strings.fromJSON;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,12 @@ in
|
||||||
|> lib.concatLists
|
|> lib.concatLists
|
||||||
|> lib.concatMap (
|
|> lib.concatMap (
|
||||||
entry:
|
entry:
|
||||||
map (domain: {
|
lib.map (domain: {
|
||||||
file = entry.file;
|
file = entry.file;
|
||||||
inherit domain;
|
inherit domain;
|
||||||
}) entry.value
|
}) entry.value
|
||||||
)
|
)
|
||||||
|> lib.groupBy (entry: toString entry.domain)
|
|> lib.groupBy (entry: builtins.toString entry.domain)
|
||||||
|> lib.filterAttrs (domain: entries: lib.length entries > 1);
|
|> lib.filterAttrs (domain: entries: lib.length entries > 1);
|
||||||
|
|
||||||
errorMessage =
|
errorMessage =
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ in
|
||||||
options.meta.ports.list.definitionsWithLocations
|
options.meta.ports.list.definitionsWithLocations
|
||||||
|> lib.concatMap (
|
|> lib.concatMap (
|
||||||
entry:
|
entry:
|
||||||
map (port: {
|
lib.map (port: {
|
||||||
inherit (entry) file;
|
inherit (entry) file;
|
||||||
inherit port;
|
inherit port;
|
||||||
}) entry.value
|
}) entry.value
|
||||||
)
|
)
|
||||||
|> lib.groupBy (entry: toString entry.port)
|
|> lib.groupBy (entry: builtins.toString entry.port)
|
||||||
|> lib.filterAttrs (port: entries: lib.length entries > 1);
|
|> lib.filterAttrs (port: entries: lib.length entries > 1);
|
||||||
|
|
||||||
errorMessage =
|
errorMessage =
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ let
|
||||||
logFormat = "output file ${config.services.caddy.logDir}/access-${domain}.log { mode 640 }";
|
logFormat = "output file ${config.services.caddy.logDir}/access-${domain}.log { mode 640 }";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
${lib.optionalString (isTailscaleDomain domain) "bind tailscale/${getSubdomain domain}"}
|
${lib.optionalString (isTailscaleDomain domain) "bind tailscale/${getSubdomain domain}"}
|
||||||
reverse_proxy localhost:${toString port}
|
reverse_proxy localhost:${builtins.toString port}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ in
|
||||||
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec;
|
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec;
|
||||||
enrollKeyFile = config.sops.secrets."crowdsec/enrollment-key".path;
|
enrollKeyFile = config.sops.secrets."crowdsec/enrollment-key".path;
|
||||||
settings = {
|
settings = {
|
||||||
api.server.listen_uri = "127.0.0.1:${toString cfg.apiPort}";
|
api.server.listen_uri = "127.0.0.1:${builtins.toString cfg.apiPort}";
|
||||||
cscli.prometheus_uri = "http://127.0.0.1:${toString cfg.prometheusPort}";
|
cscli.prometheus_uri = "http://127.0.0.1:${builtins.toString cfg.prometheusPort}";
|
||||||
};
|
};
|
||||||
|
|
||||||
allowLocalJournalAccess = true;
|
allowLocalJournalAccess = true;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ in
|
||||||
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec-firewall-bouncer;
|
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec-firewall-bouncer;
|
||||||
settings = {
|
settings = {
|
||||||
api_key = "cs-firewall-bouncer";
|
api_key = "cs-firewall-bouncer";
|
||||||
api_url = "http://127.0.0.1:${toString cfg.apiPort}";
|
api_url = "http://127.0.0.1:${builtins.toString cfg.apiPort}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ in
|
||||||
database.SQLITE_JOURNAL_MODE = "WAL";
|
database.SQLITE_JOURNAL_MODE = "WAL";
|
||||||
cache = {
|
cache = {
|
||||||
ADAPTER = "twoqueue";
|
ADAPTER = "twoqueue";
|
||||||
HOST = builtins.toJSON {
|
HOST = lib.strings.toJSON {
|
||||||
size = 100;
|
size = 100;
|
||||||
recent_ratio = 0.25;
|
recent_ratio = 0.25;
|
||||||
ghost_ratio = 0.5;
|
ghost_ratio = 0.5;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ in
|
||||||
|
|
||||||
services.static-web-server = {
|
services.static-web-server = {
|
||||||
enable = true;
|
enable = true;
|
||||||
listen = "[::]:${toString cfg.port}";
|
listen = "[::]:${builtins.toString cfg.port}";
|
||||||
root = "${pkgs.it-tools}/lib";
|
root = "${pkgs.it-tools}/lib";
|
||||||
configuration.general.health = true;
|
configuration.general.health = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
base-url = "https://${cfg.domain}";
|
base-url = "https://${cfg.domain}";
|
||||||
listen-http = ":${toString cfg.port}";
|
listen-http = ":${builtins.toString cfg.port}";
|
||||||
behind-proxy = true;
|
behind-proxy = true;
|
||||||
web-root = "disable";
|
web-root = "disable";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ in
|
||||||
group = lib.mkIf (!cfg.isServer) "users";
|
group = lib.mkIf (!cfg.isServer) "users";
|
||||||
dataDir = lib.mkIf (!cfg.isServer) "/home/seb";
|
dataDir = lib.mkIf (!cfg.isServer) "/home/seb";
|
||||||
|
|
||||||
guiAddress = lib.mkIf cfg.isServer "127.0.0.1:${toString cfg.gui.port}";
|
guiAddress = lib.mkIf cfg.isServer "127.0.0.1:${builtins.toString cfg.gui.port}";
|
||||||
|
|
||||||
cert = lib.mkIf useStaticTls config.sops.secrets."syncthing/cert".path;
|
cert = lib.mkIf useStaticTls config.sops.secrets."syncthing/cert".path;
|
||||||
key = lib.mkIf useStaticTls config.sops.secrets."syncthing/key".path;
|
key = lib.mkIf useStaticTls config.sops.secrets."syncthing/key".path;
|
||||||
|
|
@ -81,7 +81,7 @@ in
|
||||||
|> lib.mapAttrs (
|
|> lib.mapAttrs (
|
||||||
name: value: {
|
name: value: {
|
||||||
id = value.config.custom.services.syncthing.deviceId;
|
id = value.config.custom.services.syncthing.deviceId;
|
||||||
addresses = [ "tcp://${name}.${tailscaleCfg.domain}:${toString cfg.syncPort}" ];
|
addresses = [ "tcp://${name}.${tailscaleCfg.domain}:${builtins.toString cfg.syncPort}" ];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
listenAddress = "tcp://0.0.0.0:${toString cfg.syncPort}";
|
listenAddress = "tcp://0.0.0.0:${builtins.toString cfg.syncPort}";
|
||||||
globalAnnounceEnabled = false;
|
globalAnnounceEnabled = false;
|
||||||
localAnnounceEnabled = false;
|
localAnnounceEnabled = false;
|
||||||
relaysEnabled = false;
|
relaysEnabled = false;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ in
|
||||||
};
|
};
|
||||||
secrets = lib.mkOption {
|
secrets = lib.mkOption {
|
||||||
type = lib.types.anything;
|
type = lib.types.anything;
|
||||||
default = absoluteSecretsPath |> builtins.readFile |> builtins.fromJSON;
|
default = absoluteSecretsPath |> lib.readFile |> lib.strings.fromJSON;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue