nix: fmt + remove pkgs.system ref

This commit is contained in:
atagen 2026-05-24 19:08:15 +10:00
parent 7797f60128
commit 031f47f560
2 changed files with 109 additions and 71 deletions

163
flake.nix
View file

@ -9,17 +9,28 @@
};
};
outputs = { self, nixpkgs, rust-overlay }:
outputs =
{
self,
nixpkgs,
rust-overlay,
}:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
pkgsFor =
system:
import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
perSystem = system:
perSystem =
system:
let
pkgs = pkgsFor system;
@ -48,76 +59,87 @@
in
{
# `nix develop` — full dev environment.
devShell = pkgs.mkShell ({
name = "headroom-dev";
devShell = pkgs.mkShell (
{
name = "headroom-dev";
nativeBuildInputs = nativeBuildTools ++ [
rustToolchain
pkgs.rust-analyzer
];
nativeBuildInputs = nativeBuildTools ++ [
rustToolchain
pkgs.rust-analyzer
];
buildInputs = nativeAudioBuildInputs ++ (with pkgs; [
socat # poke the IPC socket
jq # pretty-print JSON
pipewire # for pw-cli, pw-cat, etc.
wireplumber
]);
buildInputs =
nativeAudioBuildInputs
++ (with pkgs; [
socat # poke the IPC socket
jq # pretty-print JSON
pipewire # for pw-cli, pw-cat, etc.
wireplumber
]);
shellHook = ''
echo "headroom dev shell rustc $(rustc --version | cut -d' ' -f2)"
echo " cargo build / cargo test for iteration."
echo " nix build .#headroom for the packaged binary."
export RUST_BACKTRACE=1
export RUST_LOG=headroom=debug,info
'';
} // commonEnv);
shellHook = ''
echo "headroom dev shell rustc $(rustc --version | cut -d' ' -f2)"
echo " cargo build / cargo test for iteration."
echo " nix build .#headroom for the packaged binary."
export RUST_BACKTRACE=1
export RUST_LOG=headroom=debug,info
'';
}
// commonEnv
);
# `nix build` — the final packaged daemon + CLI.
headroom = rustPlatform.buildRustPackage ({
pname = "headroom";
# Pull from the workspace Cargo.toml — the per-crate
# manifests use `version.workspace = true` which evaluates
# to a table here, not a string.
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
headroom = rustPlatform.buildRustPackage (
{
pname = "headroom";
# Pull from the workspace Cargo.toml — the per-crate
# manifests use `version.workspace = true` which evaluates
# to a table here, not a string.
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
src = ./.;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
# allowBuiltinFetchGit = true;
};
cargoLock = {
lockFile = ./Cargo.lock;
# allowBuiltinFetchGit = true;
};
nativeBuildInputs = nativeBuildTools;
buildInputs = nativeAudioBuildInputs;
nativeBuildInputs = nativeBuildTools;
buildInputs = nativeAudioBuildInputs;
# We ship one binary from the workspace: `headroom` (cli + daemon).
cargoBuildFlags = [ "-p" "headroom-cli" ];
doCheck = true;
cargoTestFlags = [ "--workspace" ];
# We ship one binary from the workspace: `headroom` (cli + daemon).
cargoBuildFlags = [
"-p"
"headroom-cli"
];
doCheck = true;
cargoTestFlags = [ "--workspace" ];
# Install the systemd user unit (templated with @bindir@
# so the unit refers to the absolute path of the binary in
# this derivation, never to whatever happens to be on
# PATH) and ship the canonical profiles under
# share/headroom/profiles so users / modules can copy
# them into XDG_CONFIG_HOME on first run.
postInstall = ''
install -Dm644 contrib/systemd/headroom.service \
"$out/lib/systemd/user/headroom.service"
substituteInPlace "$out/lib/systemd/user/headroom.service" \
--replace-fail '@bindir@' "$out/bin"
# Install the systemd user unit (templated with @bindir@
# so the unit refers to the absolute path of the binary in
# this derivation, never to whatever happens to be on
# PATH) and ship the canonical profiles under
# share/headroom/profiles so users / modules can copy
# them into XDG_CONFIG_HOME on first run.
postInstall = ''
install -Dm644 contrib/systemd/headroom.service \
"$out/lib/systemd/user/headroom.service"
substituteInPlace "$out/lib/systemd/user/headroom.service" \
--replace-fail '@bindir@' "$out/bin"
mkdir -p "$out/share/headroom/profiles"
cp -r profiles/. "$out/share/headroom/profiles/"
'';
mkdir -p "$out/share/headroom/profiles"
cp -r profiles/. "$out/share/headroom/profiles/"
'';
meta = with pkgs.lib; {
description = "AGC + compressor + true-peak limiter daemon for PipeWire";
license = licenses.gpl3Plus;
platforms = platforms.linux;
mainProgram = "headroom";
};
} // commonEnv);
meta = with pkgs.lib; {
description = "Audio dynamic range daemon for PipeWire";
license = licenses.gpl3Plus;
platforms = platforms.linux;
mainProgram = "headroom";
};
}
// commonEnv
);
};
in
{
@ -125,11 +147,16 @@
default = (perSystem system).devShell;
});
packages = forAllSystems (system:
let ps = perSystem system; in rec {
packages = forAllSystems (
system:
let
ps = perSystem system;
in
rec {
default = headroom;
headroom = ps.headroom;
});
}
);
formatter = forAllSystems (system: (pkgsFor system).nixpkgs-fmt);