feat: make the first kind of working quickshell flake

This commit is contained in:
2026-04-17 17:53:43 -05:00
parent 08dad5425e
commit 457f310aa2
3 changed files with 99 additions and 79 deletions
+92 -78
View File
@@ -111,7 +111,18 @@
inherit src buildInputs nativeBuildInputs cargoArtifacts; inherit src buildInputs nativeBuildInputs cargoArtifacts;
}; };
default = lib; qmlModule = pkgs.runCommand "rshell-qml-dir" {} ''
mkdir -p $out
cat << EOF > $out/qmldir
${''
module one.krantz.rshell
plugin rshell ${lib}/lib
''}
EOF
'';
default = qmlModule;
}; };
checks = { checks = {
@@ -145,98 +156,100 @@
# Copy your main files # Copy your main files
cp -r ${lib.sources.sourceFilesBySuffices ./qml [".qml"]}/* $out/ cp -r ${lib.sources.sourceFilesBySuffices ./qml [".qml"]}/* $out/
# Copy the rust plugin
cp -Lr ${self.packages.${pkgs.stdenv.hostPlatform.system}.qmlModule} $out/one.krantz.rshell
# Copy the nix generate qml files # Copy the nix generate qml files
cp -Lr ${nixQmlDir} $out/nix cp -Lr ${nixQmlDir} $out/nix
''; '';
nixQmlDir = let nixQmlDir = pkgs.runCommand "nix-qml-dir" {} ''
cpText = drv: "ln -s ${drv} $out/${drv.name}"; mkdir -p $out/
in
pkgs.runCommand "nix-qml-dir" {} ''
mkdir -p $out
${cpText ( cat << EOF > $out/CodeDirStat.qml
pkgs.writeText "CodeDirStat.qml" ${
/* /*
qml qml
*/ */
'' ''
pragma Singleton pragma Singleton
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import QtQuick import QtQuick
Singleton { Singleton {
id: root id: root
property int files property int files
property int commits property int commits
property int stashes property int stashes
Process { Process {
id: codedirstatproc id: codedirstatproc
command: [${"\"" command: [${"\""
+ (with pkgs; + (with pkgs;
writeScript "quickshell-codedirstat" writeScript "quickshell-codedirstat"
/* /*
nu nu
*/ */
'' ''
#!${nushell}/bin/nu --plugins [${nushellPlugins.gstat}/bin/nu_plugin_gstat] #!${nushell}/bin/nu --plugins [${nushellPlugins.gstat}/bin/nu_plugin_gstat]
ls ~/code/**/*/.git/.. ls ~/code/**/*/.git/..
| each {|r| gstat $r.name} | each {|r| gstat $r.name}
| each {|r| { files: (($r.wt_untracked + $r.wt_modified) > 0), commits: ($r.ahead > 0), stashes: ($r.stashes > 0) }} | each {|r| { files: (($r.wt_untracked + $r.wt_modified) > 0), commits: ($r.ahead > 0), stashes: ($r.stashes > 0) }}
| into int files commits stashes | into int files commits stashes
| math sum | math sum
| $"($in.files):($in.commits):($in.stashes)" | $"($in.files):($in.commits):($in.stashes)"
'') '')
+ "\""}] + "\""}]
running: true running: true
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
const res = this.text.split(":") const res = this.text.split(":")
root.files = res[0] root.files = res[0]
root.commits = res[1] root.commits = res[1]
root.stashes = res[2] root.stashes = res[2]
}
} }
} }
Timer {
interval: 30000
running: true
repeat: true
onTriggered: codedirstatproc.running = true
}
} }
''
)}
${cpText ( Timer {
pkgs.writeText "Theme.qml" interval: 30000
/* running: true
qml repeat: true
*/ onTriggered: codedirstatproc.running = true
''
pragma Singleton
import Quickshell
import QtQuick
Singleton {
${builtins.concatStringsSep "\n" (
lib.attrsets.mapAttrsToList (
name: color: "readonly property color ${name}: \"#${color}\""
)
cfg.colors
)}
} }
'' }
)} ''
''; }
EOF
cat << EOF > $out/Theme.qml
${
/*
qml
*/
''
pragma Singleton
import Quickshell
import QtQuick
Singleton {
${builtins.concatStringsSep "\n" (
lib.attrsets.mapAttrsToList (
name: color: "readonly property color ${name}: \"#${color}\""
)
cfg.colors
)}
}
''
}
EOF
'';
in { in {
options.krantz.rshell = { options.krantz.rshell = {
enable = lib.mkEnableOption "rshell, quickshell based graphical shell"; enable = lib.mkEnableOption "rshell, quickshell based graphical shell";
@@ -266,8 +279,9 @@
systemd.enable = true; systemd.enable = true;
configs = { configs = {
"shell.qml" = "${qmlDir}/Bar.qml"; "shell.qml" = "${qmlDir}/shell.qml";
"nix" = nixQmlDir; "nix" = nixQmlDir;
"one.krantz.rshell" = self.packages.${pkgs.stdenv.hostPlatform.system}.qmlModule;
}; };
}; };
}; };
-1
View File
@@ -1,5 +1,4 @@
import "nix" import "nix"
import "one.krantz.rshell" import "one.krantz.rshell"
import Quickshell import Quickshell
+7
View File
@@ -0,0 +1,7 @@
import Quickshell
ShellRoot {
settings.watchFiles: true
Bar {}
}