feat: add nix package, module, and container

Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
seth 2023-12-03 04:14:20 -05:00
parent 45403e9d9b
commit e928eb67df
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
7 changed files with 497 additions and 67 deletions

51
nix/derivation.nix Normal file
View file

@ -0,0 +1,51 @@
{
lib,
stdenv,
naersk,
CoreFoundation,
Security,
SystemConfiguration,
version,
optimizeSize ? false,
}: let
filter = path: type: let
path' = toString path;
base = baseNameOf path';
dirBlocklist = ["nix"];
matches = lib.any (suffix: lib.hasSuffix suffix base) [".rs"];
isCargo = base == "Cargo.lock" || base == "Cargo.toml";
isAllowedDir = !(builtins.elem base dirBlocklist);
in
(type == "directory" && isAllowedDir) || matches || isCargo;
filterSource = src:
lib.cleanSourceWith {
src = lib.cleanSource src;
inherit filter;
};
in
naersk.buildPackage {
pname = "refraction";
inherit version;
src = filterSource ../.;
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
CoreFoundation
Security
SystemConfiguration
];
RUSTFLAGS = lib.optionalString optimizeSize "-C codegen-units=1 -C strip=symbols -C opt-level=z";
meta = with lib; {
mainProgram = "refraction";
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = licenses.gpl3Plus;
platforms = with platforms; linux ++ darwin;
maintainers = with maintainers; [getchoo Scrumplex];
};
}