diff --git a/flake.nix b/flake.nix index 8d74a0d..4cfaf47 100644 --- a/flake.nix +++ b/flake.nix @@ -111,7 +111,18 @@ 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 = { @@ -145,98 +156,100 @@ # Copy your main files 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 cp -Lr ${nixQmlDir} $out/nix ''; - nixQmlDir = let - cpText = drv: "ln -s ${drv} $out/${drv.name}"; - in - pkgs.runCommand "nix-qml-dir" {} '' - mkdir -p $out + nixQmlDir = pkgs.runCommand "nix-qml-dir" {} '' + mkdir -p $out/ - ${cpText ( - pkgs.writeText "CodeDirStat.qml" - /* - qml - */ - '' - pragma Singleton + cat << EOF > $out/CodeDirStat.qml + ${ + /* + qml + */ + '' + pragma Singleton - import Quickshell - import Quickshell.Io - import QtQuick + import Quickshell + import Quickshell.Io + import QtQuick - Singleton { - id: root - property int files - property int commits - property int stashes + Singleton { + id: root + property int files + property int commits + property int stashes - Process { - id: codedirstatproc - command: [${"\"" - + (with pkgs; - writeScript "quickshell-codedirstat" - /* - nu - */ - '' - #!${nushell}/bin/nu --plugins [${nushellPlugins.gstat}/bin/nu_plugin_gstat] + Process { + id: codedirstatproc + command: [${"\"" + + (with pkgs; + writeScript "quickshell-codedirstat" + /* + nu + */ + '' + #!${nushell}/bin/nu --plugins [${nushellPlugins.gstat}/bin/nu_plugin_gstat] - ls ~/code/**/*/.git/.. - | each {|r| gstat $r.name} - | each {|r| { files: (($r.wt_untracked + $r.wt_modified) > 0), commits: ($r.ahead > 0), stashes: ($r.stashes > 0) }} - | into int files commits stashes - | math sum - | $"($in.files):($in.commits):($in.stashes)" - '') - + "\""}] - running: true + ls ~/code/**/*/.git/.. + | each {|r| gstat $r.name} + | each {|r| { files: (($r.wt_untracked + $r.wt_modified) > 0), commits: ($r.ahead > 0), stashes: ($r.stashes > 0) }} + | into int files commits stashes + | math sum + | $"($in.files):($in.commits):($in.stashes)" + '') + + "\""}] + running: true - stdout: StdioCollector { - onStreamFinished: { - const res = this.text.split(":") + stdout: StdioCollector { + onStreamFinished: { + const res = this.text.split(":") - root.files = res[0] - root.commits = res[1] - root.stashes = res[2] - } + root.files = res[0] + root.commits = res[1] + root.stashes = res[2] } } - - Timer { - interval: 30000 - running: true - repeat: true - onTriggered: codedirstatproc.running = true - } } - '' - )} - ${cpText ( - pkgs.writeText "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 - )} + Timer { + interval: 30000 + running: true + repeat: true + onTriggered: codedirstatproc.running = true } - '' - )} - ''; + } + '' + } + 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 { options.krantz.rshell = { enable = lib.mkEnableOption "rshell, quickshell based graphical shell"; @@ -266,8 +279,9 @@ systemd.enable = true; configs = { - "shell.qml" = "${qmlDir}/Bar.qml"; + "shell.qml" = "${qmlDir}/shell.qml"; "nix" = nixQmlDir; + "one.krantz.rshell" = self.packages.${pkgs.stdenv.hostPlatform.system}.qmlModule; }; }; }; diff --git a/qml/Bar.qml b/qml/Bar.qml index 06b405e..d355115 100644 --- a/qml/Bar.qml +++ b/qml/Bar.qml @@ -1,5 +1,4 @@ import "nix" - import "one.krantz.rshell" import Quickshell diff --git a/qml/shell.qml b/qml/shell.qml new file mode 100644 index 0000000..ace0050 --- /dev/null +++ b/qml/shell.qml @@ -0,0 +1,7 @@ +import Quickshell + +ShellRoot { + settings.watchFiles: true + + Bar {} +}