chore: initial commit
Initial commit
This commit is contained in:
@@ -0,0 +1,277 @@
|
||||
{
|
||||
description = "A quickshell based graphical shell named rshell";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
crane.url = "github:ipetkov/crane";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
flake-parts,
|
||||
treefmt-nix,
|
||||
crane,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
imports = [
|
||||
treefmt-nix.flakeModule
|
||||
];
|
||||
|
||||
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
|
||||
|
||||
perSystem = {
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
craneLib = crane.mkLib pkgs;
|
||||
src = 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)
|
||||
];
|
||||
};
|
||||
manifest = (lib.importTOML "${src}/Cargo.toml").package;
|
||||
|
||||
# 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
|
||||
];
|
||||
|
||||
# runtime dependencies
|
||||
buildInputs = with pkgs; [
|
||||
qtEnv
|
||||
];
|
||||
|
||||
# build dependencies
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# pkg-config
|
||||
# rustPlatform.bindgenHook
|
||||
];
|
||||
|
||||
# Build *just* the cargo dependencies, so we can reuse
|
||||
# all of that work (e.g. via cachix) when running in CI
|
||||
cargoArtifacts = craneLib.buildDepsOnly {
|
||||
inherit src buildInputs nativeBuildInputs;
|
||||
};
|
||||
in rec {
|
||||
# Dev Shell that lets you enter an environment with all the necessary utilites
|
||||
# Available through 'nix develop'
|
||||
# Also can be activated automatically if direnv is installed on the system with 'direnv allow'
|
||||
devShells.default = craneLib.devShell {
|
||||
inherit checks;
|
||||
|
||||
# extra tooling dependencies
|
||||
packages = with pkgs; [
|
||||
rust-analyzer
|
||||
quickshell
|
||||
];
|
||||
|
||||
shellHook =
|
||||
/*
|
||||
bash
|
||||
*/
|
||||
''
|
||||
export QML2_IMPORT_PATH=$(git rev-parse --show-toplevel)/result/:$QML2_IMPORT_PATH
|
||||
'';
|
||||
|
||||
inputsFrom = [packages.default];
|
||||
};
|
||||
|
||||
# Formatter for nix files, available through 'nix fmt'
|
||||
treefmt = {
|
||||
programs.alejandra.enable = true;
|
||||
programs.rustfmt = {
|
||||
enable = true;
|
||||
edition = manifest.edition;
|
||||
};
|
||||
};
|
||||
|
||||
# Your custom packages
|
||||
# Accessible through 'nix build', 'nix shell', 'nix run', etc
|
||||
packages = rec {
|
||||
lib = craneLib.buildPackage {
|
||||
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
||||
};
|
||||
|
||||
default = lib;
|
||||
};
|
||||
|
||||
checks = {
|
||||
clippy = craneLib.cargoClippy {
|
||||
inherit src buildInputs nativeBuildInputs cargoArtifacts;
|
||||
cargoClippyExtraArgs = "-- --deny warnings";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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 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
|
||||
|
||||
${cpText (
|
||||
pkgs.writeText "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
|
||||
}
|
||||
}
|
||||
''
|
||||
)}
|
||||
|
||||
${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
|
||||
)}
|
||||
}
|
||||
''
|
||||
)}
|
||||
'';
|
||||
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}/Bar.qml";
|
||||
"nix" = nixQmlDir;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user