diff options
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/module.nix | 25 | ||||
| -rw-r--r-- | nix/package.nix | 22 | ||||
| -rw-r--r-- | nix/static.nix | 46 |
3 files changed, 52 insertions, 41 deletions
diff --git a/nix/module.nix b/nix/module.nix index 3d23ead..3ad3929 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,13 +1,14 @@ -self: { +self: +{ config, lib, pkgs, ... -}: let +}: +let cfg = config.services.nixpkgs-tracker-bot; - inherit - (lib) + inherit (lib) getExe literalExpression mkEnableOption @@ -18,12 +19,12 @@ self: { ; inherit (pkgs.stdenv.hostPlatform) system; -in { +in +{ options.services.nixpkgs-tracker-bot = { enable = mkEnableOption "nixpkgs-tracker-bot"; - package = mkPackageOption ( - self.packages.${system} or (throw "${system} is not supported!") - ) "nixpkgs-tracker-bot" {}; + package = mkPackageOption (self.packages.${system} or (throw "${system} is not supported!") + ) "nixpkgs-tracker-bot" { }; environmentFile = mkOption { description = '' @@ -40,8 +41,8 @@ in { config = mkIf cfg.enable { systemd.services.nixpkgs-tracker-bot = { enable = true; - wantedBy = ["multi-user.target"]; - after = ["network.target"]; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; script = '' ${getExe cfg.package} @@ -82,9 +83,7 @@ in { RestrictRealtime = true; RestrictSUIDSGID = true; SystemCallArchitectures = "native"; - SystemCallFilter = [ - "@system-service" - ]; + SystemCallFilter = [ "@system-service" ]; UMask = "0077"; }; }; diff --git a/nix/package.nix b/nix/package.nix index 778fa27..261e785 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -22,16 +22,18 @@ rustPlatform.buildRustPackage { cargoLock.lockFile = ../Cargo.lock; - nativeBuildInputs = [pkg-config]; - buildInputs = [openssl]; + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; - env = let - toRustFlags = lib.mapAttrs' ( - name: - lib.nameValuePair - "CARGO_BUILD_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}" - ); - in + env = + let + toRustFlags = lib.mapAttrs' ( + name: + lib.nameValuePair "CARGO_BUILD_RELEASE_${ + lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] name) + }" + ); + in lib.optionalAttrs lto (toRustFlags { lto = "thin"; }) @@ -47,6 +49,6 @@ rustPlatform.buildRustPackage { homepage = "https://github.com/getchoo/nixpkgs-tracker-bot"; mainProgram = "nixpkgs-tracker-bot"; license = lib.licenses.mit; - maintainers = [lib.maintainers.getchoo]; + maintainers = [ lib.maintainers.getchoo ]; }; } diff --git a/nix/static.nix b/nix/static.nix index c5e3c57..86a1cc3 100644 --- a/nix/static.nix +++ b/nix/static.nix @@ -3,33 +3,43 @@ fenix, pkgsCross, nixpkgs-tracker-bot, -}: let +}: +let crossPkgsFor = with pkgsCross; { x86_64 = musl64.pkgsStatic; aarch64 = aarch64-multiplatform; }; - rustcTargetFor = lib.mapAttrs (lib.const (pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget)) crossPkgsFor; - rustStdFor = lib.mapAttrs (lib.const (rustcTarget: fenix.targets.${rustcTarget}.stable.rust-std)) rustcTargetFor; + rustcTargetFor = lib.mapAttrs (lib.const ( + pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget + )) crossPkgsFor; + rustStdFor = lib.mapAttrs (lib.const ( + rustcTarget: fenix.targets.${rustcTarget}.stable.rust-std + )) rustcTargetFor; - toolchain = with fenix; + toolchain = + with fenix; combine ( - [stable.cargo stable.rustc] + [ + stable.cargo + stable.rustc + ] ++ lib.attrValues rustStdFor ); - crossPlatformFor = - lib.mapAttrs ( - lib.const (pkgs: - pkgs.makeRustPlatform ( - lib.genAttrs ["cargo" "rustc"] (lib.const toolchain) - )) + crossPlatformFor = lib.mapAttrs (lib.const ( + pkgs: + pkgs.makeRustPlatform ( + lib.genAttrs [ + "cargo" + "rustc" + ] (lib.const toolchain) ) - crossPkgsFor; + )) crossPkgsFor; in - {arch}: - nixpkgs-tracker-bot.override { - rustPlatform = crossPlatformFor.${arch}; - inherit (crossPkgsFor.${arch}) openssl; - optimizeSize = true; - } +{ arch }: +nixpkgs-tracker-bot.override { + rustPlatform = crossPlatformFor.${arch}; + inherit (crossPkgsFor.${arch}) openssl; + optimizeSize = true; +} |
