This commit is contained in:
2025-12-07 16:41:17 +00:00
parent 438e239fff
commit b8ce965de5
61 changed files with 2373 additions and 2384 deletions

View File

@@ -1 +1 @@
indentation = "Tabs"
indentation = "TwoSpaces"

View File

@@ -2,7 +2,7 @@
description = "Configuration for my macOS laptops and NixOS server";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
sops-nix = {
url = "github:Mic92/sops-nix";
@@ -53,8 +53,7 @@
"aarch64-darwin"
];
flake.darwinConfigurations =
inputs.nixpkgs.lib.genAttrs darwinHosts (
flake.darwinConfigurations = inputs.nixpkgs.lib.genAttrs darwinHosts (
hostname:
inputs.darwin.lib.darwinSystem {
system = "aarch64-darwin";
@@ -82,8 +81,7 @@
}
);
flake.nixosConfigurations =
inputs.nixpkgs.lib.genAttrs nixosHosts (
flake.nixosConfigurations = inputs.nixpkgs.lib.genAttrs nixosHosts (
hostname:
inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
@@ -122,8 +120,7 @@
"rollback"
];
in {
devShells.default =
pkgs.mkShell {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
bashInteractive
git
@@ -133,8 +130,7 @@
shellHook = ''export EDITOR=nvim'';
};
apps =
builtins.listToAttrs (
apps = builtins.listToAttrs (
map (n: {
name = n;
value = mkApp n;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ with pkgs; [
ast-grep
bun
delta
# devenv
devenv
dig
docker
docker-compose
@@ -22,6 +22,7 @@ with pkgs; [
git
gnumake
gnupg
hledger
htop
hyperfine
jq

View File

@@ -0,0 +1,43 @@
{
pkgs,
inputs,
...
}:
with pkgs; [
inputs.beads.packages.${pkgs.system}.default
inputs.nix-ai-tools.packages.${pkgs.system}.amp
(callPackage ./bin/open-project.nix {})
age
alejandra
ast-grep
bun
delta
devenv
dig
docker
docker-compose
hledger
fastfetch
fd
gh
git
gnumake
gnupg
htop
hyperfine
jq
killall
lsof
nurl
openssh
postgresql_17
sd
sops
sqlite
tokei
tree
tree-sitter
unzip
vivid
zip
]

View File

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