style(nix): alejandra -> nixfmt-rfc-style

This commit is contained in:
seth 2024-08-06 23:26:02 -04:00 committed by Sefa Eyeoglu
parent bdb2ef7c4c
commit 068da95e36
4 changed files with 127 additions and 106 deletions

View file

@ -10,11 +10,13 @@
};
};
outputs = {
outputs =
{
self,
nixpkgs,
rust-overlay,
}: let
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
@ -23,7 +25,8 @@
];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
in {
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
@ -50,16 +53,18 @@
};
});
formatter = forAllSystems (pkgs: pkgs.alejandra);
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
nixosModules.default = import ./nix/module.nix self;
packages = forAllSystems ({
packages = forAllSystems (
{
lib,
pkgs,
system,
...
}: let
}:
let
packages' = self.packages.${system};
mkStatic = pkgs.callPackage ./nix/static.nix {
@ -67,14 +72,16 @@
rust-overlay = rust-overlay.packages.${system};
};
mkContainerFor = refraction:
mkContainerFor =
refraction:
pkgs.dockerTools.buildLayeredImage {
name = "refraction";
tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}";
config.Cmd = [ (lib.getExe refraction) ];
inherit (refraction) architecture;
};
in {
in
{
refraction = pkgs.callPackage ./nix/derivation.nix { inherit self; };
static-x86_64 = mkStatic { arch = "x86_64"; };
@ -83,7 +90,8 @@
container-aarch64 = mkContainerFor packages'.static-aarch64;
default = packages'.refraction;
});
}
);
overlays.default = _: prev: {
refraction = prev.callPackage ./nix/derivation.nix { inherit self; };

View file

@ -31,17 +31,22 @@ rustPlatform.buildRustPackage {
lockFile = ../Cargo.lock;
};
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreFoundation
Security
SystemConfiguration
]);
]
);
env = let
env =
let
toRustFlags = lib.mapAttrs' (
name:
lib.nameValuePair
"CARGO_PROFILE_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}"
lib.nameValuePair "CARGO_PROFILE_RELEASE_${
lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] name)
}"
);
in
lib.optionalAttrs lto (toRustFlags {
@ -62,6 +67,9 @@ rustPlatform.buildRustPackage {
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = licenses.gpl3Plus;
maintainers = with maintainers; [getchoo Scrumplex];
maintainers = with maintainers; [
getchoo
Scrumplex
];
};
}

View file

@ -1,14 +1,15 @@
self: {
self:
{
config,
lib,
pkgs,
...
}: let
}:
let
cfg = config.services.refraction;
defaultUser = "refraction";
inherit
(lib)
inherit (lib)
getExe
literalExpression
mdDoc
@ -19,7 +20,8 @@ self: {
optionals
types
;
in {
in
{
options.services.refraction = {
enable = mkEnableOption "refraction";
package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" { };
@ -85,9 +87,7 @@ in {
systemd.services."refraction" = {
enable = true;
wantedBy = [ "multi-user.target" ];
after =
["network.target"]
++ optionals (cfg.redisUrl == "local") ["redis-refraction.service"];
after = [ "network.target" ] ++ optionals (cfg.redisUrl == "local") [ "redis-refraction.service" ];
script = ''
${getExe cfg.package}
@ -95,9 +95,10 @@ in {
environment = {
BOT_REDIS_URL =
if cfg.redisUrl == "local"
then "unix:${config.services.redis.servers.refraction.unixSocket}"
else cfg.redisUrl;
if cfg.redisUrl == "local" then
"unix:${config.services.redis.servers.refraction.unixSocket}"
else
cfg.redisUrl;
};
serviceConfig = {
@ -141,9 +142,7 @@ in {
};
};
groups = mkIf (cfg.group == defaultUser) {
${defaultUser} = {};
};
groups = mkIf (cfg.group == defaultUser) { ${defaultUser} = { }; };
};
};
}

View file

@ -3,7 +3,9 @@
refraction,
rust-overlay,
pkgsCross,
}: {arch}: let
}:
{ arch }:
let
targets = with pkgsCross; {
x86_64 = musl64.pkgsStatic;
aarch64 = aarch64-multiplatform.pkgsStatic;
@ -15,9 +17,13 @@
targets = lib.mapAttrsToList (lib.const getRustcTarget) targets;
};
mkRustPlatformWith = pkgs:
mkRustPlatformWith =
pkgs:
pkgs.makeRustPlatform (
lib.genAttrs ["cargo" "rustc"] (lib.const toolchain)
lib.genAttrs [
"cargo"
"rustc"
] (lib.const toolchain)
);
rustPlatforms = lib.mapAttrs (lib.const mkRustPlatformWith) targets;
in