mirror of
https://github.com/blahai/nyx.git
synced 2025-02-23 12:15:09 +00:00
Style: formatting
This commit is contained in:
parent
c6d2a9bf10
commit
70e622f996
5 changed files with 314 additions and 322 deletions
|
@ -1,310 +1,311 @@
|
||||||
{ 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
|
||||||
|
|
||||||
- [k] they key, which is the file name
|
- [k] they key, which is the file name
|
||||||
- [v] the value, which is the type of the file
|
- [v] the value, which is the type of the file
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
filterNixFiles :: String -> String -> Bool
|
filterNixFiles :: String -> String -> Bool
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
filterNixFiles "default.nix" "regular"
|
filterNixFiles "default.nix" "regular"
|
||||||
=> true
|
=> true
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
- [path] the path to the directory
|
- [path] the path to the directory
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
importNixFiles :: String -> List
|
importNixFiles :: String -> List
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
importNixFiles ./.
|
importNixFiles ./.
|
||||||
=> [ {...} ]
|
=> [ {...} ]
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
- [dir] the directory to search for nix files
|
- [dir] the directory to search for nix files
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
importNixFilesAndDirs :: String -> List
|
importNixFilesAndDirs :: String -> List
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
importNixFilesAndDirs ./.
|
importNixFilesAndDirs ./.
|
||||||
=> [ "flake.nix" ]
|
=> [ "flake.nix" ]
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
- [bool] the boolean value
|
- [bool] the boolean value
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
boolToNum :: Bool -> Int
|
boolToNum :: Bool -> Int
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
boolToNum true
|
boolToNum true
|
||||||
=> 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
|
||||||
|
|
||||||
- [list] the list of integers
|
- [list] the list of integers
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
intListToStringList :: List -> List
|
intListToStringList :: List -> List
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
intListToStringList [1 2 3]
|
intListToStringList [1 2 3]
|
||||||
=> ["1" "2" "3"]
|
=> ["1" "2" "3"]
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
- [list] the list to search in
|
- [list] the list to search in
|
||||||
- [elem] the element to search for
|
- [elem] the element to search for
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
indexOf :: List -> Any -> Int
|
indexOf :: List -> Any -> Int
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
indexOf [1 2 3] 2
|
indexOf [1 2 3] 2
|
||||||
=> 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
|
in
|
||||||
i
|
|
||||||
else
|
|
||||||
f f (i + 1);
|
|
||||||
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
|
||||||
|
|
||||||
- [list] the list to search in
|
- [list] the list to search in
|
||||||
- [targetStrings] the list of strings to search for
|
- [targetStrings] the list of strings to search for
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
containsStrings :: List -> List -> Bool
|
containsStrings :: List -> List -> Bool
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
containsStrings ["a" "b" "c"] ["a" "b"]
|
containsStrings ["a" "b" "c"] ["a" "b"]
|
||||||
=> 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
|
||||||
|
|
||||||
- [domain] the domain to create the alias for
|
- [domain] the domain to create the alias for
|
||||||
- [alias] the alias to use
|
- [alias] the alias to use
|
||||||
- [user] the user to use, this defaults to "git"
|
- [user] the user to use, this defaults to "git"
|
||||||
- [port] the port to use, this is optional
|
- [port] the port to use, this is optional
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
giturl :: (String -> String -> String -> Int) -> AttrSet
|
giturl :: (String -> String -> String -> Int) -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
giturl { domain = "github.com"; alias = "gh"; }
|
giturl { domain = "github.com"; alias = "gh"; }
|
||||||
=> {
|
=> {
|
||||||
"https://github.com/".insteadOf = "gh:";
|
"https://github.com/".insteadOf = "gh:";
|
||||||
"ssh://git@github.com/".pushInsteadOf = "gh:";
|
"ssh://git@github.com/".pushInsteadOf = "gh:";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
giturl =
|
giturl = {
|
||||||
{
|
domain,
|
||||||
domain,
|
alias,
|
||||||
alias,
|
user ? "git",
|
||||||
user ? "git",
|
port ? null,
|
||||||
port ? null,
|
...
|
||||||
...
|
}: {
|
||||||
}:
|
"https://${domain}/".insteadOf = "${alias}:";
|
||||||
{
|
"ssh://${user}@${domain}${
|
||||||
"https://${domain}/".insteadOf = "${alias}:";
|
if (builtins.isNull port)
|
||||||
"ssh://${user}@${domain}${
|
then ""
|
||||||
if (builtins.isNull port) then
|
else if (builtins.isInt port)
|
||||||
""
|
then ":" + (builtins.toString port)
|
||||||
else if (builtins.isInt port) then
|
else ":" + port
|
||||||
":" + (builtins.toString port)
|
}/".pushInsteadOf = "${alias}:";
|
||||||
else
|
};
|
||||||
":" + port
|
|
||||||
}/".pushInsteadOf =
|
/*
|
||||||
"${alias}:";
|
*
|
||||||
|
Create a public key for a given host
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
|
||||||
|
- [host] the host to create the public key for
|
||||||
|
- [key] this is a attrset with the key type and key
|
||||||
|
|
||||||
|
# Type
|
||||||
|
|
||||||
|
```
|
||||||
|
mkPub :: (String -> AttrSet -> AttrSet) -> String -> AttrSet -> AttrSet
|
||||||
|
```
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```nix
|
||||||
|
mkPub "github.com" {
|
||||||
|
type = "rsa";
|
||||||
|
key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
||||||
|
}
|
||||||
|
=> {
|
||||||
|
"github.com-rsa" = {
|
||||||
|
hostNames = [ "github.com" ];
|
||||||
|
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
||||||
};
|
};
|
||||||
|
}
|
||||||
/**
|
```
|
||||||
Create a public key for a given host
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
|
|
||||||
- [host] the host to create the public key for
|
|
||||||
- [key] this is a attrset with the key type and key
|
|
||||||
|
|
||||||
# Type
|
|
||||||
|
|
||||||
```
|
|
||||||
mkPub :: (String -> AttrSet -> AttrSet) -> String -> AttrSet -> AttrSet
|
|
||||||
```
|
|
||||||
|
|
||||||
# Example
|
|
||||||
|
|
||||||
```nix
|
|
||||||
mkPub "github.com" {
|
|
||||||
type = "rsa";
|
|
||||||
key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
|
||||||
}
|
|
||||||
=> {
|
|
||||||
"github.com-rsa" = {
|
|
||||||
hostNames = [ "github.com" ];
|
|
||||||
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
- [host] the host to create the public keys for
|
- [host] the host to create the public keys for
|
||||||
- [keys] the list of keys to create
|
- [keys] the list of keys to create
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkPubs :: (String -> List) -> String -> List -> AttrSet
|
mkPubs :: (String -> List) -> String -> List -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkPubs "github.com" [
|
mkPubs "github.com" [
|
||||||
{
|
{
|
||||||
type = "rsa";
|
type = "rsa";
|
||||||
key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "ed25519";
|
|
||||||
key = "AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
|
|
||||||
}
|
|
||||||
]
|
|
||||||
=> {
|
|
||||||
"github.com-ed25519" = {
|
|
||||||
hostNames = [ "github.com" ];
|
|
||||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
|
|
||||||
};
|
|
||||||
"github.com-rsa" = {
|
|
||||||
hostNames = [ "github.com" ];
|
|
||||||
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
{
|
||||||
|
type = "ed25519";
|
||||||
|
key = "AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
=> {
|
||||||
|
"github.com-ed25519" = {
|
||||||
|
hostNames = [ "github.com" ];
|
||||||
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
|
||||||
|
};
|
||||||
|
"github.com-rsa" = {
|
||||||
|
hostNames = [ "github.com" ];
|
||||||
|
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
*/
|
*/
|
||||||
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,87 +1,85 @@
|
||||||
{ inputs }:
|
{inputs}: let
|
||||||
let
|
|
||||||
inherit (inputs) self;
|
inherit (inputs) self;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Create secrets for use with `agenix`.
|
*
|
||||||
|
Create secrets for use with `agenix`.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- [file] the age file to use for the secret
|
- [file] the age file to use for the secret
|
||||||
- [owner] the owner of the secret, this defaults to "root"
|
- [owner] the owner of the secret, this defaults to "root"
|
||||||
- [group] the group of the secret, this defaults to "root"
|
- [group] the group of the secret, this defaults to "root"
|
||||||
- [mode] the permissions of the secret, this defaults to "400"
|
- [mode] the permissions of the secret, this defaults to "400"
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkSecret :: (String -> String -> String -> String) -> AttrSet
|
mkSecret :: (String -> String -> String -> String) -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkSecret { file = "./my-secret.age"; }
|
mkSecret { file = "./my-secret.age"; }
|
||||||
=> {
|
=> {
|
||||||
file = "./my-secret.age";
|
file = "./my-secret.age";
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
mode = "400";
|
mode = "400";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSecret =
|
mkSecret = {
|
||||||
{
|
file,
|
||||||
file,
|
owner ? "root",
|
||||||
owner ? "root",
|
group ? "root",
|
||||||
group ? "root",
|
mode ? "400",
|
||||||
mode ? "400",
|
...
|
||||||
...
|
}: {
|
||||||
}:
|
file = "${self}/secrets/${file}.age";
|
||||||
{
|
inherit owner group mode;
|
||||||
file = "${self}/secrets/${file}.age";
|
};
|
||||||
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
|
||||||
|
|
||||||
- [file] the age file to use for the secret
|
- [file] the age file to use for the secret
|
||||||
- [owner] the owner of the secret, this defaults to "root"
|
- [owner] the owner of the secret, this defaults to "root"
|
||||||
- [group] the group of the secret, this defaults to "root"
|
- [group] the group of the secret, this defaults to "root"
|
||||||
- [mode] the permissions of the secret, this defaults to "400"
|
- [mode] the permissions of the secret, this defaults to "400"
|
||||||
- [path] the path to output the secret to
|
- [path] the path to output the secret to
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkSecretWithPath :: (String -> String -> String -> String -> String) -> AttrSet
|
mkSecretWithPath :: (String -> String -> String -> String -> String) -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkSecret { file = "./my-secret.age"; path = "/etc/my-secret"; }
|
mkSecret { file = "./my-secret.age"; path = "/etc/my-secret"; }
|
||||||
=> {
|
=> {
|
||||||
file = "./my-secret.age";
|
file = "./my-secret.age";
|
||||||
path = "/etc/my-secret";
|
path = "/etc/my-secret";
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
mode = "400";
|
mode = "400";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSecretWithPath =
|
mkSecretWithPath = {
|
||||||
{
|
file,
|
||||||
file,
|
path,
|
||||||
path,
|
owner ? "root",
|
||||||
owner ? "root",
|
group ? "root",
|
||||||
group ? "root",
|
mode ? "400",
|
||||||
mode ? "400",
|
...
|
||||||
...
|
}:
|
||||||
}:
|
|
||||||
mkSecret {
|
mkSecret {
|
||||||
inherit
|
inherit
|
||||||
file
|
file
|
||||||
|
@ -93,7 +91,6 @@ let
|
||||||
// {
|
// {
|
||||||
inherit path;
|
inherit path;
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
inherit mkSecret mkSecretWithPath;
|
inherit mkSecret mkSecretWithPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,40 @@
|
||||||
{ 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
|
||||||
|
|
||||||
- [name]: The name of the service
|
- [name]: The name of the service
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkServiceOption :: String -> (Int -> String -> String -> AttrSet) -> AttrSet
|
mkServiceOption :: String -> (Int -> String -> String -> AttrSet) -> AttrSet
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkServiceOption =
|
mkServiceOption = name: {
|
||||||
name:
|
port ? 0,
|
||||||
{
|
host ? "127.0.0.1",
|
||||||
port ? 0,
|
domain ? "",
|
||||||
host ? "127.0.0.1",
|
extraConfig ? {},
|
||||||
domain ? "",
|
}:
|
||||||
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