Compare commits

...

4 commits

Author SHA1 Message Date
Geoffrey Frogeye 684d9b4d8b
frobar: More corner cases 2025-01-28 19:07:52 +01:00
Geoffrey Frogeye aceb44293f
syncthing: Support remote declarative sync 2025-01-27 00:15:28 +01:00
Geoffrey Frogeye 460ab8938f
frobar: Workaround missing workspace
Not sure what causes it, not interested in figuring out right now.
2025-01-26 17:18:40 +01:00
Geoffrey Frogeye 3335f90de4
Fix specialisation detection
I think
2025-01-26 17:18:28 +01:00
6 changed files with 96 additions and 13 deletions

View file

@ -213,6 +213,10 @@
system = "x86_64-linux";
modules = [ ./abavorana/standin.nix ];
};
nixosConfigurations.ludwig = lib.nixosSystem {
system = "x86_64-linux";
modules = [ ./ludwig/standin.nix ];
};
nixosConfigurations.sprinkles = lib.nixosSystem {
system = "aarch64-linux";
modules = [ ./sprinkles/standin.nix ];

View file

@ -370,7 +370,11 @@ class Bar(ComposableText):
while True:
line = await proc.stdout.readline()
command = line.decode().strip()
callback = self.actions[command]
callback = self.actions.get(command)
if callback is None:
# In some conditions on start it's empty
log.error(f"Unknown command: {command}")
return
callback()
async with self.taskGroup:

View file

@ -19,7 +19,7 @@ from frobar.common import (AlertingProvider, Button, MirrorProvider, Module,
MultiSectionsProvider, PeriodicProvider,
PeriodicStatefulProvider, Screen, Section,
SingleSectionProvider, StatefulSection,
StatefulSectionProvider, clip, humanSize, ramp)
StatefulSectionProvider, clip, humanSize, log, ramp)
gi.require_version("Playerctl", "2.0")
import gi.repository.Playerctl
@ -81,7 +81,12 @@ class I3WorkspacesProvider(MultiSectionsProvider):
section.setAction(Button.CLICK_LEFT, switch_to_workspace)
async def update() -> None:
workspace = self.workspaces[num]
workspace = self.workspaces.get(num)
if workspace is None:
log.warning(f"Can't find workspace {num}")
section.setText("X")
return
name = workspace.name
if workspace.urgent:
section.color = self.COLOR_URGENT

10
ludwig/standin.nix Normal file
View file

@ -0,0 +1,10 @@
{ ... }:
{
config = {
frogeye = {
name = "ludwig";
storageSize = "big";
syncthing.name = "Ludwig";
};
};
}

View file

@ -40,17 +40,31 @@ sudo nom build "$derivation^*" --no-link "$@"
info "Showing diff"
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
# Figure out specialisation
specialisationArgs=()
info "Figuring current specialisation"
systemLink=
currentSystem="$(readlink -f /run/current-system)"
while read -r specialisation
while read -r system
do
if [ "$(readlink -f "/nix/var/nix/profiles/system/specialisation/$specialisation")" = "$currentSystem" ]
if [ "$(readlink -f "$system")" = "$currentSystem" ]
then
systemLink="$system"
break
fi
done <<< "$(ls -d /nix/var/nix/profiles/system-*-link{,/specialisation/*})"
specialisationArgs=()
if [ -n "$systemLink" ]
then
specialisation=$(echo "$systemLink" | cut -d/ -f8)
if [ -n "$specialisation" ]
then
debug "Using specialisation: $specialisation"
specialisationArgs=("--specialisation" "$specialisation")
fi
done <<< "$(ls /nix/var/nix/profiles/system/specialisation)"
else
warning "Could not find link for $currentSystem, will switch to non-specialized system"
fi
# Apply
confirm="n"

View file

@ -24,7 +24,9 @@ let
);
allDevices = nixosDevices;
syncingDevices = builtins.filter (device: device.syncthing.id != null) allDevices;
peerDevices = builtins.filter (device: device.name != config.frogeye.name) syncingDevices;
peerDevices = builtins.filter (
device: device.syncthing.id != config.frogeye.syncthing.id
) syncingDevices;
# Can't use the module's folders enable option, as it still requests things somehow
allFolders = builtins.attrValues config.frogeye.folders;
@ -34,12 +36,58 @@ let
folder: device:
(lib.hasAttrByPath [ folder.name ] device.folders)
&& device.folders.${folder.name}.syncthing.enable;
folderDeviceEntry = folder: device: { deviceID = device.syncthing.id; };
enable = (builtins.length syncedFolders) > 0;
in
{
config = {
# Allow to export configuration to other systems
system.build.syncthingConfig = {
folders = lib.trivial.pipe syncedFolders [
(builtins.map (folder: {
name = folder.name;
value = folder;
}))
builtins.listToAttrs
(lib.attrsets.mapAttrs (
folderName: folder:
(lib.attrsets.filterAttrs (
k: v:
builtins.elem k [
"label"
"path"
"syncthing"
"user"
]
))
folder
))
];
devices = lib.trivial.pipe syncingDevices [
(builtins.map (device: {
name = device.name;
value = device;
}))
builtins.listToAttrs
(lib.attrsets.mapAttrs (
deviceName: device:
{
folders = lib.trivial.pipe device.folders [
(lib.attrsets.filterAttrs (folderName: folder: folder.syncthing.enable))
(lib.attrsets.mapAttrs (folderName: folder: { syncthing.enable = true; }))
];
}
//
(lib.attrsets.filterAttrs (
k: v:
builtins.elem k [
"syncthing"
]
))
device
))
];
};
services.${service} = {
inherit enable;
openDefaultPorts = true;
@ -63,8 +111,6 @@ in
value = {
label = "${capitalizeFirstLetter folder.user} ${folder.label}";
path = "${config.users.users.${folder.user}.home}/${folder.path}";
# Despite further in the code indicating this is possible, it is, actually not
# devices = builtins.map (folderDeviceEntry folder) (builtins.filter (folderShouldSyncWith folder) peerDevices);
devices = builtins.map (device: device.name) (
builtins.filter (folderShouldSyncWith folder) peerDevices
);