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, enabled,
enableAttrs,
listify,
config, config,
... ...
}: }:
let
inherit (lib.strings) hasPrefix splitString;
inherit (builtins) readFile filter;
readLanguageSettings = f: f |> readFile |> splitString "\n" |> filter (line: !(hasPrefix "#" line));
in
{ {
oizys = {
oizys = nix-ld = enabled // {
{ overkill = enabled;
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
);
sops = { sops = {
defaultSopsFile = ./secrets.yaml; defaultSopsFile = ./secrets.yaml;

View file

@ -10,7 +10,6 @@
attic-client attic-client
distrobox distrobox
# cachix # cachix
zk zk
@ -18,7 +17,6 @@
charm-freeze charm-freeze
quarto quarto
calibre 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 filter
attrNames attrNames
readDir readDir
readFile
pathExists
length
; ;
inherit (final) inherit (final)
concatStringsSep concatStringsSep
@ -16,6 +19,7 @@ let
mkIf mkIf
mkOption mkOption
types types
hasPrefix
splitString splitString
trim trim
; ;
@ -119,6 +123,30 @@ let
|> filter (f: f != "default.nix") |> filter (f: f != "default.nix")
|> map (f: import (../overlays + "/${f}") { inherit inputs; }); |> 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 in
{ {
inherit inherit
@ -139,5 +167,7 @@ in
flakeFromSystem flakeFromSystem
listify listify
loadOverlays loadOverlays
hostFiles
oizysSettings
; ;
} }

View file

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

View file

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