Nix: use nixfmt as formatter

This commit is contained in:
wxlyyy
2025-12-20 03:20:39 +08:00
parent 2d81050db0
commit 8ce09bd234
5 changed files with 119 additions and 113 deletions
+58 -52
View File
@@ -5,65 +5,71 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
...
}: let
eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.linux;
pkgsFor = eachSystem (system: nixpkgs.legacyPackages.${system}.appendOverlays [self.overlays.default]);
in {
formatter = eachSystem (system: pkgsFor.${system}.alejandra);
outputs =
{
self,
nixpkgs,
...
}:
let
eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.linux;
pkgsFor = eachSystem (
system: nixpkgs.legacyPackages.${system}.appendOverlays [ self.overlays.default ]
);
in
{
formatter = eachSystem (system: pkgsFor.${system}.nixfmt);
packages = eachSystem (
system: {
packages = eachSystem (system: {
default = pkgsFor.${system}.noctalia-shell;
}
);
});
overlays = {
default = final: prev: {
noctalia-shell = final.callPackage ./nix/package.nix {
version = let
mkDate = longDate: final.lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
];
in
mkDate (self.lastModifiedDate or "19700101")
+ "_"
+ (self.shortRev or "dirty");
overlays = {
default = final: prev: {
noctalia-shell = final.callPackage ./nix/package.nix {
version =
let
mkDate =
longDate:
final.lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
];
in
mkDate (self.lastModifiedDate or "19700101") + "_" + (self.shortRev or "dirty");
};
};
};
};
devShells = eachSystem (
system: {
default = pkgsFor.${system}.callPackage ./nix/shell.nix {};
}
);
devShells = eachSystem (system: {
default = pkgsFor.${system}.callPackage ./nix/shell.nix { };
});
homeModules.default = {
pkgs,
lib,
...
}: {
imports = [./nix/home-module.nix];
programs.noctalia-shell.package =
lib.mkDefault
self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
homeModules.default =
{
pkgs,
lib,
...
}:
{
imports = [ ./nix/home-module.nix ];
programs.noctalia-shell.package =
lib.mkDefault
self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
nixosModules.default = {
pkgs,
lib,
...
}: {
imports = [./nix/nixos-module.nix];
services.noctalia-shell.package =
lib.mkDefault
self.packages.${pkgs.stdenv.hostPlatform.system}.default;
nixosModules.default =
{
pkgs,
lib,
...
}:
{
imports = [ ./nix/nixos-module.nix ];
services.noctalia-shell.package =
lib.mkDefault
self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
};
};
}
+4 -7
View File
@@ -107,15 +107,15 @@ in
{
templates = {
neovim = {
inputPath = "~/.config/matugen/templates/template.lua";
outputPath = "~/.config/nvim/generated.lua";
postHook = "pkill -SIGUSR1 nvim";
input_path = "~/.config/matugen/templates/template.lua";
output_path = "~/.config/nvim/generated.lua";
post_hook = "pkill -SIGUSR1 nvim";
};
};
}
'';
description = ''
Template definitions for Matugen.
Template definitions for Matugen, to be written to ~/.config/noctalia/user-templates.toml.
This option accepts:
- a Nix attrset (converted to TOML automatically)
@@ -135,7 +135,6 @@ in
config =
let
restart = "${pkgs.systemd}/bin/systemctl --user try-restart noctalia-shell.service 2>/dev/null || true";
useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false;
in
lib.mkIf cfg.enable {
@@ -169,11 +168,9 @@ in
xdg.configFile = {
"noctalia/settings.json" = lib.mkIf (cfg.settings != { }) {
onChange = lib.mkIf (!cfg.systemd.enable) restart;
source = generateJson "settings" cfg.settings;
};
"noctalia/colors.json" = lib.mkIf (cfg.colors != { }) {
onChange = lib.mkIf (!cfg.systemd.enable) restart;
source = generateJson "colors" cfg.colors;
};
"noctalia/user-templates.toml" = lib.mkIf (cfg.user-templates != { }) {
+10 -8
View File
@@ -2,9 +2,11 @@
config,
lib,
...
}: let
}:
let
cfg = config.services.noctalia-shell;
in {
in
{
options.services.noctalia-shell = {
enable = lib.mkEnableOption "Noctalia shell systemd service";
@@ -24,11 +26,11 @@ in {
config = lib.mkIf cfg.enable {
systemd.user.services.noctalia-shell = {
description = "Noctalia Shell - Wayland desktop shell";
documentation = ["https://docs.noctalia.dev/docs"];
after = [cfg.target];
partOf = [cfg.target];
wantedBy = [cfg.target];
restartTriggers = [cfg.package];
documentation = [ "https://docs.noctalia.dev/docs" ];
after = [ cfg.target ];
partOf = [ cfg.target ];
wantedBy = [ cfg.target ];
restartTriggers = [ cfg.package ];
environment = {
PATH = lib.mkForce null;
@@ -43,6 +45,6 @@ in {
};
};
environment.systemPackages = [cfg.package];
environment.systemPackages = [ cfg.package ];
};
}
+46 -45
View File
@@ -16,10 +16,12 @@
imagemagick,
wget,
gpu-screen-recorder, # optional
}: let
}:
let
src = lib.cleanSourceWith {
src = ../.;
filter = path: type:
filter =
path: type:
!(builtins.any (prefix: lib.path.hasPrefix (../. + prefix) (/. + path)) [
/.github
/.gitignore
@@ -36,52 +38,51 @@
]);
};
runtimeDeps =
[
brightnessctl
cava
cliphist
ddcutil
matugen
wlsunset
wl-clipboard
imagemagick
wget
]
++ lib.optionals (stdenvNoCC.hostPlatform.system == "x86_64-linux") [
gpu-screen-recorder
];
runtimeDeps = [
brightnessctl
cava
cliphist
ddcutil
matugen
wlsunset
wl-clipboard
imagemagick
wget
]
++ lib.optionals (stdenvNoCC.hostPlatform.system == "x86_64-linux") [
gpu-screen-recorder
];
in
stdenvNoCC.mkDerivation {
pname = "noctalia-shell";
inherit version src;
stdenvNoCC.mkDerivation {
pname = "noctalia-shell";
inherit version src;
nativeBuildInputs = [
qt6.wrapQtAppsHook
];
nativeBuildInputs = [
qt6.wrapQtAppsHook
];
buildInputs = [
qt6.qtbase
qt6.qtmultimedia
];
buildInputs = [
qt6.qtbase
qt6.qtmultimedia
];
installPhase = ''
mkdir -p $out/share/noctalia-shell $out/bin
cp -r . $out/share/noctalia-shell
ln -s ${quickshell}/bin/qs $out/bin/noctalia-shell
'';
installPhase = ''
mkdir -p $out/share/noctalia-shell $out/bin
cp -r . $out/share/noctalia-shell
ln -s ${quickshell}/bin/qs $out/bin/noctalia-shell
'';
preFixup = ''
qtWrapperArgs+=(
--prefix PATH : ${lib.makeBinPath runtimeDeps}
--add-flags "-p $out/share/noctalia-shell"
)
'';
preFixup = ''
qtWrapperArgs+=(
--prefix PATH : ${lib.makeBinPath runtimeDeps}
--add-flags "-p $out/share/noctalia-shell"
)
'';
meta = {
description = "A sleek and minimal desktop shell thoughtfully crafted for Wayland, built with Quickshell.";
homepage = "https://github.com/noctalia-dev/noctalia-shell";
license = lib.licenses.mit;
mainProgram = "noctalia-shell";
};
}
meta = {
description = "A sleek and minimal desktop shell thoughtfully crafted for Wayland, built with Quickshell.";
homepage = "https://github.com/noctalia-dev/noctalia-shell";
license = lib.licenses.mit;
mainProgram = "noctalia-shell";
};
}
+1 -1
View File
@@ -1 +1 @@
(import <nixpkgs> {}).callPackage ./nix/shell.nix {}
(import <nixpkgs> { }).callPackage ./nix/shell.nix { }