style(nix): alejandra -> nixfmt-rfc-style
This commit is contained in:
parent
bdb2ef7c4c
commit
068da95e36
4 changed files with 127 additions and 106 deletions
146
flake.nix
146
flake.nix
|
@ -10,83 +10,91 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
}: let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
}:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
|
||||
in {
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
redis
|
||||
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
redis
|
||||
|
||||
# linters & formatters
|
||||
actionlint
|
||||
nodePackages.prettier
|
||||
# linters & formatters
|
||||
actionlint
|
||||
nodePackages.prettier
|
||||
|
||||
# rust tools
|
||||
clippy
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
# rust tools
|
||||
clippy
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
|
||||
# nix tools
|
||||
self.formatter.${system}
|
||||
deadnix
|
||||
nil
|
||||
statix
|
||||
];
|
||||
# nix tools
|
||||
self.formatter.${system}
|
||||
deadnix
|
||||
nil
|
||||
statix
|
||||
];
|
||||
|
||||
inputsFrom = [self.packages.${pkgs.system}.refraction];
|
||||
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
|
||||
};
|
||||
});
|
||||
|
||||
formatter = forAllSystems (pkgs: pkgs.alejandra);
|
||||
|
||||
nixosModules.default = import ./nix/module.nix self;
|
||||
|
||||
packages = forAllSystems ({
|
||||
lib,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
packages' = self.packages.${system};
|
||||
|
||||
mkStatic = pkgs.callPackage ./nix/static.nix {
|
||||
inherit (self.packages.${pkgs.system}) refraction;
|
||||
rust-overlay = rust-overlay.packages.${system};
|
||||
};
|
||||
|
||||
mkContainerFor = refraction:
|
||||
pkgs.dockerTools.buildLayeredImage {
|
||||
name = "refraction";
|
||||
tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}";
|
||||
config.Cmd = [(lib.getExe refraction)];
|
||||
inherit (refraction) architecture;
|
||||
inputsFrom = [ self.packages.${pkgs.system}.refraction ];
|
||||
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
|
||||
};
|
||||
in {
|
||||
refraction = pkgs.callPackage ./nix/derivation.nix {inherit self;};
|
||||
});
|
||||
|
||||
static-x86_64 = mkStatic {arch = "x86_64";};
|
||||
static-aarch64 = mkStatic {arch = "aarch64";};
|
||||
container-x86_64 = mkContainerFor packages'.static-x86_64;
|
||||
container-aarch64 = mkContainerFor packages'.static-aarch64;
|
||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
||||
|
||||
default = packages'.refraction;
|
||||
});
|
||||
nixosModules.default = import ./nix/module.nix self;
|
||||
|
||||
overlays.default = _: prev: {
|
||||
refraction = prev.callPackage ./nix/derivation.nix {inherit self;};
|
||||
packages = forAllSystems (
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
packages' = self.packages.${system};
|
||||
|
||||
mkStatic = pkgs.callPackage ./nix/static.nix {
|
||||
inherit (self.packages.${pkgs.system}) refraction;
|
||||
rust-overlay = rust-overlay.packages.${system};
|
||||
};
|
||||
|
||||
mkContainerFor =
|
||||
refraction:
|
||||
pkgs.dockerTools.buildLayeredImage {
|
||||
name = "refraction";
|
||||
tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}";
|
||||
config.Cmd = [ (lib.getExe refraction) ];
|
||||
inherit (refraction) architecture;
|
||||
};
|
||||
in
|
||||
{
|
||||
refraction = pkgs.callPackage ./nix/derivation.nix { inherit self; };
|
||||
|
||||
static-x86_64 = mkStatic { arch = "x86_64"; };
|
||||
static-aarch64 = mkStatic { arch = "aarch64"; };
|
||||
container-x86_64 = mkContainerFor packages'.static-x86_64;
|
||||
container-aarch64 = mkContainerFor packages'.static-aarch64;
|
||||
|
||||
default = packages'.refraction;
|
||||
}
|
||||
);
|
||||
|
||||
overlays.default = _: prev: {
|
||||
refraction = prev.callPackage ./nix/derivation.nix { inherit self; };
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,19 +31,24 @@ rustPlatform.buildRustPackage {
|
|||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
|
||||
CoreFoundation
|
||||
Security
|
||||
SystemConfiguration
|
||||
]);
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (
|
||||
with darwin.apple_sdk.frameworks;
|
||||
[
|
||||
CoreFoundation
|
||||
Security
|
||||
SystemConfiguration
|
||||
]
|
||||
);
|
||||
|
||||
env = let
|
||||
toRustFlags = lib.mapAttrs' (
|
||||
name:
|
||||
lib.nameValuePair
|
||||
"CARGO_PROFILE_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}"
|
||||
);
|
||||
in
|
||||
env =
|
||||
let
|
||||
toRustFlags = lib.mapAttrs' (
|
||||
name:
|
||||
lib.nameValuePair "CARGO_PROFILE_RELEASE_${
|
||||
lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] name)
|
||||
}"
|
||||
);
|
||||
in
|
||||
lib.optionalAttrs lto (toRustFlags {
|
||||
lto = "thin";
|
||||
})
|
||||
|
@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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,10 +20,11 @@ self: {
|
|||
optionals
|
||||
types
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.refraction = {
|
||||
enable = mkEnableOption "refraction";
|
||||
package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" {};
|
||||
package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" { };
|
||||
|
||||
user = mkOption {
|
||||
description = mdDoc ''
|
||||
|
@ -84,10 +86,8 @@ in {
|
|||
|
||||
systemd.services."refraction" = {
|
||||
enable = true;
|
||||
wantedBy = ["multi-user.target"];
|
||||
after =
|
||||
["network.target"]
|
||||
++ optionals (cfg.redisUrl == "local") ["redis-refraction.service"];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
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} = { }; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
refraction,
|
||||
rust-overlay,
|
||||
pkgsCross,
|
||||
}: {arch}: let
|
||||
}:
|
||||
{ arch }:
|
||||
let
|
||||
targets = with pkgsCross; {
|
||||
x86_64 = musl64.pkgsStatic;
|
||||
aarch64 = aarch64-multiplatform.pkgsStatic;
|
||||
|
@ -11,17 +13,21 @@
|
|||
|
||||
getRustcTarget = pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget;
|
||||
toolchain = rust-overlay.rust.minimal.override {
|
||||
extensions = ["rust-std"];
|
||||
extensions = [ "rust-std" ];
|
||||
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
|
||||
refraction.override {
|
||||
rustPlatform = rustPlatforms.${arch};
|
||||
optimizeSize = true;
|
||||
}
|
||||
refraction.override {
|
||||
rustPlatform = rustPlatforms.${arch};
|
||||
optimizeSize = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue