{ description = "A quickshell based graphical shell named rshell"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; project-templates = { url = "git+ssh://gitea@git.krantz.one/reed/project-templates"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-parts.follows = "flake-parts"; }; }; outputs = { self, flake-parts, project-templates, ... } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { imports = [ project-templates.flakeModules.rust ]; systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin"]; perSystem = { lib, config, pkgs, self', ... }: { krantz.rust = let craneLib = config.krantz.rust.craneLib; # pkgs.qt6.env already includes pkgs.qt6.qtbase # And using `with` to prevent a lot of typing. qtEnv = with pkgs.qt6; env "qt-rshell-${qtbase.version}" [ qtdeclarative qttools ]; in { enable = true; srcFiltered = let unfilteredRoot = ./.; in lib.fileset.toSource { root = unfilteredRoot; fileset = lib.fileset.unions [ # Default files from crane (Rust and cargo files) (craneLib.fileset.commonCargoSources unfilteredRoot) (lib.fileset.maybeMissing ./qt-plugin.version) ]; }; runtimeDeps = [ qtEnv ]; devDeps = with pkgs; [ rust-analyzer quickshell ]; devShell.extraAttrs = { shellHook = /* bash */ '' export QML2_IMPORT_PATH=$(git rev-parse --show-toplevel)/result/:$QML2_IMPORT_PATH ''; }; package.name = "lib"; }; # Your custom packages # Accessible through 'nix build', 'nix shell', 'nix run', etc packages = { qmlModule = pkgs.runCommand "rshell-qml-dir" {} '' mkdir -p $out cat << EOF > $out/qmldir ${'' module one.krantz.rshell plugin rshell ${self'.packages.lib}/lib ''} EOF ''; default = self'.packages.qmlModule; }; }; flake = { homeManagerModules.default = { lib, config, pkgs, ... }: let cfg = config.krantz.rshell; colors = config.lib.stylix.colors; mkColorOption = default: description: lib.mkOption { inherit default; description = "The ${description} color."; type = lib.types.str; }; qmlDir = pkgs.runCommand "quickshell-config" {} '' mkdir -p $out # 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 = pkgs.runCommand "nix-qml-dir" {} '' mkdir -p $out/ cat << EOF > $out/CodeDirStat.qml ${ /* qml */ '' pragma Singleton import Quickshell import Quickshell.Io import QtQuick 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] 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(":") root.files = res[0] root.commits = res[1] root.stashes = res[2] } } } 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"; colors = { bg = mkColorOption colors.base00-hex "default background"; fg = mkColorOption colors.base07-hex "default content"; text = mkColorOption colors.base07-hex "default text"; accent = mkColorOption colors.base0D-hex "accent"; shaded = mkColorOption colors.base03-hex "darker icon or text"; containerBg = mkColorOption colors.base01-hex "container background"; divider = mkColorOption colors.base02-hex "divider"; inactive = mkColorOption colors.base03-hex "inactive element"; bad = mkColorOption colors.base08-hex "bad state / low amount of resource"; ok = mkColorOption colors.base0A-hex "ok state / medium amount of resource"; good = mkColorOption colors.base0B-hex "good state / high amount of resource"; }; }; config = lib.mkIf cfg.enable { programs.quickshell = { enable = true; systemd.enable = true; configs = { "shell.qml" = "${qmlDir}/shell.qml"; "nix" = nixQmlDir; "one.krantz.rshell" = self.packages.${pkgs.stdenv.hostPlatform.system}.qmlModule; }; }; }; }; }; }; }