WIP: added wired-notify

feat: added autostart for systemd services
This commit is contained in:
Patrick Großmann 2023-10-12 02:30:03 +02:00
parent 288c6156ac
commit 4978892d2a
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
8 changed files with 228 additions and 6 deletions

View file

@ -49,6 +49,28 @@
"type": "github"
}
},
"alejandra": {
"inputs": {
"flakeCompat": "flakeCompat",
"nixpkgs": [
"wired-notify",
"nixpkgs"
]
},
"locked": {
"lastModified": 1652974241,
"narHash": "sha256-0AolxQtKj3Oek0WSbODDpPVO5Ih8PXHOA3qXEKPB4dQ=",
"owner": "kamadorueda",
"repo": "alejandra",
"rev": "0be1462419fc73270a5dc0f84f8092603890b029",
"type": "github"
},
"original": {
"owner": "kamadorueda",
"repo": "alejandra",
"type": "github"
}
},
"base16": {
"inputs": {
"fromYaml": "fromYaml"
@ -383,6 +405,22 @@
"type": "github"
}
},
"flakeCompat": {
"flake": false,
"locked": {
"lastModified": 1648199409,
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"fromYaml": {
"flake": false,
"locked": {
@ -930,7 +968,8 @@
"pre-commit-hooks": "pre-commit-hooks_2",
"stylix": "stylix",
"systems": "systems_5",
"templates": "templates"
"templates": "templates",
"wired-notify": "wired-notify"
}
},
"rust-overlay": {
@ -1090,6 +1129,30 @@
"repo": "treefmt-nix",
"type": "github"
}
},
"wired-notify": {
"inputs": {
"alejandra": "alejandra",
"nixpkgs": [
"nixpkgs"
],
"utils": [
"flake-utils"
]
},
"locked": {
"lastModified": 1683104317,
"narHash": "sha256-TfPrY+sqCKfRiBhO3oz0t/i9IGcTuGGQMKhkD+LpMys=",
"owner": "Toqozz",
"repo": "wired-notify",
"rev": "73bb26863ed3272e0d524424685bd53a70db25e4",
"type": "github"
},
"original": {
"owner": "Toqozz",
"repo": "wired-notify",
"type": "github"
}
}
},
"root": "root",

View file

@ -76,6 +76,11 @@
};
stylix.url = "github:danth/stylix";
wired-notify = {
url = "github:Toqozz/wired-notify";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
};
outputs = {
@ -87,6 +92,7 @@
pre-commit-hooks,
devshell,
nixpkgs-wayland,
wired-notify,
...
} @ inputs: let
inherit (nixpkgs) lib;
@ -130,6 +136,7 @@
# nixpkgs-wayland.overlay
devshell.overlays.default
agenix-rekey.overlays.default
wired-notify.overlays.default
];
inherit system;
config.allowUnfree = true;

View file

@ -12,6 +12,7 @@ lib.optionalAttrs (!minimal) {
with pkgs; [
# vampir überlebende braucht diese pkgs
libgdiplus
xdg-desktop-portal
cups
];
};

View file

@ -30,6 +30,8 @@ in {
streamdeck = {
Unit = {
Description = "start streamdeck-ui";
# For some reason this depends on X or wayland running
ConditionEnvironment = ["DISPLAY" "WAYLAND_DISPLAYS"];
};
Service = {
Type = "exec";

View file

@ -3,5 +3,10 @@
zsh-histdb-skim = super.callPackage ./zsh-histdb-skim.nix {};
zsh-histdb = super.callPackage ./zsh-histdb.nix {};
deploy = super.callPackage ./deploy.nix {};
formats =
super.formats
// {
ron = import ./ron.nix {inherit (super) lib pkgs;};
};
})
]

147
pkgs/ron.nix Normal file
View file

@ -0,0 +1,147 @@
{
lib,
pkgs,
...
}: {extensions ? []}: let
inherit
(lib)
boolToString
concatMapStrings
concatStringsSep
escape
length
mapAttrsToList
stringLength
types
;
toRon = indent: value:
with builtins;
if value == null
then "None"
else if isBool value
then boolToString value
else if isInt value || isFloat value
then toString value
else if isString value
then string value
else if isList value
then list indent value
else if isAttrs value
then attrs indent value
else abort "formats.ron: should never happen (value = ${value})";
specialType = indent: {
value,
_ronType,
...
} @ args:
if _ronType == "literal"
then value
else if _ronType == "raw_string"
then rawString value
else if _ronType == "char"
then char value
else if _ronType == "optional"
then some indent value
else if _ronType == "tuple"
then tuple indent value
else if _ronType == "struct"
then struct indent args
else abort "formats.ron: should never happen (_ronType = ${_ronType})";
escapedValues = escape ["\\" "\""];
string = value: ''"${escapedValues value}"'';
listContent = indent: values: concatStringsSep ",\n${indent}" (map (toRon indent) values);
list = indent: values:
if length values <= 1
then "[${listContent indent values}]"
else let newIndent = "${indent}\t"; in "[\n${newIndent}${listContent newIndent values}\n${indent}]";
attrs = indent: set:
if set ? _ronType
then specialType indent set
else let
newIndent = "${indent}\t";
toEntry = n: v: "${toRon newIndent n}: ${toRon newIndent v}";
entries = concatStringsSep ",\n${newIndent}" (mapAttrsToList toEntry set);
in "{\n${indent}${entries}\n${indent}}";
rawString = value: ''r#"${value}"#'';
char = value: "'${escapedValues value}'";
some = indent: value: "Some(${toRon indent value})";
tuple = indent: values: let
newIndent = "${indent}\t";
in "(\n${newIndent}${listContent newIndent values}\n${indent})";
struct = indent: {
name,
value,
...
}: let
newIndent = "${indent}\t";
toEntry = n: v: "${n}: ${toRon newIndent v}";
entriesStr =
if value ? _ronType
then specialType indent value
else let
entries = mapAttrsToList toEntry value;
entriesStrSpace = concatStringsSep ", " entries;
entriesStrNl = "\n${newIndent}${concatStringsSep ",\n${newIndent}" entries}\n${indent}";
in
if stringLength (indent + entriesStrSpace) < 120
then entriesStrSpace
else entriesStrNl;
in
if stringLength name == 0
then "(${entriesStr})"
else "${name} (${entriesStr})";
toFile = value: ''${concatMapStrings (x: "${x}\n") extensions}${toRon "" value}'';
in {
type = let
valueType =
types.nullOr (types.oneOf [
types.bool
types.int
types.float
types.str
(types.attrsOf valueType)
(types.listOf valueType)
])
// {
description = "RON value";
};
in
valueType;
lib = let
mkType = typeName: value: {
inherit value;
_ronType = typeName;
};
in rec {
mkLiteral = mkType "literal";
rawString = mkType "raw_string";
char = mkType "character";
some = mkType "optional";
enum = mkLiteral;
tuple = mkType "tuple";
struct = name: value: {
inherit value name;
_ronType = "struct";
};
types = {};
};
generate = name: value:
pkgs.runCommand name {
value = toFile value;
passAsFile = ["value"];
} ''
cp "$valuePath" "$out"
'';
}

View file

@ -15,6 +15,7 @@ in {
set-wallpaper = {
Unit = {
Description = "Set a random wallpaper every 3 minutes";
ConditionEnvironment = "DISPLAY";
};
Timer = {
OnActiveSec = "10 sec";

View file

@ -1,8 +1,4 @@
{
config,
pkgs,
...
}: {
{config, ...}: {
programs.streamdeck-ui = {
enable = true;
settings = {