This commit is contained in:
Qyriad 2026-01-21 15:23:04 +01:00
commit d8ac4e157d
5 changed files with 178 additions and 0 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
[*.rs]
indent_style = tab
indent_size = 4
[*.nix]
indent_style = tab
indent_size = 2

20
default.nix Normal file
View file

@ -0,0 +1,20 @@
{
pkgs ? import <nixpkgs> { },
qpkgs ? let
src = fetchTree (builtins.parseFlakeRef "github:Qyriad/nur-packages");
in import src { inherit pkgs; },
}: let
inherit (qpkgs) lib;
PKGNAME = qpkgs.callPackage ./package.nix { };
byStdenv = lib.mapAttrs (stdenvName: stdenv: let
withStdenv = PKGNAME.override { inherit stdenv; };
PKGNAME' = withStdenv.overrideAttrs (prev: {
pname = "${prev.pname}-${stdenvName}";
});
in PKGNAME') qpkgs.validStdenvs;
in PKGNAME.overrideAttrs (prev: lib.recursiveUpdate prev {
passthru = { inherit byStdenv; };
})

45
flake.nix Normal file
View file

@ -0,0 +1,45 @@
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
qyriad-nur = {
url = "github:Qyriad/nur-packages";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
qyriad-nur,
}: flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
qpkgs = import qyriad-nur { inherit pkgs; };
inherit (qpkgs) lib;
PKGNAME = import ./default.nix { inherit pkgs qpkgs; };
extraVersions = lib.mapAttrs' (stdenvName: value: {
name = "${stdenvName}-PKGNAME";
inherit value;
}) PKGNAME.byStdenv;
devShell = import ./shell.nix { inherit pkgs qpkgs PKGNAME; };
extraDevShells = lib.mapAttrs' (stdenvName: value: {
name = "${stdenvName}-PKGNAME";
inherit value;
}) PKGNAME.byStdenv;
in {
packages = extraVersions // {
default = PKGNAME;
inherit PKGNAME;
};
devShells = extraDevShells // {
default = devShell;
};
});
}

81
package.nix Normal file
View file

@ -0,0 +1,81 @@
{
lib,
stdenv,
rustHooks,
rustPlatform,
cargo,
clippy,
versionCheckHook,
}: let
cargoToml = lib.importTOML ./Cargo.toml;
cargoPackage = cargoToml.package;
in stdenv.mkDerivation (self: {
pname = cargoPackage.name;
version = cargoPackage.version;
strictDeps = true;
__structuredAttrs = true;
doCheck = true;
doInstallCheck = true;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./src
];
};
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
versionCheckProgramArg = "--version";
nativeBuildInputs = rustHooks.asList ++ [
cargo
];
nativeInstallCheckInputs = [
versionCheckHook
];
passthru.mkDevShell = {
mkShell,
}: let
mkShell' = mkShell.override { stdenv = stdenv; };
in mkShell' {
name = "${self.pname}-devshell-${self.version}";
inputsFrom = [ self.finalPackage ];
};
passthru.tests.clippy = self.finalPackage.overrideAttrs (prev: {
pname = "${self.pname}-clippy";
nativeCheckInputs = prev.nativeCheckInputs or [ ] ++ [
clippy
];
dontConfigure = true;
dontBuild = true;
doCheck = true;
dontFixup = true;
dontInstallCheck = true;
checkPhase = lib.trim ''
echo "cargoClippyPhase()"
cargo clippy --all-targets --profile "$cargoCheckType" -- --deny warnings
'';
installPhase = lib.trim ''
touch "$out"
'';
});
meta = {
mainProgram = "PKGNAME";
};
})

17
shell.nix Normal file
View file

@ -0,0 +1,17 @@
{
pkgs ? import <nixpkgs> { },
qpkgs ? let
src = fetchTarball "https://github.com/Qyriad/nur-packages/archive/main.tar.gz";
in import src { inherit pkgs; },
PKGNAME ? import ./default.nix { inherit pkgs qpkgs; },
}: let
inherit (pkgs) lib;
mkDevShell = PKGNAME: qpkgs.callPackage PKGNAME.mkDevShell { };
devShell = mkDevShell PKGNAME;
byStdenv = lib.mapAttrs (lib.const mkDevShell) PKGNAME.byStdenv;
in devShell.overrideAttrs (prev: lib.recursiveUpdate prev {
passthru = { inherit byStdenv; };
})