chore: cleanup + update nix flake

This commit is contained in:
seth 2024-01-27 23:49:35 -05:00
parent f4fa737124
commit 24c8406590
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
6 changed files with 91 additions and 109 deletions

View file

@ -14,7 +14,7 @@
...
}: let
crossPkgsFor =
rec {
{
x86_64-linux = {
x86_64 = pkgs.pkgsStatic;
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
@ -30,7 +30,7 @@
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
};
aarch64-darwin = x86_64-darwin;
aarch64-darwin = crossPkgsFor.x86_64-darwin;
}
.${system};
@ -56,17 +56,17 @@
optimizeSize = true;
};
newAttrs = lib.fix (finalAttrs: {
newAttrs = {
CARGO_BUILD_TARGET = target;
"CC_${target'}" = "${cc}/bin/${cc.targetPrefix}cc";
"CARGO_TARGET_${targetUpper}_RUSTFLAGS" = "-C target-feature=+crt-static";
"CARGO_TARGET_${targetUpper}_LINKER" = finalAttrs."CC_${target'}";
});
"CARGO_TARGET_${targetUpper}_LINKER" = newAttrs."CC_${target'}";
};
inherit (crossPkgsFor.${arch}.stdenv) cc;
in
lib.getExe (
refraction.overrideAttrs (_: newAttrs)
refraction.overrideAttrs (lib.const newAttrs)
);
containerFor = arch:

View file

@ -7,47 +7,35 @@
SystemConfiguration,
version,
optimizeSize ? false,
}: let
filter = path: type: let
path' = toString path;
base = baseNameOf path';
parent = baseNameOf (dirOf path');
}:
naersk.buildPackage {
pname = "refraction";
inherit version;
dirBlocklist = ["nix"];
matches = lib.any (suffix: lib.hasSuffix suffix base) [".rs"];
isCargo = base == "Cargo.lock" || base == "Cargo.toml";
isTag = parent == "tags";
isAllowedDir = !(builtins.elem base dirBlocklist);
in
(type == "directory" && isAllowedDir) || matches || isCargo || isTag;
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
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../src
../build.rs
../Cargo.lock
../Cargo.toml
../tags
];
};
RUSTFLAGS = lib.optionalString optimizeSize "-C codegen-units=1 -C strip=symbols -C opt-level=z";
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
CoreFoundation
Security
SystemConfiguration
];
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];
};
}
cargoBuildFlags = lib.optionals 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;
maintainers = with maintainers; [getchoo Scrumplex];
};
}

View file

@ -9,7 +9,9 @@
pre-commit.settings.hooks = {
actionlint.enable = true;
alejandra.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
statix.enable = true;
nil.enable = true;
prettier = {
enable = true;
@ -17,8 +19,8 @@
};
};
proc.groups.daemons.processes = {
redis.command = "${lib.getExe' pkgs.redis "redis-server"}";
procfiles.daemons.processes = {
redis = lib.getExe' pkgs.redis "redis-server";
};
devShells.default = pkgs.mkShell {
@ -29,7 +31,7 @@
packages = with pkgs; [
# general
actionlint
config.proc.groups.daemons.package
config.procfiles.daemons.package
# rust
cargo
@ -40,7 +42,9 @@
# nix
self'.formatter
deadnix
nil
statix
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

View file

@ -6,12 +6,12 @@
perSystem = {
pkgs,
system,
config,
self',
...
}: {
packages = {
refraction = pkgs.callPackage ./derivation.nix {
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
version = builtins.substring 0 7 self.rev or "dirty";
inherit
(pkgs.darwin.apple_sdk.frameworks)
@ -23,7 +23,7 @@
naersk = inputs.naersk.lib.${system};
};
default = config.packages.refraction;
default = self'.packages.refraction;
};
};
}