wooooooot, we're compiling again
This commit is contained in:
parent
97b63074f0
commit
ba7c3392b9
94 changed files with 654 additions and 677 deletions
|
|
@ -5,47 +5,12 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib) mkOption types;
|
||||
namespace = "sneeuwvlok";
|
||||
|
||||
sharedContext = {
|
||||
inherit inputs namespace;
|
||||
erosanixLib = inputs.erosanix.lib;
|
||||
repoRoot = ../.;
|
||||
sneeuwvlokLib = config.localLib;
|
||||
terranixLib = inputs.terranix.lib;
|
||||
};
|
||||
|
||||
baseNixosModules =
|
||||
[
|
||||
inputs.grub2-themes.nixosModules.default
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.himmelblau.nixosModules.himmelblau
|
||||
inputs.jovian.nixosModules.default
|
||||
inputs.mydia.nixosModules.default
|
||||
inputs.nix-minecraft.nixosModules.minecraft-servers
|
||||
inputs.nvf.nixosModules.default
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = sharedContext;
|
||||
sharedModules = config.localUsers.homeSharedModules;
|
||||
};
|
||||
}
|
||||
]
|
||||
++ [../modules/nixos];
|
||||
in {
|
||||
imports = [
|
||||
./options
|
||||
./strings
|
||||
];
|
||||
|
||||
options.localLib = mkOption {
|
||||
type = types.lazyAttrsOf types.raw;
|
||||
default = {};
|
||||
};
|
||||
|
||||
config = {
|
||||
_module.args = {
|
||||
inherit
|
||||
|
|
@ -55,7 +20,6 @@ in {
|
|||
sharedContext
|
||||
systemOverlays
|
||||
;
|
||||
sneeuwvlokLib = config.localLib;
|
||||
};
|
||||
|
||||
flake.lib = config.localLib;
|
||||
|
|
|
|||
|
|
@ -2,36 +2,54 @@
|
|||
inherit (builtins) isString typeOf match toString head;
|
||||
inherit (lib) throwIfNot concatStringsSep splitStringBy toLower map concatMapAttrsStringSep;
|
||||
in {
|
||||
localLib.strings = {
|
||||
strings = {
|
||||
#========================================================================================
|
||||
# Converts a string to snake case
|
||||
#
|
||||
# simply replaces any uppercase letter to its lowercase variant preceeded by an underscore
|
||||
#========================================================================================
|
||||
toSnakeCase =
|
||||
str:
|
||||
toSnakeCase = str:
|
||||
throwIfNot (isString str) "toSnakeCase only accepts string values, but got ${typeOf str}" (
|
||||
str
|
||||
|> splitStringBy (prev: curr: builtins.match "[a-z]" prev != null && builtins.match "[A-Z]" curr != null) true
|
||||
|> map (p: toLower p)
|
||||
|> concatStringsSep "_"
|
||||
|> splitStringBy (prev: curr: builtins.match "[a-z]" prev != null && builtins.match "[A-Z]" curr != null) true
|
||||
|> map (p: toLower p)
|
||||
|> concatStringsSep "_"
|
||||
);
|
||||
|
||||
#========================================================================================
|
||||
# Converts a set of url parts to a string
|
||||
#========================================================================================
|
||||
toUrl =
|
||||
{ protocol ? null, host, port ? null, path ? null, query ? null, hash ? null }:
|
||||
let
|
||||
trim_slashes = str: str |> match "^\/*(.+?)\/*$" |> head;
|
||||
encode_to_str = set: concatMapAttrsStringSep "&" (n: v: "${n}=${v}") set;
|
||||
|
||||
_protocol = if protocol != null then "${protocol}://" else "";
|
||||
_port = if port != null then ":${toString port}" else "";
|
||||
_path = if path != null then "/${path |> trim_slashes}" else "";
|
||||
_query = if query != null then "?${query |> encode_to_str}" else "";
|
||||
_hash = if hash != null then "#${hash |> encode_to_str}" else "";
|
||||
in
|
||||
"${_protocol}${host}${_port}${_path}${_query}${_hash}";
|
||||
toUrl = {
|
||||
protocol ? null,
|
||||
host,
|
||||
port ? null,
|
||||
path ? null,
|
||||
query ? null,
|
||||
hash ? null,
|
||||
}: let
|
||||
trim_slashes = str: str |> match "^\/*(.+?)\/*$" |> head;
|
||||
encode_to_str = set: concatMapAttrsStringSep "&" (n: v: "${n}=${v}") set;
|
||||
|
||||
_protocol =
|
||||
if protocol != null
|
||||
then "${protocol}://"
|
||||
else "";
|
||||
_port =
|
||||
if port != null
|
||||
then ":${toString port}"
|
||||
else "";
|
||||
_path =
|
||||
if path != null
|
||||
then "/${path |> trim_slashes}"
|
||||
else "";
|
||||
_query =
|
||||
if query != null
|
||||
then "?${query |> encode_to_str}"
|
||||
else "";
|
||||
_hash =
|
||||
if hash != null
|
||||
then "#${hash |> encode_to_str}"
|
||||
else "";
|
||||
in "${_protocol}${host}${_port}${_path}${_query}${_hash}";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue