init: working version
This commit is contained in:
commit
7d8d7dacae
109 changed files with 15066 additions and 0 deletions
60
services/NixOS.qml
Normal file
60
services/NixOS.qml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string nixVersion: nixVersionProc.nixVersion
|
||||
readonly property list<Generation> generations: nixosGenerationsProc.generations
|
||||
readonly property Generation currentGen: generations.find(g => g.current) ?? null
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
interval: 60000
|
||||
onTriggered: {
|
||||
nixVersionProc.running = true;
|
||||
nixosGenerationsProc.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nixVersionProc
|
||||
command: ["nix", "--version"]
|
||||
property string nixVersion: ""
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: nixVersionProc.nixVersion = this.text.split(" ")[2].trim()
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nixosGenerationsProc
|
||||
command: ["nixos-rebuild", "list-generations", "--json"]
|
||||
property list<Generation> generations: []
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const json = JSON.parse(this.text);
|
||||
nixosGenerationsProc.generations = json.map(o => genComp.createObject(root, { ipcObject: o }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component Generation: QtObject {
|
||||
required property var ipcObject
|
||||
readonly property int id: ipcObject.generation
|
||||
readonly property date date: ipcObject.date
|
||||
readonly property string nixosVersion: ipcObject.nixosVersion
|
||||
readonly property string kernelVersion: ipcObject.kernelVersion
|
||||
readonly property string revision: ipcObject.configurationRevision
|
||||
readonly property bool current: ipcObject.current
|
||||
}
|
||||
|
||||
Component {
|
||||
id: genComp
|
||||
Generation {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue