custom oizys settings files

This commit is contained in:
Daylin Morgan 2025-01-06 15:29:31 -06:00
parent 728f7ef279
commit e495c7d8bb
Signed by: daylin
GPG key ID: 950D13E9719334AD
6 changed files with 56 additions and 46 deletions

View file

@ -1,44 +1,14 @@
{
lib,
enabled,
enableAttrs,
listify,
config,
...
}:
let
inherit (lib.strings) hasPrefix splitString;
inherit (builtins) readFile filter;
readLanguageSettings = f: f |> readFile |> splitString "\n" |> filter (line: !(hasPrefix "#" line));
in
{
oizys =
{
nix-ld = enabled // {
overkill = enabled;
};
languages = readLanguageSettings ./settings/languages;
# languages = "misc|nim|node|nushell|python|tex|typst" |> listify;
}
// (
''
desktop
hp-scanner
hyprland
chrome
vpn
backups
llm
vbox
podman
docker
utils
''
|> listify
|> enableAttrs
);
oizys = {
nix-ld = enabled // {
overkill = enabled;
};
};
sops = {
defaultSopsFile = ./secrets.yaml;

View file

@ -10,7 +10,6 @@
attic-client
distrobox
# cachix
zk
@ -18,7 +17,6 @@
charm-freeze
quarto
calibre
]);
}

View file

@ -0,0 +1,11 @@
backups
chrome
desktop
docker
hp-scanner
hyprland
llm
podman
utils
vbox
vpn

View file

@ -8,6 +8,9 @@ let
filter
attrNames
readDir
readFile
pathExists
length
;
inherit (final)
concatStringsSep
@ -16,6 +19,7 @@ let
mkIf
mkOption
types
hasPrefix
splitString
trim
;
@ -119,6 +123,30 @@ let
|> filter (f: f != "default.nix")
|> map (f: import (../overlays + "/${f}") { inherit inputs; });
readLinesNoComment =
f: f |> readFile |> splitString "\n" |> filter (line: !(hasPrefix "#" line) && line != "");
pathFromHostName = host: ../. + "/hosts/${host}";
hostFiles = host: host |> pathFromHostName |> listFilesRecursive |> filter isNixFile;
# if the specified path doesn't exist returns an empty array
tryReadLinesNoComment = f: if pathExists f then (readLinesNoComment f) else [ ];
tryreadEnabledAttrsOrEmpty =
p: p |> tryReadLinesNoComment |> (lines: if (length lines) > 0 then lines |> enableAttrs else { });
oizysSettings =
hostName:
hostName
|> pathFromHostName
|> (
p:
{
languages = tryReadLinesNoComment "${p}/settings/languages";
}
// (tryreadEnabledAttrsOrEmpty "${p}/settings/modules")
);
in
{
inherit
@ -139,5 +167,7 @@ in
flakeFromSystem
listify
loadOverlays
hostFiles
oizysSettings
;
}

View file

@ -12,19 +12,17 @@ let
mkOizysModule
enabled
enableAttrs
isNixFile
flakeFromSystem
listify
readSettings
hostFiles
;
inherit (lib.filesystem) listFilesRecursive;
flake = flakeFromSystem "x86_64-linux";
hostPath = host: ../. + "/hosts/${host}";
hostFiles = host: host |> hostPath |> listFilesRecursive |> filter isNixFile;
nixosModules = names: names |> listify |> map (n: inputs.${n}.nixosModules.default);
selfModules = names: names |> listify |> map (n: self.nixosModules.${n});
# generate anonymous module to set oizys settings from existing plaintext files
commonSpecialArgs = {
inherit
self
@ -45,19 +43,21 @@ let
nixosSystem {
system = "x86_64-linux";
modules =
[]
[
]
++ (selfModules ''oizys'')
++ (nixosModules ''lix-module|sops-nix'')
++ (hostFiles hostName);
specialArgs = commonSpecialArgs // {
inherit
flake
mkDefaultOizysModule
mkOizysModule
listify
enableAttrs
hostName
flake
readSettings
;
};
};

View file

@ -6,7 +6,7 @@
...
}:
let
inherit (lib) mkEnableOption mkOption loadOverlays;
inherit (lib) mkEnableOption mkOption loadOverlays oizysSettings;
in
{
imports = with self.nixosModules; [
@ -60,5 +60,6 @@ in
networking.hostName = hostName;
time.timeZone = "US/Central";
nixpkgs.overlays = import ../overlays { inherit inputs loadOverlays; };
oizys = oizysSettings hostName;
};
}