1
0
mirror of https://github.com/kmein/niveum synced 2026-03-22 04:41:07 +01:00

feat: use pkgs.formats for everything

This commit is contained in:
2021-04-07 09:37:57 +02:00
parent 0f0b5658be
commit 4adf8fea0a
9 changed files with 83 additions and 94 deletions

View File

@@ -1,10 +1,18 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
let {
environment.variables.TERMINAL = "alacritty";
environment.systemPackages = [
pkgs.alacritty
];
home-manager.users.me.xdg.configFile =
let
inherit (import <niveum/lib>) colours; inherit (import <niveum/lib>) colours;
colourNames = colourNames = [ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ];
[ "black" "red" "green" "yellow" "blue" "magenta" "cyan" "white" ];
colourPairs = lib.getAttrs colourNames colours; colourPairs = lib.getAttrs colourNames colours;
alacrittyConfig = { in {
"alacritty/alacritty.yml".source = (pkgs.formats.yaml {}).generate "alacritty.yml" {
background_opacity = 0.9; background_opacity = 0.9;
colors = { colors = {
primary = { inherit (colours) background foreground; }; primary = { inherit (colours) background foreground; };
@@ -33,14 +41,5 @@ let
} }
]; ];
}; };
in {
environment.variables.TERMINAL = "alacritty";
environment.systemPackages = [
pkgs.alacritty
];
home-manager.users.me.xdg.configFile = {
"alacritty/alacritty.yml".text = builtins.toJSON alacrittyConfig;
}; };
} }

View File

@@ -36,7 +36,6 @@ in {
(self: super: { (self: super: {
scripts = import <niveum/packages/scripts> { pkgs = super; lib = super.lib; }; scripts = import <niveum/packages/scripts> { pkgs = super; lib = super.lib; };
}) })
(import <niveum/overlays/toml.nix>)
(import <stockholm/krebs/5pkgs/haskell>) (import <stockholm/krebs/5pkgs/haskell>)
(import <stockholm/submodules/nix-writers/pkgs>) (import <stockholm/submodules/nix-writers/pkgs>)
(import <stockholm/krebs/5pkgs/override>) (import <stockholm/krebs/5pkgs/override>)

View File

@@ -143,7 +143,7 @@ in {
}; };
}; };
statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${ statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${
pkgs.writeTOML (import <niveum/lib/i3status-rust.nix> { (pkgs.formats.toml {}).generate "i3status-rust.toml" (import <niveum/lib/i3status-rust.nix> {
inherit (config.niveum) batteryName wirelessInterface; inherit (config.niveum) batteryName wirelessInterface;
inherit colours; inherit colours;
inherit pkgs; inherit pkgs;

View File

@@ -1,7 +1,21 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let {
bridgeBotToken = lib.strings.fileContents <system-secrets/telegram/kmein.token>; nixpkgs.overlays = [
config = { (self: super: {
matterbridge = (import (super.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "e45d91ee65db293a172ec506759d1248e40c35f5";
sha256 = "03cjs5xcx09lw0djyrx2kfakw7gkg4iqmy9w25azai62im39l30k";
}) {}).matterbridge;
})
];
services.matterbridge = {
enable = true;
configPath =
let bridgeBotToken = lib.strings.fileContents <system-secrets/telegram/kmein.token>;
in toString ((pkgs.formats.toml {}).generate "config.toml" {
general = { general = {
RemoteNickFormat = "[{NICK}] "; RemoteNickFormat = "[{NICK}] ";
Charset = "utf-8"; Charset = "utf-8";
@@ -37,23 +51,6 @@ let
]; ];
} }
]; ];
}; });
in
{
nixpkgs.overlays = [
(import <niveum/overlays/toml.nix>)
(self: super: {
matterbridge = (import (super.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "e45d91ee65db293a172ec506759d1248e40c35f5";
sha256 = "03cjs5xcx09lw0djyrx2kfakw7gkg4iqmy9w25azai62im39l30k";
}) {}).matterbridge;
})
];
services.matterbridge = {
enable = true;
configPath = toString (pkgs.writeTOML config);
}; };
} }

View File

@@ -47,7 +47,7 @@ in
systemd.services.mpd-fm-stations = systemd.services.mpd-fm-stations =
let let
stations = lib.lists.imap0 (id: {desc ? "", logo ? "https://picsum.photos/seed/${builtins.hashString "md5" stream}/300", stream, station}: { inherit id desc logo stream station; }) streams; stations = lib.lists.imap0 (id: {desc ? "", logo ? "https://picsum.photos/seed/${builtins.hashString "md5" stream}/300", stream, station}: { inherit id desc logo stream station; }) streams;
stationsJson = pkgs.writeText "stations.json" (builtins.toJSON stations); stationsJson = (pkgs.formats.json {}).generate "stations.json" stations;
in { in {
wantedBy = [ "mpd-fm.service" ]; wantedBy = [ "mpd-fm.service" ];
startAt = "hourly"; startAt = "hourly";

View File

@@ -10,8 +10,9 @@
''; '';
# :def unpl \x -> return $ ":!${pkgs.haskellPackages.pointful}/bin/pointful \"" ++ x ++ "\"" # :def unpl \x -> return $ ":!${pkgs.haskellPackages.pointful}/bin/pointful \"" ++ x ++ "\""
# :def pl \x -> return $ ":!${pkgs.haskellPackages.pointfree}/bin/pointfree -v \"" ++ x ++ "\"" # :def pl \x -> return $ ":!${pkgs.haskellPackages.pointfree}/bin/pointfree -v \"" ++ x ++ "\""
".stack/config.yaml".text = let inherit (import <niveum/lib>) kieran; ".stack/config.yaml".source =
in builtins.toJSON { let inherit (import <niveum/lib>) kieran;
in (pkgs.formats.yaml {}).generate "config.yaml" {
templates.params = { templates.params = {
author-name = kieran.name; author-name = kieran.name;
author-email = kieran.email; author-email = kieran.email;

View File

@@ -66,7 +66,7 @@ let
} }
]; ];
configFile = pkgs.writeText "urlwatch.yaml" (builtins.toJSON { configFile = (pkgs.formats.yaml {}).generate "urlwatch.yaml" {
display = { display = {
error = true; error = true;
new = true; new = true;
@@ -100,7 +100,7 @@ let
# chat_id = [ "18980945" ]; # chat_id = [ "18980945" ];
# }; # };
}; };
}); };
urlwatch = pkgs.urlwatch.overrideAttrs (attrs: { urlwatch = pkgs.urlwatch.overrideAttrs (attrs: {
patches = [ <niveum/packages/urlwatch-insecure.patch> ]; patches = [ <niveum/packages/urlwatch-insecure.patch> ];
}); });

View File

@@ -44,7 +44,7 @@ in {
stationsFile = mkOption { stationsFile = mkOption {
type = types.path; type = types.path;
default = pkgs.writeText "stations.json" (builtins.toJSON cfg.stations); default = (pkgs.formats.json {}).generate "stations.json" cfg.stations;
}; };
package = mkOption { package = mkOption {

View File

@@ -1,7 +0,0 @@
(self: super: {
writeTOML = object: super.runCommand "writeTOML" {} ''
echo '${builtins.toJSON object}' | ${super.remarshal}/bin/json2toml > $out
'';
toTOML = object: builtins.readFile (self.writeTOML object);
writeJSON = path: object: super.writeText path (builtins.toJSON object);
})