This repository has no description
Something went wrong. Try again.
5.4 kB · 161 lines
Nix
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162{ config, lib, pkgs, moppkgs, ...}:let cfg = config.sidonia; fromHexString = hex: (fromTOML "getInt = 0h${hex}").getInt;in{ options = { sidonia = { lib = lib.mkOption { readOnly = true; type = lib.types.attrs; default = { capitalize = str: let chars = lib.stringToCharacters str; in lib.concatStrings ([ (lib.toUpper (builtins.head chars)) ] ++ (builtins.tail chars)); fromHexToRgb = hex: lib.concatStringsSep ", " ( map (x: toString (fromHexString x)) [ (builtins.substring 0 2 hex) (builtins.substring 2 2 hex) (builtins.substring 4 2 hex) ] ); patchDesktop = pkg: appName: f: lib.hiPrio ( pkgs.writeTextFile { name = "${appName}.desktop"; destination = "/share/applications/${appName}.desktop"; text = lib.concatLines ( lib.mapAttrsToList ( group: keys: lib.concatLines ([ "[${group}]" ] ++ (lib.mapAttrsToList (key: value: "${key}=${value}") keys)) ) ( f ( lib.importTOML ( pkgs.runCommand "desktop-to-toml-${appName}" { } '' sed -r 's/^(\[)(.*)(\])$/\1"\2"\3/;s/^(.*=)(.*)$/\1"\2"/' ${pkg}/share/applications/${appName}.desktop > $out '' ) ) ) ); checkPhase = ''${pkgs.desktop-file-utils}/bin/desktop-file-validate "$target"''; } ); addDesktopFlags = pkg: appName: flags: cfg.lib.patchDesktop pkg appName ( prev: lib.recursiveUpdate prev { "Desktop Entry" = { Exec = lib.concatStringsSep " " ([ prev."Desktop Entry".Exec ] ++ flags); }; } );
home = { applications = "/home/${cfg.userName}/.nix-profile/share/applications"; autostart = "/home/${cfg.userName}/.config/autostart"; }; configContainerCredential = f: service: path: let hash = builtins.hashString "sha256" "${path}"; rootCredName = "${service}-${hash}-Root"; localCredName = "${service}-${hash}-Local"; in { extraFlags = [ "--load-credential=${rootCredName}:${path}" ]; config = lib.mkMerge [ { systemd.services."${service}".serviceConfig.LoadCredential = [ "${localCredName}:${rootCredName}" ]; } (f "/run/credentials/${service}.service/${localCredName}") ]; }; }; }; ssh = { pubKey = lib.mkOption { type = lib.types.str; default = ""; }; privKeyPath = lib.mkOption { type = lib.types.path; default = "/home/${cfg.userName}/.ssh/id_ed25519"; }; }; userName = lib.mkOption { description = "Username of main user"; type = lib.types.str; }; geolocation.enable = lib.mkEnableOption "Turn on geolocation related services such as automatic timezone changing and geoclue"; isLaptop = lib.mkEnableOption "Apply laptop-specific tweaks"; legacyGpu = lib.mkEnableOption "Apply tweaks for OpenGL ES 2 device support"; text = { comicCode = lib.mkOption { default = { }; type = lib.types.submodule { options = { enable = lib.mkEnableOption "Use Comic Code monospace font"; ligatures.enable = lib.mkOption { description = "Use ligatures by default"; default = true; type = lib.types.bool; }; source = lib.mkOption { description = "Source zip file containing the font"; type = lib.types.nullOr lib.types.path; default = null; }; }; }; apply = x: { inherit (x) enable; package = if (isNull x.source) then moppkgs.comic-code else (moppkgs.comic-code.overrideAttrs { src = x.source; }); name = if x.enable then if x.ligatures.enable then "Comic Code Ligatures" else "Comic Code" else "ComicShannsMono Nerd Font"; }; }; }; desktop = { enable = lib.mkEnableOption "Enable desktop environment"; compositor = lib.mkOption { description = "Which compositor to use"; type = lib.types.enum [ "niri" ]; default = "niri"; }; shell = lib.mkOption { description = "What desktop shell to use"; type = lib.types.enum [ "noctalia" ]; default = "noctalia"; }; }; }; };}