nova-shell/flake.nix

149 lines
4.9 KiB
Nix

{
description = "nova-shell - minimal Quickshell bar for niri";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
quickshell = {
url = "git+https://git.outfoxxed.me/outfoxxed/quickshell";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
quickshell,
treefmt-nix,
...
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
];
treefmt-config = {
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
programs.qmlformat.enable = true;
programs.rustfmt.enable = true;
programs.taplo.enable = true;
programs.keep-sorted.enable = true;
};
forAllSystems =
fn:
nixpkgs.lib.genAttrs systems (
system:
fn rec {
pkgs = nixpkgs.legacyPackages.${system};
treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config;
}
);
in
{
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper);
packages = forAllSystems (
{ pkgs, ... }:
let
qs = quickshell.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
withX11 = false;
withI3 = false;
};
nova-stats = pkgs.callPackage ./nix/stats-daemon.nix { };
nova-shaders = pkgs.callPackage ./nix/shaders.nix { };
in
rec {
inherit nova-stats nova-shaders;
nova-shell = pkgs.callPackage ./nix/package.nix {
quickshell = qs;
inherit nova-stats nova-shaders;
};
nova-shell-cli = pkgs.runCommand "nova-shell-cli" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${qs}/bin/quickshell $out/bin/nova-shell \
--add-flags "-p ${nova-shell}/share/nova-shell/shell.qml"
'';
docs = pkgs.callPackage ./nix/docs.nix { inherit self; };
default = nova-shell;
}
);
devShells = forAllSystems (
{ pkgs, ... }:
{
default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rust-analyzer
clippy
rustfmt
libnotify
qt6.qtdeclarative
];
};
}
);
checks = forAllSystems (
{ pkgs, treefmt-eval }:
{
formatting = treefmt-eval.config.build.check self;
build = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
nova-stats = self.packages.${pkgs.stdenv.hostPlatform.system}.nova-stats;
docs = self.packages.${pkgs.stdenv.hostPlatform.system}.docs;
qmllint =
pkgs.runCommand "nova-shell-qmllint"
{
nativeBuildInputs = [ pkgs.qt6.qtdeclarative ];
src = self;
}
''
cd $src
export QML_IMPORT_PATH="${pkgs.qt6.qtdeclarative}/lib/qt-6/qml:${
quickshell.packages.${pkgs.stdenv.hostPlatform.system}.default
}/lib/qt-6/qml"
qmllint -E \
-I shell/modules -I shell/services -I shell/applets -I shell/lock \
shell/shell.qml shell/modules/*.qml shell/services/*.qml \
shell/applets/*.qml shell/lock/*.qml \
> $TMPDIR/output.txt 2>&1 || true
# Extract unique warning messages (file:message, without line numbers)
grep -E "^Warning:" $TMPDIR/output.txt \
| sed 's/^Warning: //' \
| sed 's/\([^:]*\):[0-9]*:[0-9]*: /\1: /' \
| sort -u > $TMPDIR/current.txt
# Diff against known baseline - new warnings = failure
if ! diff -u test/qmllint-baseline.txt $TMPDIR/current.txt > $TMPDIR/diff.txt 2>&1; then
new=$(grep '^+[^+]' $TMPDIR/diff.txt || true)
if [ -n "$new" ]; then
echo "qmllint found new warnings not in baseline:"
echo "$new"
exit 1
fi
fi
cp $TMPDIR/output.txt $out
'';
nova-stats-clippy = (pkgs.callPackage ./nix/stats-daemon.nix { }).overrideAttrs (old: {
pname = "nova-stats-clippy";
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.clippy ];
buildPhase = "cargo clippy --all-targets -- -D warnings";
installPhase = "touch $out";
doCheck = false;
});
}
);
homeModules.default = import ./nix/hm-module.nix self;
homeManagerModules.default = self.homeModules.default;
};
}