-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f732b90
commit e3b1767
Showing
16 changed files
with
483 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ inputs, ... }: | ||
{ | ||
imports = [ | ||
./dev | ||
./lib.nix | ||
./packages.nix | ||
./templates.nix | ||
]; | ||
|
||
perSystem = | ||
{ system, ... }: | ||
{ | ||
_module.args = { | ||
pkgs = import inputs.nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ lib, inputs, ... }: | ||
{ | ||
imports = | ||
[ ./devshell.nix ] | ||
++ lib.optional (inputs.git-hooks-nix ? flakeModule) inputs.git-hooks-nix.flakeModule | ||
++ lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule; | ||
|
||
perSystem = | ||
{ | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) { | ||
treefmt.config = { | ||
projectRootFile = "flake.nix"; | ||
flakeCheck = true; | ||
|
||
programs = { | ||
actionlint.enable = true; | ||
clang-format.enable = true; | ||
isort.enable = true; | ||
nixfmt = { | ||
enable = true; | ||
package = pkgs.nixfmt-rfc-style; | ||
}; | ||
prettier = { | ||
enable = true; | ||
|
||
excludes = [ "**.md" ]; | ||
}; | ||
ruff = { | ||
check = true; | ||
format = true; | ||
}; | ||
statix.enable = true; | ||
stylua.enable = true; | ||
shfmt.enable = true; | ||
taplo.enable = true; | ||
}; | ||
|
||
settings = { | ||
global.excludes = [ | ||
".editorconfig" | ||
".envrc" | ||
".git-blame-ignore-revs" | ||
".gitignore" | ||
"LICENSE" | ||
"flake.lock" | ||
"**.md" | ||
"**.scm" | ||
"**.svg" | ||
"**/man/*.5" | ||
]; | ||
formatter.ruff-format.options = [ "--isolated" ]; | ||
}; | ||
}; | ||
} | ||
// lib.optionalAttrs (inputs.pre-commit-hooks-nix ? flakeModule) { | ||
pre-commit = { | ||
check.enable = false; | ||
|
||
settings.hooks = { | ||
actionlint.enable = true; | ||
clang-tidy.enable = true; | ||
deadnix = { | ||
enable = true; | ||
|
||
settings = { | ||
edit = true; | ||
}; | ||
}; | ||
eslint = { | ||
enable = true; | ||
package = pkgs.eslint_d; | ||
}; | ||
luacheck.enable = true; | ||
pre-commit-hook-ensure-sops.enable = true; | ||
statix.enable = true; | ||
treefmt.enable = true; | ||
typos = { | ||
enable = true; | ||
excludes = [ "generated/*" ]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ lib, inputs, ... }: | ||
{ | ||
imports = lib.optional (inputs.devshell ? flakeModule) inputs.devshell.flakeModule; | ||
|
||
perSystem = | ||
{ | ||
lib, | ||
pkgs, | ||
config, | ||
self', | ||
system, | ||
... | ||
}: | ||
lib.optionalAttrs (inputs.devshell ? flakeModule) { | ||
devshells.default = { | ||
devshell.startup.pre-commit.text = config.pre-commit.installationScript; | ||
|
||
commands = [ | ||
{ | ||
name = "checks"; | ||
help = "Run all checks"; | ||
command = '' | ||
echo "=> Running all checks..." | ||
nix flake check "$@" | ||
''; | ||
} | ||
{ | ||
name = "format"; | ||
help = "Format the entire codebase"; | ||
command = "nix fmt"; | ||
} | ||
{ | ||
name = "docs"; | ||
help = "Build khanelinix documentation"; | ||
command = '' | ||
echo "=> Building khanelinix documentation..." | ||
${pkgs.lib.getExe pkgs.nix-output-monitor} build .#docs "$@" | ||
''; | ||
} | ||
{ | ||
name = "serve-docs"; | ||
help = "Build and serve documentation locally"; | ||
command = '' | ||
echo -e "=> Building khanelinix documentation...\n" | ||
doc_derivation=$(${pkgs.lib.getExe pkgs.nix-output-monitor} build .#docs --no-link --print-out-paths) | ||
echo -e "\n=> Documentation successfully built ('$doc_derivation')" | ||
echo -e "\n=> You can then open your browser to view the doc\n" | ||
(cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py}) | ||
''; | ||
} | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import http.server | ||
|
||
PORT = 8000 | ||
|
||
|
||
class UncachedHTTPHandler(http.server.SimpleHTTPRequestHandler): | ||
def end_headers(self): | ||
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") | ||
self.send_header("Pragma", "no-cache") | ||
self.send_header("Expires", "0") | ||
super().end_headers() | ||
|
||
|
||
with http.server.HTTPServer(("", PORT), UncachedHTTPHandler) as httpd: | ||
print(f"Serving documentation at http://localhost:{PORT}/nixvim") | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
config, | ||
lib, | ||
withSystem, | ||
... | ||
}: | ||
{ | ||
_module.args.helpers = import ../lib { inherit lib; }; | ||
|
||
flake.lib = lib.genAttrs config.systems ( | ||
lib.flip withSystem ( | ||
{ pkgs, ... }: | ||
{ | ||
check = import ../lib/tests.nix { inherit lib pkgs; }; | ||
helpers = import ../lib { inherit lib pkgs; }; | ||
} | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ inputs, ... }: | ||
{ | ||
perSystem = | ||
{ | ||
config, | ||
inputs', | ||
system, | ||
... | ||
}: | ||
{ | ||
# packages = import ../docs { | ||
# inherit system; | ||
# inherit (inputs) nixpkgs; | ||
# }; | ||
|
||
# Test that all packages build fine when running `nix flake check`. | ||
checks = config.packages; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ self, inputs, ... }: | ||
let | ||
templatesDir = ../templates; | ||
templates = builtins.attrNames (builtins.readDir templatesDir); | ||
generateTemplate = name: { | ||
description = "${name} template"; | ||
path = "${templatesDir}/${name}"; | ||
}; | ||
in | ||
{ | ||
flake.templates = builtins.listToAttrs ( | ||
map (name: { | ||
name = name; | ||
value = generateTemplate name; | ||
}) templates | ||
); | ||
|
||
# The following adds the template flake's checks to the main (current) flake's checks. | ||
# It ensures that the template's own checks are successful. | ||
perSystem = | ||
{ | ||
pkgs, | ||
system, | ||
lib, | ||
... | ||
}: | ||
{ | ||
checks = | ||
let | ||
callFlake = | ||
args@{ | ||
inputs, | ||
outputs, | ||
sourceInfo, | ||
}: | ||
let | ||
result = { | ||
outputs = args.outputs (inputs // { self = result; }); | ||
}; | ||
in | ||
result; | ||
|
||
templateFlakeOutputs = map ( | ||
template: | ||
callFlake { | ||
inputs = { | ||
inherit (inputs) flake-parts nixpkgs; | ||
}; | ||
# Import and read the `outputs` field of the template flake. | ||
outputs = import (templatesDir + "/${template}/flake.nix"); | ||
sourceInfo = { }; | ||
} | ||
) templates; | ||
|
||
templateChecks = lib.concatMap ( | ||
templateOutput: templateOutput.checks.${system} or [ ] | ||
) templateFlakeOutputs; | ||
in | ||
lib.listToAttrs ( | ||
map (check: { | ||
name = "template-${check.name}"; | ||
value = check; | ||
}) templateChecks | ||
); | ||
}; | ||
} |
Oops, something went wrong.