maint: Run nix stuff through the formatter

There are several choices for formatting Nix code, but IMHO alejandra is the
right kind of opinionated: <https://github.com/kamadorueda/alejandra>.
This commit is contained in:
Lucas Bergman 2024-02-19 20:31:47 -06:00
parent 847413f4f5
commit fe162968e5
2 changed files with 153 additions and 136 deletions

View File

@ -1,11 +1,12 @@
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in in
(import ( (import (
fetchTarball { fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }
) { ) {
src = ./.; src = ./.;
}).defaultNix })
.defaultNix

View File

@ -6,16 +6,25 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
naersk.url = "github:nix-community/naersk"; naersk.url = "github:nix-community/naersk";
flake-compat = { url = github:edolstra/flake-compat; flake = false; }; flake-compat = {
url = github:edolstra/flake-compat;
flake = false;
};
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = {nixpkgs, flake-utils, naersk, rust-overlay, ...}: outputs = {
nixpkgs,
flake-utils,
naersk,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
overlays = [ overlays = [
rust-overlay.overlays.default rust-overlay.overlays.default
]; ];
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs {inherit system overlays;};
rust-bin = pkgs.rust-bin.stable."1.71.0".default; rust-bin = pkgs.rust-bin.stable."1.71.0".default;
naersk-lib = pkgs.callPackage naersk { naersk-lib = pkgs.callPackage naersk {
rustc = rust-bin; rustc = rust-bin;
@ -25,18 +34,25 @@
name = "heracles"; name = "heracles";
verion = "0.0.1"; verion = "0.0.1";
src = ./.; src = ./.;
nativeBuildInputs = [ pkgs.pkg-config ]; nativeBuildInputs = [pkgs.pkg-config];
buildInputs = ( buildInputs =
if pkgs.stdenv.isDarwin then (
with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ] if pkgs.stdenv.isDarwin
else then with pkgs.darwin.apple_sdk.frameworks; [Security SystemConfiguration]
[ pkgs.openssl ]) ++ [rust-bin]; else [pkgs.openssl]
)
++ [rust-bin];
}; };
in in {
{
packages.default = heracles; packages.default = heracles;
}) // { })
nixosModule = {config, pkgs, lib}: with lib; { // {
nixosModule = {
config,
pkgs,
lib,
}:
with lib; {
options = { options = {
services.heracles.enable = mkEnableOption "enable heracles service"; services.heracles.enable = mkEnableOption "enable heracles service";
services.heracles.listen = mkOption { services.heracles.listen = mkOption {
@ -134,12 +150,12 @@
config = mkIf config.services.heracles.enable { config = mkIf config.services.heracles.enable {
environment.etc."heracles.yaml" = { environment.etc."heracles.yaml" = {
text = (generators.toYAML {} config.services.heracles.settings); text = generators.toYAML {} config.services.heracles.settings;
}; };
systemd.services.heracles = { systemd.services.heracles = {
wantedBy = [ "multi-user.target" "default.target" ]; wantedBy = ["multi-user.target" "default.target"];
wants = [ "network.target" ]; wants = ["network.target"];
after = [ "network-online.target" ]; after = ["network-online.target"];
serviceConfig = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "30s"; RestartSec = "30s";