up
This commit is contained in:
14
flake.nix
14
flake.nix
@@ -36,6 +36,13 @@
|
||||
user = constants.user;
|
||||
darwinHosts = builtins.attrNames (builtins.readDir ./hosts/darwin);
|
||||
nixosHosts = builtins.attrNames (builtins.readDir ./hosts/nixos);
|
||||
|
||||
loadDarwinOverlay = overlayPath: let
|
||||
overlay = import overlayPath;
|
||||
module = (overlay null { darwin = {}; }).darwinSyncthingModule;
|
||||
in {
|
||||
inherit overlay module;
|
||||
};
|
||||
in {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
@@ -45,8 +52,7 @@
|
||||
flake.darwinConfigurations = inputs.nixpkgs.lib.genAttrs darwinHosts (
|
||||
hostname:
|
||||
let
|
||||
syncthingOverlay = import ./overlays/syncthing-darwin.nix;
|
||||
syncthingModule = (syncthingOverlay null { darwin = {}; }).darwinSyncthingModule;
|
||||
syncthing = loadDarwinOverlay ./overlays/syncthing-darwin.nix;
|
||||
in
|
||||
inputs.darwin.lib.darwinSystem {
|
||||
system = "aarch64-darwin";
|
||||
@@ -58,10 +64,10 @@
|
||||
modules = [
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
inputs.nix-homebrew.darwinModules.nix-homebrew
|
||||
syncthingModule
|
||||
syncthing.module
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [ syncthingOverlay ];
|
||||
nixpkgs.overlays = [ syncthing.overlay ];
|
||||
|
||||
nix-homebrew = {
|
||||
inherit user;
|
||||
|
||||
@@ -5,16 +5,22 @@
|
||||
...
|
||||
}: let
|
||||
isDarwin = pkgs.stdenv.isDarwin;
|
||||
isLinux = pkgs.stdenv.isLinux;
|
||||
homeDir = if isDarwin then "/Users/${user}" else "/home/${user}";
|
||||
|
||||
platformConfig = if isDarwin then {
|
||||
homeDir = "/Users/${user}";
|
||||
group = "staff";
|
||||
} else {
|
||||
homeDir = "/home/${user}";
|
||||
group = "users";
|
||||
};
|
||||
in {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
openDefaultPorts = isLinux;
|
||||
dataDir = "${homeDir}/.local/share/syncthing";
|
||||
configDir = "${homeDir}/.config/syncthing";
|
||||
openDefaultPorts = !isDarwin;
|
||||
dataDir = "${platformConfig.homeDir}/.local/share/syncthing";
|
||||
configDir = "${platformConfig.homeDir}/.config/syncthing";
|
||||
user = "${user}";
|
||||
group = if isDarwin then "staff" else "users";
|
||||
group = platformConfig.group;
|
||||
guiAddress = "0.0.0.0:8384";
|
||||
overrideFolders = true;
|
||||
overrideDevices = true;
|
||||
@@ -26,7 +32,7 @@ in {
|
||||
};
|
||||
folders = {
|
||||
"Projects" = {
|
||||
path = "${homeDir}/Projects";
|
||||
path = "${platformConfig.homeDir}/Projects";
|
||||
devices = ["tahani" "jason"];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
final: prev: {
|
||||
darwinSyncthingModule = { config, lib, pkgs, ... }:
|
||||
darwinModules = prev.darwinModules or {} // {
|
||||
syncthing = { config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.syncthing;
|
||||
@@ -383,4 +384,7 @@ final: prev: {
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
darwinSyncthingModule = final.darwinModules.syncthing;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user