Signed-off-by: Christoph Schmatzler <christoph@schmatzler.com>
This commit is contained in:
2025-11-02 11:36:27 +00:00
parent fe843e19bf
commit 298bbfae53
57 changed files with 2309 additions and 2248 deletions

1
alejandra.toml Normal file
View File

@@ -0,0 +1 @@
indentation = "Tabs"

View File

@@ -43,7 +43,8 @@
"aarch64-darwin" "aarch64-darwin"
]; ];
flake.darwinConfigurations = inputs.nixpkgs.lib.genAttrs darwinHosts ( flake.darwinConfigurations =
inputs.nixpkgs.lib.genAttrs darwinHosts (
hostname: hostname:
inputs.darwin.lib.darwinSystem { inputs.darwin.lib.darwinSystem {
system = "aarch64-darwin"; system = "aarch64-darwin";
@@ -73,7 +74,8 @@
} }
); );
flake.nixosConfigurations = inputs.nixpkgs.lib.genAttrs nixosHosts ( flake.nixosConfigurations =
inputs.nixpkgs.lib.genAttrs nixosHosts (
hostname: hostname:
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
@@ -114,7 +116,8 @@
"rollback" "rollback"
]; ];
in { in {
devShells.default = pkgs.mkShell { devShells.default =
pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
bashInteractive bashInteractive
git git
@@ -124,7 +127,8 @@
shellHook = ''export EDITOR=nvim''; shellHook = ''export EDITOR=nvim'';
}; };
apps = builtins.listToAttrs ( apps =
builtins.listToAttrs (
map (n: { map (n: {
name = n; name = n;
value = mkApp n; value = mkApp n;

View File

@@ -1,5 +1,6 @@
{pkgs}: let {pkgs}: let
wallpaper = pkgs.fetchurl { wallpaper =
pkgs.fetchurl {
url = "https://misc-assets.raycast.com/wallpapers/bright-rain.png"; url = "https://misc-assets.raycast.com/wallpapers/bright-rain.png";
sha256 = "sha256-wQT4I2X3gS6QFsEb7MdRsn4oX7FNkflukXPGMFbJZ10="; sha256 = "sha256-wQT4I2X3gS6QFsEb7MdRsn4oX7FNkflukXPGMFbJZ10=";
}; };

View File

@@ -10,23 +10,27 @@ with lib; let
in { in {
options = { options = {
local.dock = { local.dock = {
enable = mkOption { enable =
mkOption {
description = "Enable dock"; description = "Enable dock";
default = stdenv.isDarwin; default = stdenv.isDarwin;
example = false; example = false;
}; };
entries = mkOption { entries =
mkOption {
description = "Entries on the Dock"; description = "Entries on the Dock";
type = with types; type = with types;
listOf (submodule { listOf (submodule {
options = { options = {
path = lib.mkOption {type = str;}; path = lib.mkOption {type = str;};
section = lib.mkOption { section =
lib.mkOption {
type = str; type = str;
default = "apps"; default = "apps";
}; };
options = lib.mkOption { options =
lib.mkOption {
type = str; type = str;
default = ""; default = "";
}; };
@@ -35,14 +39,16 @@ in {
readOnly = true; readOnly = true;
}; };
username = mkOption { username =
mkOption {
description = "Username to apply the dock settings to"; description = "Username to apply the dock settings to";
type = types.str; type = types.str;
}; };
}; };
}; };
config = mkIf cfg.enable ( config =
mkIf cfg.enable (
let let
normalize = path: normalize = path:
if hasSuffix ".app" path if hasSuffix ".app" path

View File

@@ -12,7 +12,8 @@ in {
home = { home = {
packages = pkgs.callPackage ../packages.nix {}; packages = pkgs.callPackage ../packages.nix {};
activation = { activation = {
"setWallpaper" = lib.hm.dag.entryAfter ["revealHomeLibraryDirectory"] '' "setWallpaper" =
lib.hm.dag.entryAfter ["revealHomeLibraryDirectory"] ''
echo "[+] Setting wallpaper" echo "[+] Setting wallpaper"
${setWallpaperScript}/bin/set-wallpaper-script ${setWallpaperScript}/bin/set-wallpaper-script
''; '';

View File

@@ -19,7 +19,8 @@ with lib; let
devices = mapAttrsToList (_: device: device // {deviceID = device.id;}) cfg.settings.devices; devices = mapAttrsToList (_: device: device // {deviceID = device.id;}) cfg.settings.devices;
anyAutoAccept = builtins.any (dev: dev.autoAcceptFolders) devices; anyAutoAccept = builtins.any (dev: dev.autoAcceptFolders) devices;
folders = mapAttrsToList (_: folder: folders =
mapAttrsToList (_: folder:
folder folder
// { // {
devices = let devices = let
@@ -37,7 +38,8 @@ with lib; let
}) (filterAttrs (_: folder: folder.enable) cfg.settings.folders); }) (filterAttrs (_: folder: folder.enable) cfg.settings.folders);
jq = "${pkgs.jq}/bin/jq"; jq = "${pkgs.jq}/bin/jq";
updateConfig = pkgs.writers.writeBash "merge-syncthing-config" ( updateConfig =
pkgs.writers.writeBash "merge-syncthing-config" (
'' ''
set -efu set -efu
umask 0077 umask 0077
@@ -76,7 +78,8 @@ with lib; let
lib.pipe s.conf [ lib.pipe s.conf [
(map ( (map (
new_cfg: let new_cfg: let
jsonPreSecretsFile = pkgs.writeTextFile { jsonPreSecretsFile =
pkgs.writeTextFile {
name = "${conf_type}-${new_cfg.id}-conf-pre-secrets.json"; name = "${conf_type}-${new_cfg.id}-conf-pre-secrets.json";
text = builtins.toJSON new_cfg; text = builtins.toJSON new_cfg;
}; };
@@ -85,7 +88,8 @@ with lib; let
"devs" = "${jq} ."; "devs" = "${jq} .";
"dirs" = let "dirs" = let
folder = new_cfg; folder = new_cfg;
devicesWithSecrets = lib.pipe folder.devices [ devicesWithSecrets =
lib.pipe folder.devices [
(lib.filter (device: (builtins.isAttrs device) && device ? encryptionPasswordFile)) (lib.filter (device: (builtins.isAttrs device) && device ? encryptionPasswordFile))
(map (device: { (map (device: {
deviceId = device.deviceId; deviceId = device.deviceId;
@@ -151,56 +155,68 @@ in {
services.syncthing = { services.syncthing = {
enable = mkEnableOption "Syncthing, a self-hosted open-source alternative to Dropbox and Bittorrent Sync"; enable = mkEnableOption "Syncthing, a self-hosted open-source alternative to Dropbox and Bittorrent Sync";
cert = mkOption { cert =
mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Path to the cert.pem file, which will be copied into Syncthing's configDir."; description = "Path to the cert.pem file, which will be copied into Syncthing's configDir.";
}; };
key = mkOption { key =
mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Path to the key.pem file, which will be copied into Syncthing's configDir."; description = "Path to the key.pem file, which will be copied into Syncthing's configDir.";
}; };
overrideDevices = mkOption { overrideDevices =
mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "Whether to delete the devices which are not configured via the devices option."; description = "Whether to delete the devices which are not configured via the devices option.";
}; };
overrideFolders = mkOption { overrideFolders =
mkOption {
type = types.bool; type = types.bool;
default = !anyAutoAccept; default = !anyAutoAccept;
description = "Whether to delete the folders which are not configured via the folders option."; description = "Whether to delete the folders which are not configured via the folders option.";
}; };
settings = mkOption { settings =
type = types.submodule { mkOption {
type =
types.submodule {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
options = mkOption { options =
mkOption {
default = {}; default = {};
description = "The options element contains all other global configuration options"; description = "The options element contains all other global configuration options";
type = types.submodule { type =
types.submodule {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
localAnnounceEnabled = mkOption { localAnnounceEnabled =
mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
description = "Whether to send announcements to the local LAN."; description = "Whether to send announcements to the local LAN.";
}; };
globalAnnounceEnabled = mkOption { globalAnnounceEnabled =
mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
description = "Whether to send announcements to the global discovery servers."; description = "Whether to send announcements to the global discovery servers.";
}; };
relaysEnabled = mkOption { relaysEnabled =
mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
description = "When true, relays will be connected to and potentially used for device to device connections."; description = "When true, relays will be connected to and potentially used for device to device connections.";
}; };
urAccepted = mkOption { urAccepted =
mkOption {
type = types.nullOr types.int; type = types.nullOr types.int;
default = null; default = null;
description = "Whether the user has accepted to submit anonymous usage data."; description = "Whether the user has accepted to submit anonymous usage data.";
@@ -209,22 +225,27 @@ in {
}; };
}; };
devices = mkOption { devices =
mkOption {
default = {}; default = {};
description = "Peers/devices which Syncthing should communicate with."; description = "Peers/devices which Syncthing should communicate with.";
type = types.attrsOf (types.submodule ({name, ...}: { type =
types.attrsOf (types.submodule ({name, ...}: {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
name = mkOption { name =
mkOption {
type = types.str; type = types.str;
default = name; default = name;
description = "The name of the device."; description = "The name of the device.";
}; };
id = mkOption { id =
mkOption {
type = types.str; type = types.str;
description = "The device ID."; description = "The device ID.";
}; };
autoAcceptFolders = mkOption { autoAcceptFolders =
mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Automatically create or share folders that this device advertises at the default path."; description = "Automatically create or share folders that this device advertises at the default path.";
@@ -233,48 +254,59 @@ in {
})); }));
}; };
folders = mkOption { folders =
mkOption {
default = {}; default = {};
description = "Folders which should be shared by Syncthing."; description = "Folders which should be shared by Syncthing.";
type = types.attrsOf (types.submodule ({name, ...}: { type =
types.attrsOf (types.submodule ({name, ...}: {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
enable = mkOption { enable =
mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "Whether to share this folder."; description = "Whether to share this folder.";
}; };
path = mkOption { path =
mkOption {
type = types.str; type = types.str;
default = name; default = name;
description = "The path to the folder which should be shared."; description = "The path to the folder which should be shared.";
}; };
id = mkOption { id =
mkOption {
type = types.str; type = types.str;
default = name; default = name;
description = "The ID of the folder. Must be the same on all devices."; description = "The ID of the folder. Must be the same on all devices.";
}; };
label = mkOption { label =
mkOption {
type = types.str; type = types.str;
default = name; default = name;
description = "The label of the folder."; description = "The label of the folder.";
}; };
type = mkOption { type =
mkOption {
type = types.enum ["sendreceive" "sendonly" "receiveonly" "receiveencrypted"]; type = types.enum ["sendreceive" "sendonly" "receiveonly" "receiveencrypted"];
default = "sendreceive"; default = "sendreceive";
description = "Controls how the folder is handled by Syncthing."; description = "Controls how the folder is handled by Syncthing.";
}; };
devices = mkOption { devices =
type = types.listOf (types.oneOf [ mkOption {
type =
types.listOf (types.oneOf [
types.str types.str
(types.submodule { (types.submodule {
freeformType = settingsFormat.type; freeformType = settingsFormat.type;
options = { options = {
name = mkOption { name =
mkOption {
type = types.str; type = types.str;
description = "The name of a device defined in the devices option."; description = "The name of a device defined in the devices option.";
}; };
encryptionPasswordFile = mkOption { encryptionPasswordFile =
mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;
description = "Path to encryption password file."; description = "Path to encryption password file.";
@@ -294,37 +326,43 @@ in {
description = "Extra configuration options for Syncthing."; description = "Extra configuration options for Syncthing.";
}; };
guiAddress = mkOption { guiAddress =
mkOption {
type = types.str; type = types.str;
default = "127.0.0.1:8384"; default = "127.0.0.1:8384";
description = "The address to serve the web interface at."; description = "The address to serve the web interface at.";
}; };
user = mkOption { user =
mkOption {
type = types.str; type = types.str;
default = "syncthing"; default = "syncthing";
description = "The user to run Syncthing as."; description = "The user to run Syncthing as.";
}; };
group = mkOption { group =
mkOption {
type = types.str; type = types.str;
default = "syncthing"; default = "syncthing";
description = "The group to run Syncthing under."; description = "The group to run Syncthing under.";
}; };
dataDir = mkOption { dataDir =
mkOption {
type = types.path; type = types.path;
default = "/var/lib/syncthing"; default = "/var/lib/syncthing";
description = "The path where synchronised directories will exist."; description = "The path where synchronised directories will exist.";
}; };
configDir = mkOption { configDir =
mkOption {
type = types.path; type = types.path;
default = cfg.dataDir + "/.config/syncthing"; default = cfg.dataDir + "/.config/syncthing";
description = "The path where the settings and keys will exist."; description = "The path where the settings and keys will exist.";
}; };
openDefaultPorts = mkOption { openDefaultPorts =
mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Whether to open the default ports in the firewall (not applicable on Darwin)."; description = "Whether to open the default ports in the firewall (not applicable on Darwin).";
@@ -334,7 +372,8 @@ in {
}; };
}; };
config = mkIf cfg.enable { config =
mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = !(cfg.overrideFolders && anyAutoAccept); assertion = !(cfg.overrideFolders && anyAutoAccept);
@@ -369,7 +408,8 @@ in {
}; };
}; };
launchd.user.agents.syncthing-init = mkIf (cleanedConfig != {}) { launchd.user.agents.syncthing-init =
mkIf (cleanedConfig != {}) {
serviceConfig = { serviceConfig = {
ProgramArguments = ["${updateConfig}"]; ProgramArguments = ["${updateConfig}"];
RunAtLoad = true; RunAtLoad = true;
@@ -380,7 +420,8 @@ in {
}; };
}; };
system.activationScripts.syncthing = mkIf (cfg.cert != null || cfg.key != null) '' system.activationScripts.syncthing =
mkIf (cfg.cert != null || cfg.key != null) ''
echo "Setting up Syncthing certificates..." echo "Setting up Syncthing certificates..."
mkdir -p ${cfg.configDir} mkdir -p ${cfg.configDir}
${optionalString (cfg.cert != null) '' ${optionalString (cfg.cert != null) ''

View File

@@ -7,7 +7,8 @@
}; };
themes = { themes = {
"Catppuccin Latte" = { "Catppuccin Latte" = {
src = pkgs.fetchFromGitHub { src =
pkgs.fetchFromGitHub {
owner = "catppuccin"; owner = "catppuccin";
repo = "bat"; repo = "bat";
rev = "6810349b28055dce54076712fc05fc68da4b8ec0"; rev = "6810349b28055dce54076712fc05fc68da4b8ec0";

View File

@@ -4,7 +4,8 @@
clipboard = "osc52"; clipboard = "osc52";
}; };
opts = { opts = {
expandtab = true; expandtab = false;
tabstop = 2;
ignorecase = true; ignorecase = true;
mouse = ""; mouse = "";
relativenumber = true; relativenumber = true;

View File

@@ -127,7 +127,11 @@
extra = {}; extra = {};
git = {}; git = {};
icons = {}; icons = {};
indentscope = {}; indentscope = {
settings = {
symbol = "|";
};
};
jump = {}; jump = {};
jump2d = { jump2d = {
settings = { settings = {

View File

@@ -1,6 +1,7 @@
{inputs}: let {inputs}: let
dir = builtins.readDir ./.; dir = builtins.readDir ./.;
overlayNames = builtins.sort builtins.lessThan (builtins.filter ( overlayNames =
builtins.sort builtins.lessThan (builtins.filter (
name: name:
name name
!= "default.nix" != "default.nix"