chore: reformat codebase

This commit is contained in:
Gabriel Arazas 2023-01-07 16:06:34 +08:00
parent d9e7f7c67e
commit 4c34a87366
7 changed files with 88 additions and 77 deletions

View File

@ -340,9 +340,12 @@
networking.hostName = lib.mkOverride 2000 host'; networking.hostName = lib.mkOverride 2000 host';
}) })
(lib'.optionalAttrs (lib'.hasAttr host' images) (lib'.optionalAttrs (lib'.hasAttr host' images)
(let (
imageFormat = images.${host'}.format; let
in inputs.nixos-generators.nixosModules.${imageFormat})) imageFormat = images.${host'}.format;
in
inputs.nixos-generators.nixosModules.${imageFormat}
))
hostSharedConfig hostSharedConfig
path path
]; ];
@ -388,24 +391,25 @@
# My custom packages, available in here as well. Though, I mainly support # My custom packages, available in here as well. Though, I mainly support
# "x86_64-linux". I just want to try out supporting other systems. # "x86_64-linux". I just want to try out supporting other systems.
packages = forAllSystems (system: let packages = forAllSystems (system:
pkgs = import nixpkgs { inherit system overlays; }; let
in pkgs = import nixpkgs { inherit system overlays; };
in
inputs.flake-utils.lib.flattenTree (import ./pkgs { inherit pkgs; }) inputs.flake-utils.lib.flattenTree (import ./pkgs { inherit pkgs; })
// lib'.mapAttrs' // lib'.mapAttrs'
(name: value: (name: value:
lib'.nameValuePair "${name}-${value.format}" (mkImage { lib'.nameValuePair "${name}-${value.format}" (mkImage {
inherit system pkgs extraArgs; inherit system pkgs extraArgs;
inherit (value) format; inherit (value) format;
extraModules = [ extraModules = [
({ lib, ... }: { ({ lib, ... }: {
networking.hostName = lib.mkOverride 2000 name; networking.hostName = lib.mkOverride 2000 name;
}) })
hostSharedConfig hostSharedConfig
./hosts/${name} ./hosts/${name}
]; ];
})) }))
images); images);
# My several development shells for usual type of projects. This is much # My several development shells for usual type of projects. This is much
# more preferable than installing all of the packages at the system # more preferable than installing all of the packages at the system
@ -445,31 +449,33 @@
# sensitive info such as the hostname and such. A helpful tip would be # sensitive info such as the hostname and such. A helpful tip would be
# ignoring the shell entry by simply prefixing it with a space which most # ignoring the shell entry by simply prefixing it with a space which most
# command-line shells have support for (e.g., Bash, zsh, fish). # command-line shells have support for (e.g., Bash, zsh, fish).
deploy.nodes = let deploy.nodes =
nixosConfigurations = lib'.mapAttrs' let
(name: value: nixosConfigurations = lib'.mapAttrs'
lib'.nameValuePair "nixos-${name}" { (name: value:
hostname = name; lib'.nameValuePair "nixos-${name}" {
fastConnection = true; hostname = name;
profiles.system = { fastConnection = true;
sshUser = "admin"; profiles.system = {
user = "root"; sshUser = "admin";
path = inputs.deploy.lib.${defaultSystem}.activate.nixos value; user = "root";
}; path = inputs.deploy.lib.${defaultSystem}.activate.nixos value;
}) };
self.nixosConfigurations; })
homeManagerConfigurations = lib'.mapAttrs' self.nixosConfigurations;
(name: value: homeManagerConfigurations = lib'.mapAttrs'
lib'.nameValuePair "home-manager-${name}" { (name: value:
hostname = name; lib'.nameValuePair "home-manager-${name}" {
fastConnection = true; hostname = name;
profiles.home = { fastConnection = true;
sshUser = name; profiles.home = {
path = inputs.deploy.lib.${defaultSystem}.activate.home-manager value; sshUser = name;
}; path = inputs.deploy.lib.${defaultSystem}.activate.home-manager value;
}) };
self.homeManagerConfigurations; })
in nixosConfigurations // homeManagerConfigurations; self.homeManagerConfigurations;
in
nixosConfigurations // homeManagerConfigurations;
# How to make yourself slightly saner than before. So far the main checks # How to make yourself slightly saner than before. So far the main checks
# are for deploy nodes. # are for deploy nodes.

View File

