Skip to content

Commit 6d1c16b

Browse files
committed
chores: format nix files with treefmt and set up a default formatter
1 parent f941cd6 commit 6d1c16b

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

flake.nix

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
flake-utils.url = "github:numtide/flake-utils";
77
};
88

9-
outputs = { self, nixpkgs, flake-utils }:
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
}:
1015
let
1116
systems = [
1217
"x86_64-linux"
@@ -17,7 +22,8 @@
1722

1823
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
1924

20-
mkAuthConfig = system:
25+
mkAuthConfig =
26+
system:
2127
let
2228
pkgs = nixpkgs.legacyPackages.${system};
2329
lib = pkgs.lib;
@@ -27,15 +33,18 @@
2733
pname = "supabase-auth";
2834
version = "0.1.0";
2935
src = ./.;
30-
36+
3137
vendorHash = "sha256-QBQUUFWT3H3L7ajFV8cgi0QREXnm0ReIisD+4ACfLZQ=";
32-
33-
buildFlags = [ "-tags" "netgo" ];
38+
39+
buildFlags = [
40+
"-tags"
41+
"netgo"
42+
];
3443
doCheck = false;
3544

3645
# Specify the main package
3746
subPackages = [ "." ];
38-
47+
3948
# Specify the output binary name
4049
postInstall = ''
4150
mv $out/bin/auth $out/bin/supabase-auth
@@ -88,15 +97,20 @@
8897
authConfigOutput = pkgs.stdenv.mkDerivation {
8998
name = "auth-config";
9099
src = ./.;
91-
buildInputs = [ pkgs.bash auth-service ];
100+
buildInputs = [
101+
pkgs.bash
102+
auth-service
103+
];
92104

93105
buildPhase = ''
94106
mkdir -p $out/etc $out/bin $out/lib/systemd/system
95107
96108
# Write the auth configuration
97109
cat > $out/etc/auth.env <<EOF
98110
# Auth configuration generated by Nix
99-
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name}=${value}") config.config.auth.settings)}
111+
${lib.concatStringsSep "\n" (
112+
lib.mapAttrsToList (name: value: "${name}=${value}") config.config.auth.settings
113+
)}
100114
EOF
101115
102116
# Write the systemd unit file
@@ -128,13 +142,15 @@
128142
# Write a script to manage the auth service
129143
cat > $out/bin/manage-auth <<EOF
130144
#!/bin/sh
131-
145+
132146
case "\$1" in
133147
start)
134148
echo "Starting auth service..."
135149
${auth-service}/bin/supabase-auth -c $out/etc/auth.env
136150
# Execute steps if enabled
137-
${lib.optionalString config.config.steps.enable (lib.concatStringsSep "\n" config.config.steps.commands)}
151+
${lib.optionalString config.config.steps.enable (
152+
lib.concatStringsSep "\n" config.config.steps.commands
153+
)}
138154
;;
139155
stop)
140156
echo "Stopping auth service..."
@@ -244,8 +260,8 @@
244260
default = authConfigOutput;
245261
};
246262
devShells.default = pkgs.mkShell {
247-
buildInputs = [
248-
pkgs.bash
263+
buildInputs = [
264+
pkgs.bash
249265
auth-service
250266
pkgs.go
251267
pkgs.gopls
@@ -268,5 +284,6 @@
268284
{
269285
packages = forAllSystems (system: (mkAuthConfig system).packages);
270286
devShells = forAllSystems (system: (mkAuthConfig system).devShells);
287+
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-tree);
271288
};
272-
}
289+
}

nix/auth-module.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
{ config, lib, pkgs, ... }:
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
27

38
with lib;
49

510
let
611
cfg = config.auth;
7-
in {
12+
in
13+
{
814
options.auth = {
915
enable = mkEnableOption "Supabase Auth Service";
1016

@@ -48,4 +54,4 @@ in {
4854
config = mkIf cfg.enable {
4955
# No NixOS-specific options here
5056
};
51-
}
57+
}

nix/steps-module.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
{ config, lib, pkgs, ... }:
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
27

38
with lib;
49

510
let
611
cfg = config.steps;
7-
in {
12+
in
13+
{
814
options.steps = {
915
enable = mkEnableOption "Auth service initialization steps";
1016

1117
commands = mkOption {
1218
type = types.listOf types.str;
13-
default = [];
19+
default = [ ];
1420
description = "Commands to run during service initialization.";
1521
};
1622
};
@@ -23,4 +29,4 @@ in {
2329
#"if [ -d migrations ]; then go run main.go migrate up; fi"
2430
];
2531
};
26-
}
32+
}

0 commit comments

Comments
 (0)