Skip to content

Commit

Permalink
treewide: nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliButz committed Feb 2, 2025
1 parent d653af6 commit dbfc220
Show file tree
Hide file tree
Showing 14 changed files with 686 additions and 562 deletions.
14 changes: 7 additions & 7 deletions components/docs.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ authentik-src
, authentik-version
, buildNapalmPackage
, nodejs_22
{
authentik-src,
authentik-version,
buildNapalmPackage,
nodejs_22,
}:

buildNapalmPackage "${authentik-src}/website" {
Expand Down Expand Up @@ -52,8 +53,7 @@ buildNapalmPackage "${authentik-src}/website" {
let
files = builtins.readDir ./docs-extra-package-locks;
in
builtins.concatMap (f:
if files.${f} == "regular"
then [ (./docs-extra-package-locks + "/${f}") ] else []
builtins.concatMap (
f: if files.${f} == "regular" then [ (./docs-extra-package-locks + "/${f}") ] else [ ]
) (builtins.attrNames files);
}
11 changes: 6 additions & 5 deletions components/frontend.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ authentik-src
, authentik-version
, authentikComponents
, buildNapalmPackage
, nodejs_22
{
authentik-src,
authentik-version,
authentikComponents,
buildNapalmPackage,
nodejs_22,
}:
buildNapalmPackage "${authentik-src}/web" rec {
version = authentik-version; # 0.0.0 specified upstream in package.json
Expand Down
19 changes: 10 additions & 9 deletions components/gopkgs.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ authentik-src
, authentik-version
, authentikComponents
, buildGo123Module
, lib
, makeWrapper
{
authentik-src,
authentik-version,
authentikComponents,
buildGo123Module,
lib,
makeWrapper,
}:

buildGo123Module {
Expand All @@ -16,15 +17,15 @@ buildGo123Module {
'';
src = lib.cleanSourceWith {
src = authentik-src;
filter = (path: _:
filter = (
path: _:
(builtins.any (x: x) (
(map (infix: lib.hasInfix infix path) [
"/authentik"
"/cmd"
"/internal"
])
++
(map (suffix: lib.hasSuffix suffix path) [
++ (map (suffix: lib.hasSuffix suffix path) [
"/web"
"/web/static.go"
"/web/robots.txt"
Expand Down
29 changes: 16 additions & 13 deletions components/manage.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{ authentik-src
, authentikComponents
, makeWrapper
, runCommandLocal
{
authentik-src,
authentikComponents,
makeWrapper,
runCommandLocal,
}:

runCommandLocal "authentik-manage" {
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -vp $out/bin
cp -v ${authentik-src}/manage.py $out/bin/manage.py
runCommandLocal "authentik-manage"
{
nativeBuildInputs = [ makeWrapper ];
}
''
mkdir -vp $out/bin
cp -v ${authentik-src}/manage.py $out/bin/manage.py
wrapProgram $out/bin/manage.py \
--prefix PATH : ${authentikComponents.pythonEnv}/bin \
--prefix PYTHONPATH : ${authentikComponents.staticWorkdirDeps}
''
wrapProgram $out/bin/manage.py \
--prefix PATH : ${authentikComponents.pythonEnv}/bin \
--prefix PYTHONPATH : ${authentikComponents.staticWorkdirDeps}
''
41 changes: 22 additions & 19 deletions components/migrate.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{ authentik-src
, authentikComponents
, makeWrapper
, runCommandLocal
{
authentik-src,
authentikComponents,
makeWrapper,
runCommandLocal,
}:

runCommandLocal "authentik-migrate.py" {
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -vp $out/bin
cp ${authentik-src}/lifecycle/migrate.py $out/bin/migrate.py
chmod +w $out/bin/migrate.py
patchShebangs $out/bin/migrate.py
substituteInPlace $out/bin/migrate.py \
--replace \
'migration_path in Path(__file__).parent.absolute().glob("system_migrations/*.py")' \
'migration_path in Path("${authentikComponents.staticWorkdirDeps}/lifecycle").glob("system_migrations/*.py")'
wrapProgram $out/bin/migrate.py \
--prefix PATH : ${authentikComponents.pythonEnv}/bin \
--prefix PYTHONPATH : ${authentikComponents.staticWorkdirDeps}
''
runCommandLocal "authentik-migrate.py"
{
nativeBuildInputs = [ makeWrapper ];
}
''
mkdir -vp $out/bin
cp ${authentik-src}/lifecycle/migrate.py $out/bin/migrate.py
chmod +w $out/bin/migrate.py
patchShebangs $out/bin/migrate.py
substituteInPlace $out/bin/migrate.py \
--replace \
'migration_path in Path(__file__).parent.absolute().glob("system_migrations/*.py")' \
'migration_path in Path("${authentikComponents.staticWorkdirDeps}/lifecycle").glob("system_migrations/*.py")'
wrapProgram $out/bin/migrate.py \
--prefix PATH : ${authentikComponents.pythonEnv}/bin \
--prefix PYTHONPATH : ${authentikComponents.staticWorkdirDeps}
''
25 changes: 13 additions & 12 deletions components/pythonEnv.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ authentik-src
, authentikPoetryOverrides
, defaultPoetryOverrides
, lib
, mkPoetryEnv
, python312
{
authentik-src,
authentikPoetryOverrides,
defaultPoetryOverrides,
lib,
mkPoetryEnv,
python312,
}:

mkPoetryEnv {
Expand All @@ -12,13 +13,13 @@ mkPoetryEnv {
overrides = [
defaultPoetryOverrides
] ++ authentikPoetryOverrides;
groups = ["main"];
checkGroups = [];
groups = [ "main" ];
checkGroups = [ ];
# workaround to remove dev-dependencies for the current combination of legacy
# used by authentik and poetry2nix's behavior
pyproject = builtins.toFile "patched-pyproject.toml" (lib.replaceStrings
["tool.poetry.dev-dependencies"]
["tool.poetry.group.dev.dependencies"]
(builtins.readFile "${authentik-src}/pyproject.toml")
pyproject = builtins.toFile "patched-pyproject.toml" (
lib.replaceStrings [ "tool.poetry.dev-dependencies" ] [ "tool.poetry.group.dev.dependencies" ] (
builtins.readFile "${authentik-src}/pyproject.toml"
)
);
}
44 changes: 33 additions & 11 deletions components/staticWorkdirDeps.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ authentik-src
, authentikComponents
, linkFarm
, applyPatches
{
authentik-src,
authentikComponents,
linkFarm,
applyPatches,
}:
let
patched-src = applyPatches {
Expand All @@ -14,11 +15,32 @@ let
};
in
linkFarm "authentik-static-workdir-deps" [
{ name = "authentik"; path = "${patched-src}/authentik"; }
{ name = "locale"; path = "${authentik-src}/locale"; }
{ name = "blueprints"; path = "${authentik-src}/blueprints"; }
{ name = "internal"; path = "${authentik-src}/internal"; }
{ name = "lifecycle"; path = "${patched-src}/lifecycle"; }
{ name = "schemas"; path = "${authentik-src}/schemas"; }
{ name = "web"; path = authentikComponents.frontend; }
{
name = "authentik";
path = "${patched-src}/authentik";
}
{
name = "locale";
path = "${authentik-src}/locale";
}
{
name = "blueprints";
path = "${authentik-src}/blueprints";
}
{
name = "internal";
path = "${authentik-src}/internal";
}
{
name = "lifecycle";
path = "${patched-src}/lifecycle";
}
{
name = "schemas";
path = "${authentik-src}/schemas";
}
{
name = "web";
path = authentikComponents.frontend;
}
]
19 changes: 9 additions & 10 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix
Loading

0 comments on commit dbfc220

Please sign in to comment.