@ -27,19 +27,20 @@
type = "ed25519"; type = "ed25519";
}]; }];
sops.secrets = let sops.secrets =
getKey = key: { let
inherit key; getKey = key: {
sopsFile = ./secrets/secrets.yaml; inherit key;
}; sopsFile = ./secrets/secrets.yaml;
getSecrets = secrets: };
lib.mapAttrs' getSecrets = secrets:
(secret: config: lib.mapAttrs'
lib.nameValuePair (secret: config:
"ni/${secret}" lib.nameValuePair
((getKey secret) // config)) "ni/${secret}"
secrets; ((getKey secret) // config))
in secrets;
in
getSecrets { getSecrets {
ssh-key = { }; ssh-key = { };
"ldap/password" = { }; "ldap/password" = { };

View File

@ -220,7 +220,8 @@ in
CREATE SCHEMA AUTHORIZATION ${user.name}; CREATE SCHEMA AUTHORIZATION ${user.name};
'') '')
config.services.postgresql.ensureUsers; config.services.postgresql.ensureUsers;
in pkgs.writeText "plover-initial-postgresql-script" '' in
pkgs.writeText "plover-initial-postgresql-script" ''
${lib.concatStringsSep "\n" perUserSchemas} ${lib.concatStringsSep "\n" perUserSchemas}
''; '';
@ -554,14 +555,16 @@ in
IdentityFile ${config.sops.secrets."plover/borg/ssh-key".path} IdentityFile ${config.sops.secrets."plover/borg/ssh-key".path}
''; '';
systemd.tmpfiles.rules = let systemd.tmpfiles.rules =
# To be used similarly to $GITEA_CUSTOM variable. let
giteaCustomDir = "${config.services.gitea.stateDir}/custom"; # To be used similarly to $GITEA_CUSTOM variable.
in [ giteaCustomDir = "${config.services.gitea.stateDir}/custom";
"L+ ${giteaCustomDir}/templates/home.tmpl - - - - ${./files/gitea/home.tmpl}" in
"L+ ${giteaCustomDir}/public/img/logo.svg - - - - ${./files/gitea/logo.svg}" [
"L+ ${giteaCustomDir}/public/img/logo.png - - - - ${./files/gitea/logo.png}" "L+ ${giteaCustomDir}/templates/home.tmpl - - - - ${./files/gitea/home.tmpl}"
]; "L+ ${giteaCustomDir}/public/img/logo.svg - - - - ${./files/gitea/logo.svg}"
"L+ ${giteaCustomDir}/public/img/logo.png - - - - ${./files/gitea/logo.png}"
];
system.stateVersion = "22.11"; system.stateVersion = "22.11";
} }

View File

@ -126,9 +126,10 @@ in
withDependencies = true; withDependencies = true;
webserver.enable = true; webserver.enable = true;
jobs = mkJobs { jobs = mkJobs
db = lib.importJSON ./data/jobs.archivebox.json; {
} // { db = lib.importJSON ./data/jobs.archivebox.json;
} // {
computer = { computer = {
urls = [ urls = [
"https://blog.mozilla.org/en/feed/" "https://blog.mozilla.org/en/feed/"

View File

@ -170,7 +170,9 @@ class Outline(object):
if not category: if not category:
continue continue
category_hierarchy = filter(lambda split: split.strip(), category.split("/")) category_hierarchy = filter(
lambda split: split.strip(), category.split("/")
)
first_category_split = first(None, category_hierarchy) first_category_split = first(None, category_hierarchy)
if first_category_split is None: if first_category_split is None:
continue continue
@ -231,10 +233,7 @@ def create_jobs_from_outline(root_outline: Outline, categories=[]):
for subscription in outline.subscriptions: for subscription in outline.subscriptions:
# There are some things that are meant not to be shown (i.e., # There are some things that are meant not to be shown (i.e.,
# `categories`) so we're putting it in a data template. # `categories`) so we're putting it in a data template.
subscription_data = { subscription_data = {"name": subscription.name, "url": subscription.url}
"name": subscription.name,
"url": subscription.url
}
if subscription.description: if subscription.description:
subscription_data["description"] = subscription.description subscription_data["description"] = subscription.description

View File

@ -26,7 +26,8 @@ stdenv.mkDerivation rec {
}; };
nativeBuildInputs = with qt5; [ nativeBuildInputs = with qt5; [
autoreconfHook pkg-config autoreconfHook
pkg-config
wrapQtAppsHook wrapQtAppsHook
qtbase qtbase
qtwebchannel qtwebchannel

View File

@ -36,6 +36,6 @@ in
# Allow the user to easily enter into several services such as the database # Allow the user to easily enter into several services such as the database
# services to allowing some debugging. # services to allowing some debugging.
services.postgresql.ensureUsers = [ { inherit name; } ]; services.postgresql.ensureUsers = [{ inherit name; }];
services.mysql.ensureUsers = [ { inherit name; } ]; services.mysql.ensureUsers = [{ inherit name; }];
} }