From 34a7a042a36b63eb6b900932b1e420e4b6014a57 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 5 May 2024 11:35:18 -0400 Subject: simplify some things (#353) * flake: drop flake-parts * flake: add back flake-parts * flake: use flake module again for configurations --- parts/checks.nix | 21 +++++++++++++++++++++ parts/ci.nix | 34 ++++++++++++++++++++++++++++++++++ parts/default.nix | 11 +++++++++++ parts/shell.nix | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 parts/checks.nix create mode 100644 parts/ci.nix create mode 100644 parts/default.nix create mode 100644 parts/shell.nix (limited to 'parts') diff --git a/parts/checks.nix b/parts/checks.nix new file mode 100644 index 0000000..5ccc308 --- /dev/null +++ b/parts/checks.nix @@ -0,0 +1,21 @@ +{inputs, ...}: { + perSystem = { + lib, + pkgs, + ... + }: { + checks = { + inherit + (inputs.flake-checks.lib.mkChecks { + root = ../.; + inherit pkgs; + }) + actionlint + alejandra + deadnix + editorconfig + statix + ; + }; + }; +} diff --git a/parts/ci.nix b/parts/ci.nix new file mode 100644 index 0000000..5ddc81c --- /dev/null +++ b/parts/ci.nix @@ -0,0 +1,34 @@ +{self, ...}: { + perSystem = { + lib, + pkgs, + system, + self', + ... + }: { + packages = { + ciGate = let + toTopLevel = cfg: cfg.config.system.build.toplevel or cfg.activationPackage; + isCompatible = cfg: cfg.pkgs.system == system; + + configurations = + map + (type: + lib.mapAttrs (lib.const toTopLevel) + (lib.filterAttrs (lib.const isCompatible) self.${type})) + [ + "nixosConfigurations" + "darwinConfigurations" + "homeConfigurations" + ]; + + required = lib.concatMap lib.attrValues ( + lib.flatten [self'.checks self'.devShells configurations] + ); + in + pkgs.writeText "ci-gate" ( + lib.concatMapStringsSep "\n" toString required + ); + }; + }; +} diff --git a/parts/default.nix b/parts/default.nix new file mode 100644 index 0000000..d8da3fe --- /dev/null +++ b/parts/default.nix @@ -0,0 +1,11 @@ +{ + imports = [ + ./checks.nix + ./ci.nix + ./shell.nix + ]; + + perSystem = {pkgs, ...}: { + formatter = pkgs.alejandra; + }; +} diff --git a/parts/shell.nix b/parts/shell.nix new file mode 100644 index 0000000..ada1ecf --- /dev/null +++ b/parts/shell.nix @@ -0,0 +1,33 @@ +{ + perSystem = { + lib, + pkgs, + inputs', + self', + ... + }: { + devShells = { + default = pkgs.mkShellNoCC { + packages = + [ + pkgs.nix + + # format + lint + pkgs.actionlint + self'.formatter + pkgs.deadnix + pkgs.nil + pkgs.statix + + # utils + pkgs.deploy-rs + pkgs.fzf + pkgs.just + self'.packages.opentofu + ] + ++ lib.optional pkgs.stdenv.isDarwin [inputs'.darwin.packages.darwin-rebuild] + ++ lib.optionals pkgs.stdenv.isLinux [pkgs.nixos-rebuild inputs'.agenix.packages.agenix]; + }; + }; + }; +} -- cgit v1.2.3