refactor: simplify repo paths
check / lint (push) Successful in 14s

This commit is contained in:
2026-10-11 17:45:55 +02:00
parent 7f5d7914c4
commit 14f8c83cf3
8 changed files with 33 additions and 26 deletions
+4 -1
View File
@@ -42,8 +42,11 @@ inputs.colmena.lib.makeHive (
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
outputs = self; outputs = self;
dotsPath = ../dots;
myUtils = utils; myUtils = utils;
paths = {
dots = ../dots;
hosts = ../hosts;
};
}; };
}; };
} }
+8 -5
View File
@@ -75,7 +75,10 @@
myUtils = import ./utils { inherit lib; }; myUtils = import ./utils { inherit lib; };
hostDirNames = myUtils.dirNames ./hosts; hostDirNames = myUtils.dirNames ./hosts;
system = "x86_64-linux"; system = "x86_64-linux";
dotsPath = ./dots; paths = {
dots = ./dots;
hosts = ./hosts;
};
gitHooks = import ./git-hooks.nix { gitHooks = import ./git-hooks.nix {
inherit nixpkgs git-hooks system; inherit nixpkgs git-hooks system;
src = ./.; src = ./.;
@@ -97,7 +100,7 @@
inherit inherit
inputs inputs
outputs outputs
dotsPath paths
myUtils myUtils
; ;
}; };
@@ -117,7 +120,7 @@
inherit inherit
inputs inputs
outputs outputs
dotsPath paths
myUtils myUtils
; ;
}; };
@@ -135,7 +138,7 @@
inherit inherit
inputs inputs
outputs outputs
dotsPath paths
myUtils myUtils
; ;
}; };
@@ -154,7 +157,7 @@
inherit inherit
inputs inputs
outputs outputs
dotsPath paths
myUtils myUtils
; ;
}; };
+4 -4
View File
@@ -4,22 +4,22 @@
pkgs, pkgs,
inputs, inputs,
myUtils, myUtils,
paths,
... ...
}: }:
let let
cfg = config.deploy; cfg = config.deploy;
hostDir = ../../../hosts; hostNames = myUtils.dirNames paths.hosts;
hostNames = myUtils.dirNames hostDir;
hostsWithKeys = lib.filter ( hostsWithKeys = lib.filter (
hostname: builtins.pathExists (hostDir + "/${hostname}/ssh_host.pub") hostname: builtins.pathExists (paths.hosts + "/${hostname}/ssh_host.pub")
) hostNames; ) hostNames;
colmena = inputs.colmena.packages.${pkgs.stdenv.hostPlatform.system}.colmena; colmena = inputs.colmena.packages.${pkgs.stdenv.hostPlatform.system}.colmena;
deployRs = inputs.deploy-rs.packages.${pkgs.stdenv.hostPlatform.system}.default; deployRs = inputs.deploy-rs.packages.${pkgs.stdenv.hostPlatform.system}.default;
hostTags = hostname: (myUtils.hostMeta (hostDir + "/${hostname}")).tags; hostTags = hostname: (myUtils.hostMeta (paths.hosts + "/${hostname}")).tags;
nodeTagsDecl = '' nodeTagsDecl = ''
declare -A _colmena_node_tags=( declare -A _colmena_node_tags=(
${lib.concatMapStringsSep "\n" ( ${lib.concatMapStringsSep "\n" (
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
config, config,
lib, lib,
dotsPath, paths,
... ...
}: }:
@@ -66,6 +66,6 @@ in
''; '';
}; };
home.sessionPath = lib.optional cfg.addBinToPath "${dotsPath}/.bin"; home.sessionPath = lib.optional cfg.addBinToPath "${paths.dots}/.bin";
}; };
} }
+6 -6
View File
@@ -3,16 +3,16 @@
lib, lib,
pkgs, pkgs,
myUtils, myUtils,
paths,
... ...
}: }:
let let
cfg = config.ssh; cfg = config.ssh;
hostNames = myUtils.dirNames paths.hosts;
hostDir = ../../../hosts; hostsWithKeys = lib.filter (
hostsWithKeys = lib.filter (hostname: builtins.pathExists (hostDir + "/${hostname}/ssh_host.pub")) ( hostname: builtins.pathExists (paths.hosts + "/${hostname}/ssh_host.pub")
myUtils.dirNames hostDir ) hostNames;
);
in in
{ {
options.ssh.enable = lib.mkEnableOption "ssh"; options.ssh.enable = lib.mkEnableOption "ssh";
@@ -37,7 +37,7 @@ in
lib.genAttrs hostsWithKeys ( lib.genAttrs hostsWithKeys (
hostname: hostname:
let let
meta = myUtils.hostMeta (hostDir + "/${hostname}"); meta = myUtils.hostMeta (paths.hosts + "/${hostname}");
in in
{ {
User = meta.host.username; User = meta.host.username;
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
inputs, inputs,
outputs, outputs,
dotsPath, paths,
myUtils, myUtils,
config, config,
lib, lib,
@@ -21,7 +21,7 @@ in
inherit inherit
inputs inputs
outputs outputs
dotsPath paths
myUtils myUtils
; ;
}; };
+3 -2
View File
@@ -1,12 +1,13 @@
{ {
lib, lib,
config, config,
paths,
... ...
}: }:
let let
inherit (config.host) username; inherit (config.host) username;
adminHosts = (import ../../utils { inherit lib; }).adminHosts ../../hosts; adminHosts = (import ../../utils { inherit lib; }).adminHosts paths.hosts;
in in
{ {
options.ssh = { options.ssh = {
@@ -22,7 +23,7 @@ in
map ( map (
hostname: hostname:
let let
keyFile = ../../hosts/${hostname}/ssh_user.pub; keyFile = paths.hosts + "/${hostname}/ssh_user.pub";
in in
lib.optionals (builtins.pathExists keyFile) (lib.splitString "\n" (builtins.readFile keyFile)) lib.optionals (builtins.pathExists keyFile) (lib.splitString "\n" (builtins.readFile keyFile))
) ((builtins.filter (h: h != config.host.name) adminHosts) ++ config.ssh.authorizedHosts) ) ((builtins.filter (h: h != config.host.name) adminHosts) ++ config.ssh.authorizedHosts)
+4 -4
View File
@@ -2,19 +2,19 @@
lib, lib,
config, config,
outputs, outputs,
paths,
... ...
}: }:
let let
hosts = lib.attrNames outputs.nixosConfigurations; hosts = lib.attrNames outputs.nixosConfigurations;
hostsWithKeys = lib.filter ( keyPath = hostname: paths.hosts + "/${hostname}/ssh_host.pub";
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub hostsWithKeys = lib.filter (hostname: builtins.pathExists (keyPath hostname)) hosts;
) hosts;
in in
{ {
config = lib.mkIf config.ssh.enable { config = lib.mkIf config.ssh.enable {
programs.ssh.knownHosts = lib.genAttrs hostsWithKeys (hostname: { programs.ssh.knownHosts = lib.genAttrs hostsWithKeys (hostname: {
publicKeyFile = ../../hosts/${hostname}/ssh_host.pub; publicKeyFile = keyPath hostname;
extraHostNames = lib.optional (hostname == config.networking.hostName) "localhost"; extraHostNames = lib.optional (hostname == config.networking.hostName) "localhost";
}); });
}; };