mirror of
https://github.com/blahai/nyx.git
synced 2025-02-23 11:55:09 +00:00
Style: formatting
This commit is contained in:
parent
c6d2a9bf10
commit
70e622f996
5 changed files with 314 additions and 322 deletions
|
@ -1,11 +1,11 @@
|
||||||
{ lib }:
|
{lib}: let
|
||||||
let
|
|
||||||
inherit (lib.lists) forEach filter;
|
inherit (lib.lists) forEach filter;
|
||||||
inherit (lib.attrsets) filterAttrs mapAttrsToList;
|
inherit (lib.attrsets) filterAttrs mapAttrsToList;
|
||||||
inherit (lib.filesystem) listFilesRecursive;
|
inherit (lib.filesystem) listFilesRecursive;
|
||||||
inherit (lib.strings) hasSuffix;
|
inherit (lib.strings) hasSuffix;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
filter files for the .nix suffix
|
filter files for the .nix suffix
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -28,7 +28,8 @@ let
|
||||||
*/
|
*/
|
||||||
filterNixFiles = k: v: v == "regular" && hasSuffix ".nix" k;
|
filterNixFiles = k: v: v == "regular" && hasSuffix ".nix" k;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
Import all file that filterNixFiles allows for
|
Import all file that filterNixFiles allows for
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -48,14 +49,14 @@ let
|
||||||
=> [ {...} ]
|
=> [ {...} ]
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
importNixFiles =
|
importNixFiles = path:
|
||||||
path:
|
|
||||||
(forEach (
|
(forEach (
|
||||||
mapAttrsToList (name: _: path + ("/" + name)) (filterAttrs filterNixFiles (builtins.readDir path))
|
mapAttrsToList (name: _: path + ("/" + name)) (filterAttrs filterNixFiles (builtins.readDir path))
|
||||||
))
|
))
|
||||||
import;
|
import;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
import all nix files and directories
|
import all nix files and directories
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -77,7 +78,8 @@ let
|
||||||
*/
|
*/
|
||||||
importNixFilesAndDirs = dir: filter (f: f != "default.nix") (listFilesRecursive dir);
|
importNixFilesAndDirs = dir: filter (f: f != "default.nix") (listFilesRecursive dir);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
return an int based on boolean value
|
return an int based on boolean value
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -97,9 +99,13 @@ let
|
||||||
=> 1
|
=> 1
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
boolToNum = bool: if bool then 1 else 0;
|
boolToNum = bool:
|
||||||
|
if bool
|
||||||
|
then 1
|
||||||
|
else 0;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
convert a list of integers to a list of string
|
convert a list of integers to a list of string
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -121,7 +127,8 @@ let
|
||||||
*/
|
*/
|
||||||
intListToStringList = list: map (toString list);
|
intListToStringList = list: map (toString list);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
a function that returns the index of an element in a list
|
a function that returns the index of an element in a list
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -142,21 +149,18 @@ let
|
||||||
=> 1
|
=> 1
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
indexOf =
|
indexOf = list: elem: let
|
||||||
list: elem:
|
f = f: i:
|
||||||
let
|
if i == (builtins.length list)
|
||||||
f =
|
then null
|
||||||
f: i:
|
else if (builtins.elemAt list i) == elem
|
||||||
if i == (builtins.length list) then
|
then i
|
||||||
null
|
else f f (i + 1);
|
||||||
else if (builtins.elemAt list i) == elem then
|
|
||||||
i
|
|
||||||
else
|
|
||||||
f f (i + 1);
|
|
||||||
in
|
in
|
||||||
f f 0;
|
f f 0;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
a function that checks if a list contains a list of given strings
|
a function that checks if a list contains a list of given strings
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -177,10 +181,10 @@ let
|
||||||
=> true
|
=> true
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
containsStrings =
|
containsStrings = list: targetStrings: builtins.all (s: builtins.any (x: x == s) list) targetStrings;
|
||||||
list: targetStrings: builtins.all (s: builtins.any (x: x == s) list) targetStrings;
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
Create git url aliases for a given domain
|
Create git url aliases for a given domain
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -206,28 +210,25 @@ let
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
giturl =
|
giturl = {
|
||||||
{
|
|
||||||
domain,
|
domain,
|
||||||
alias,
|
alias,
|
||||||
user ? "git",
|
user ? "git",
|
||||||
port ? null,
|
port ? null,
|
||||||
...
|
...
|
||||||
}:
|
}: {
|
||||||
{
|
|
||||||
"https://${domain}/".insteadOf = "${alias}:";
|
"https://${domain}/".insteadOf = "${alias}:";
|
||||||
"ssh://${user}@${domain}${
|
"ssh://${user}@${domain}${
|
||||||
if (builtins.isNull port) then
|
if (builtins.isNull port)
|
||||||
""
|
then ""
|
||||||
else if (builtins.isInt port) then
|
else if (builtins.isInt port)
|
||||||
":" + (builtins.toString port)
|
then ":" + (builtins.toString port)
|
||||||
else
|
else ":" + port
|
||||||
":" + port
|
}/".pushInsteadOf = "${alias}:";
|
||||||
}/".pushInsteadOf =
|
|
||||||
"${alias}:";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
Create a public key for a given host
|
Create a public key for a given host
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -258,12 +259,13 @@ let
|
||||||
*/
|
*/
|
||||||
mkPub = host: key: {
|
mkPub = host: key: {
|
||||||
"${host}-${key.type}" = {
|
"${host}-${key.type}" = {
|
||||||
hostNames = [ host ];
|
hostNames = [host];
|
||||||
publicKey = "ssh-${key.type} ${key.key}";
|
publicKey = "ssh-${key.type} ${key.key}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
Create public keys for a given host
|
Create public keys for a given host
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -302,9 +304,8 @@ let
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkPubs = host: keys: lib.foldl' (acc: key: acc // mkPub host key) { } keys;
|
mkPubs = host: keys: lib.foldl' (acc: key: acc // mkPub host key) {} keys;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
inherit
|
inherit
|
||||||
mkPub
|
mkPub
|
||||||
mkPubs
|
mkPubs
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
{ lib }:
|
{lib}: let
|
||||||
let
|
|
||||||
inherit (lib.options) mkEnableOption mkPackageOption;
|
inherit (lib.options) mkEnableOption mkPackageOption;
|
||||||
inherit (lib.attrsets) recursiveUpdate;
|
inherit (lib.attrsets) recursiveUpdate;
|
||||||
|
|
||||||
mkProgram =
|
mkProgram = pkgs: name: extraConfig:
|
||||||
pkgs: name: extraConfig:
|
|
||||||
recursiveUpdate {
|
recursiveUpdate {
|
||||||
enable = mkEnableOption "Enable ${name}";
|
enable = mkEnableOption "Enable ${name}";
|
||||||
package = mkPackageOption pkgs name { };
|
package = mkPackageOption pkgs name {};
|
||||||
} extraConfig;
|
}
|
||||||
in
|
extraConfig;
|
||||||
{
|
in {
|
||||||
inherit mkProgram;
|
inherit mkProgram;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{ inputs }:
|
{inputs}: let
|
||||||
let
|
|
||||||
inherit (inputs) self;
|
inherit (inputs) self;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
Create secrets for use with `agenix`.
|
Create secrets for use with `agenix`.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -30,20 +30,19 @@ let
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSecret =
|
mkSecret = {
|
||||||
{
|
|
||||||
file,
|
file,
|
||||||
owner ? "root",
|
owner ? "root",
|
||||||
group ? "root",
|
group ? "root",
|
||||||
mode ? "400",
|
mode ? "400",
|
||||||
...
|
...
|
||||||
}:
|
}: {
|
||||||
{
|
|
||||||
file = "${self}/secrets/${file}.age";
|
file = "${self}/secrets/${file}.age";
|
||||||
inherit owner group mode;
|
inherit owner group mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
A light wrapper around mkSecret that allows you to specify the output path
|
A light wrapper around mkSecret that allows you to specify the output path
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -73,8 +72,7 @@ let
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSecretWithPath =
|
mkSecretWithPath = {
|
||||||
{
|
|
||||||
file,
|
file,
|
||||||
path,
|
path,
|
||||||
owner ? "root",
|
owner ? "root",
|
||||||
|
@ -93,7 +91,6 @@ let
|
||||||
// {
|
// {
|
||||||
inherit path;
|
inherit path;
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
inherit mkSecret mkSecretWithPath;
|
inherit mkSecret mkSecretWithPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
{ lib }:
|
{lib}: let
|
||||||
let
|
|
||||||
inherit (lib.types) str;
|
inherit (lib.types) str;
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.attrsets) recursiveUpdate;
|
inherit (lib.attrsets) recursiveUpdate;
|
||||||
|
|
||||||
mkGraphicalService = recursiveUpdate {
|
mkGraphicalService = recursiveUpdate {
|
||||||
Unit.PartOf = [ "graphical-session.target" ];
|
Unit.PartOf = ["graphical-session.target"];
|
||||||
Unit.After = [ "graphical-session.target" ];
|
Unit.After = ["graphical-session.target"];
|
||||||
Install.WantedBy = [ "graphical-session.target" ];
|
Install.WantedBy = ["graphical-session.target"];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkHyprlandService = recursiveUpdate {
|
mkHyprlandService = recursiveUpdate {
|
||||||
Unit.PartOf = [ "graphical-session.target" ];
|
Unit.PartOf = ["graphical-session.target"];
|
||||||
Unit.After = [ "graphical-session.target" ];
|
Unit.After = ["graphical-session.target"];
|
||||||
Install.WantedBy = [ "hyprland-session.target" ];
|
Install.WantedBy = ["hyprland-session.target"];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
|
*
|
||||||
A quick way to use my services abstraction
|
A quick way to use my services abstraction
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -29,13 +29,11 @@ let
|
||||||
mkServiceOption :: String -> (Int -> String -> String -> AttrSet) -> AttrSet
|
mkServiceOption :: String -> (Int -> String -> String -> AttrSet) -> AttrSet
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkServiceOption =
|
mkServiceOption = name: {
|
||||||
name:
|
|
||||||
{
|
|
||||||
port ? 0,
|
port ? 0,
|
||||||
host ? "127.0.0.1",
|
host ? "127.0.0.1",
|
||||||
domain ? "",
|
domain ? "",
|
||||||
extraConfig ? { },
|
extraConfig ? {},
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
enable = mkEnableOption "Enable the ${name} service";
|
enable = mkEnableOption "Enable the ${name} service";
|
||||||
|
@ -59,7 +57,6 @@ let
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// extraConfig;
|
// extraConfig;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
inherit mkGraphicalService mkHyprlandService mkServiceOption;
|
inherit mkGraphicalService mkHyprlandService mkServiceOption;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@ let
|
||||||
XDG_STATE_HOME = "$HOME/.local/state";
|
XDG_STATE_HOME = "$HOME/.local/state";
|
||||||
XDG_BIN_HOME = "$HOME/.local/bin";
|
XDG_BIN_HOME = "$HOME/.local/bin";
|
||||||
XDG_RUNTIME_DIR = "/run/user/$UID";
|
XDG_RUNTIME_DIR = "/run/user/$UID";
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
# global env
|
# global env
|
||||||
glEnv = {
|
glEnv = {
|
||||||
inherit
|
inherit
|
||||||
|
@ -18,7 +17,7 @@ in
|
||||||
XDG_BIN_HOME
|
XDG_BIN_HOME
|
||||||
XDG_RUNTIME_DIR
|
XDG_RUNTIME_DIR
|
||||||
;
|
;
|
||||||
PATH = [ "$XDG_BIN_HOME" ];
|
PATH = ["$XDG_BIN_HOME"];
|
||||||
};
|
};
|
||||||
|
|
||||||
sysEnv = {
|
sysEnv = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue