niri-tag/flake.nix
2025-06-19 17:35:38 +10:00

77 lines
2.0 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default-linux";
naersk.url = "github:nix-community/naersk";
niri-flake.url = "github:sodiboo/niri-flake";
};
outputs =
inputs:
with inputs;
let
getPackages = builtins.attrValues;
forAllSystems =
function: nixpkgs.lib.genAttrs (import systems) (system: function nixpkgs.legacyPackages.${system});
deps = forAllSystems (pkgs: {
naersk = pkgs.callPackages naersk { };
build = getPackages {
inherit (pkgs)
cargo
rustc
pkg-config
systemdLibs
;
};
dev = getPackages {
inherit (pkgs)
rust-analyzer
rustfmt
clippy
;
};
});
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with deps.${pkgs.system}; build ++ dev;
RUST_SRC_DIR = "${pkgs.rustPlatform.rustLibSrc}";
RUST_LOG = "debug";
shellHook = ''
cp --no-preserve=mode,ownership -R ${niri-flake.inputs.niri-unstable} niri/
'';
};
});
packages = forAllSystems (pkgs: {
unstable = deps.${pkgs.system}.naersk.buildPackage {
src = ./.;
preConfigure = ''
cp -R ${niri-flake.inputs.niri-unstable} niri/
'';
meta.mainProgram = "niri-tag";
};
stable = deps.${pkgs.system}.naersk.buildPackage {
src = ./.;
preBuild = ''
cp -R ${niri-flake.inputs.niri-stable} niri/
'';
meta.mainProgram = "niri-tag";
};
default = self.packages.${pkgs.system}.unstable;
});
nixosModules.default = self.nixosModules.niri-tag;
nixosModules.niri-tag =
{ pkgs, ... }:
{
imports = [
./module.nix
];
services.niri-tag.package = self.packages.${pkgs.system}.unstable;
};
};
}