summaryrefslogtreecommitdiff
path: root/repo
diff options
context:
space:
mode:
authorseth <[email protected]>2024-02-04 16:40:38 -0500
committerseth <[email protected]>2024-02-04 16:41:47 -0500
commit5f848623dff7cbcd21911032e5fd4c77bcf7d413 (patch)
tree7462ae7abec5beee71443702b330e3eeca1a407f /repo
parent371235663a4e8d783dfc4294bb0b10cd3206c9c6 (diff)
tree-wide: better separate/name some things
Diffstat (limited to 'repo')
-rw-r--r--repo/checks.nix13
-rw-r--r--repo/ci.nix28
-rw-r--r--repo/default.nix11
-rw-r--r--repo/shell.nix34
4 files changed, 86 insertions, 0 deletions
diff --git a/repo/checks.nix b/repo/checks.nix
new file mode 100644
index 0000000..cf2b732
--- /dev/null
+++ b/repo/checks.nix
@@ -0,0 +1,13 @@
+{
+ perSystem = {self', ...}: {
+ pre-commit = {
+ settings.hooks = {
+ actionlint.enable = true;
+ ${self'.formatter.pname}.enable = true;
+ deadnix.enable = true;
+ nil.enable = true;
+ statix.enable = true;
+ };
+ };
+ };
+}
diff --git a/repo/ci.nix b/repo/ci.nix
new file mode 100644
index 0000000..e33c088
--- /dev/null
+++ b/repo/ci.nix
@@ -0,0 +1,28 @@
+{
+ lib,
+ self,
+ ...
+}: {
+ flake.hydraJobs = let
+ ciSystems = ["x86_64-linux"];
+
+ getOutputs = lib.getAttrs ciSystems;
+
+ mapCfgsToDerivs = lib.mapAttrs (_: cfg: cfg.activationPackage or cfg.config.system.build.toplevel);
+ getCompatibleCfgs = lib.filterAttrs (_: cfg: lib.elem cfg.pkgs.system ciSystems);
+ in
+ builtins.foldl' lib.recursiveUpdate {} [
+ (
+ lib.genAttrs
+ ["nixosConfigurations" "homeConfigurations"]
+ (
+ type: mapCfgsToDerivs (getCompatibleCfgs self."${type}")
+ )
+ )
+ (
+ lib.genAttrs
+ ["checks" "devShells"]
+ (type: getOutputs self.${type})
+ )
+ ];
+}
diff --git a/repo/default.nix b/repo/default.nix
new file mode 100644
index 0000000..d8da3fe
--- /dev/null
+++ b/repo/default.nix
@@ -0,0 +1,11 @@
+{
+ imports = [
+ ./checks.nix
+ ./ci.nix
+ ./shell.nix
+ ];
+
+ perSystem = {pkgs, ...}: {
+ formatter = pkgs.alejandra;
+ };
+}
diff --git a/repo/shell.nix b/repo/shell.nix
new file mode 100644
index 0000000..7442907
--- /dev/null
+++ b/repo/shell.nix
@@ -0,0 +1,34 @@
+{
+ perSystem = {
+ pkgs,
+ config,
+ inputs',
+ self',
+ ...
+ }: {
+ devShells = {
+ default = pkgs.mkShellNoCC {
+ shellHook = config.pre-commit.installationScript;
+ packages = with pkgs;
+ [
+ nix
+
+ # format + lint
+ actionlint
+ self'.formatter
+ deadnix
+ nil
+ statix
+
+ # utils
+ deploy-rs
+ fzf
+ just
+ config.terranix.package
+ ]
+ ++ lib.optional stdenv.isDarwin [inputs'.darwin.packages.darwin-rebuild]
+ ++ lib.optionals stdenv.isLinux [nixos-rebuild inputs'.agenix.packages.agenix];
+ };
+ };
+ };
+}