forked from catppuccin/nix
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(home-manager): cava,imv,mako,swaylock sans IFD
Closes catppuccin#340 Closes catppuccin#341 Closes catppuccin#375 Closes catppuccin#376 Closes catppuccin#373
- Loading branch information
Showing
10 changed files
with
105 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Simplifying assumptions: | ||
# | ||
# - ASCII | ||
# - line feed separated lines | ||
# - no multiline elements | ||
# - `=` surrounded by single space on both sides or not | ||
# - no subsections | ||
# - supported comment forms: | ||
# - line that starts with `#` | ||
# - values are either not quoted or single quoted | ||
# - blank lines are supported | ||
# - otherwise no extra whitespace | ||
lib: ini: | ||
let | ||
lines = lib.strings.splitString "\n" ini; | ||
parsedLines = map parseLine lines; | ||
|
||
parseLine = line: | ||
if builtins.stringLength line == 0 | ||
then { type = "empty"; } | ||
else if lib.hasPrefix "#" line | ||
then { type = "comment"; } | ||
else if lib.hasPrefix "[" line | ||
then { | ||
type = "section"; | ||
name = lib.pipe line [(lib.removePrefix "[") (lib.removeSuffix "]")]; | ||
} | ||
else let | ||
parts = lib.splitString "=" line; | ||
key = lib.removeSuffix " " (lib.elemAt parts 0); | ||
litVal = lib.removePrefix " " (lib.elemAt parts 1); | ||
in { | ||
type = "property"; | ||
inherit key; | ||
val = lib.pipe litVal [(lib.removePrefix "'") (lib.removeSuffix "'")]; | ||
} | ||
; | ||
|
||
endState = lib.foldl foldState { val = {}; currentSection = null; } parsedLines; | ||
|
||
foldState = acc: line: | ||
if line.type == "empty" | ||
then acc | ||
else if line.type == "comment" | ||
then acc | ||
else if line.type == "section" | ||
then acc // { ${line.name} = {}; currentSection = line.name; } | ||
else if line.type == "property" | ||
then lib.updateManyAttrsByPath | ||
[{ | ||
path = lib.flatten [ | ||
"val" | ||
(lib.optional (builtins.isString acc.currentSection) acc.currentSection) | ||
line.key | ||
]; | ||
update = _: line.val; | ||
}] | ||
acc | ||
else throw "no such type ${line.type}" | ||
; | ||
in | ||
endState.val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
lib: | ||
let | ||
subject = import ../modules/lib/from-ini.nix lib; | ||
|
||
input = '' | ||
k=v | ||
[a] | ||
k=v | ||
#comment | ||
kk='vv' | ||
[aa] | ||
k = v | ||
#comment | ||
kk = 'vv' | ||
''; | ||
|
||
expected = { | ||
k = "v"; | ||
a = { | ||
k = "v"; | ||
kk = "vv"; | ||
}; | ||
aa = { | ||
k = "v"; | ||
kk = "vv"; | ||
}; | ||
}; | ||
|
||
actual = subject input; | ||
in | ||
actual == expected |