From 6f2a3fc6e3e20e719a4d570d883d64023db00653 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 27 Dec 2023 03:22:50 -0500 Subject: flake: move dev components --- .envrc | 2 +- .gitignore | 1 - ci.nix | 35 ----------------------------------- dev.nix | 48 ------------------------------------------------ dev/checks.nix | 13 +++++++++++++ dev/ci.nix | 35 +++++++++++++++++++++++++++++++++++ dev/default.nix | 11 +++++++++++ dev/shell.nix | 32 ++++++++++++++++++++++++++++++++ flake.nix | 3 +-- 9 files changed, 93 insertions(+), 87 deletions(-) delete mode 100644 ci.nix delete mode 100644 dev.nix create mode 100644 dev/checks.nix create mode 100644 dev/ci.nix create mode 100644 dev/default.nix create mode 100644 dev/shell.nix diff --git a/.envrc b/.envrc index eea1624..ee044cb 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,3 @@ use flake -watch_file dev.nix +watch_file dev/shell.nix dotenv_if_exists diff --git a/.gitignore b/.gitignore index 708042a..e45066e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # nix build artifacts result* repl-result-out* -gc-roots/ # dev shell .pre-commit-config.yaml diff --git a/ci.nix b/ci.nix deleted file mode 100644 index 1eb78e3..0000000 --- a/ci.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - lib, - self, - ... -}: { - nix2workflow.output = self.hydraJobs; - - flake.hydraJobs = let - ciSystems = ["x86_64-linux" "x86_64-darwin"]; - recursiveMerge = builtins.foldl' lib.recursiveUpdate {}; - in - recursiveMerge [ - (let - outputs = lib.getAttrs ["checks" "devShells"] self; - isCompatible = system: _: lib.elem system ciSystems; - in - lib.mapAttrs (_: lib.filterAttrs isCompatible) outputs) - - ( - let - configurations = - lib.getAttrs [ - "nixosConfigurations" - "darwinConfigurations" - "homeConfigurations" - ] - self; - - isCompatible = _: configuration: lib.elem configuration.pkgs.system ciSystems; - toDeriv = _: configuration: configuration.config.system.build.toplevel or configuration.activationPackage; - in - lib.mapAttrs (_: v: lib.mapAttrs toDeriv (lib.filterAttrs isCompatible v)) configurations - ) - ]; -} diff --git a/dev.nix b/dev.nix deleted file mode 100644 index 7ac4683..0000000 --- a/dev.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ - perSystem = { - lib, - pkgs, - config, - inputs', - ... - }: { - pre-commit = { - settings.hooks = { - actionlint.enable = true; - ${config.formatter.pname}.enable = true; - deadnix.enable = true; - nil.enable = true; - statix.enable = true; - }; - }; - - devShells = { - default = pkgs.mkShell { - shellHook = config.pre-commit.installationScript; - packages = with pkgs; - [ - actionlint - - # nix - config.formatter - deadnix - nil - statix - - # utils - deploy-rs - fzf - just - jq - opentofu - - # ci - nix-eval-jobs - ] - ++ lib.optional stdenv.isLinux inputs'.agenix.packages.agenix; - }; - }; - - formatter = pkgs.alejandra; - }; -} diff --git a/dev/checks.nix b/dev/checks.nix new file mode 100644 index 0000000..386e122 --- /dev/null +++ b/dev/checks.nix @@ -0,0 +1,13 @@ +{ + perSystem = {config, ...}: { + pre-commit = { + settings.hooks = { + actionlint.enable = true; + ${config.formatter.pname}.enable = true; + deadnix.enable = true; + nil.enable = true; + statix.enable = true; + }; + }; + }; +} diff --git a/dev/ci.nix b/dev/ci.nix new file mode 100644 index 0000000..1eb78e3 --- /dev/null +++ b/dev/ci.nix @@ -0,0 +1,35 @@ +{ + lib, + self, + ... +}: { + nix2workflow.output = self.hydraJobs; + + flake.hydraJobs = let + ciSystems = ["x86_64-linux" "x86_64-darwin"]; + recursiveMerge = builtins.foldl' lib.recursiveUpdate {}; + in + recursiveMerge [ + (let + outputs = lib.getAttrs ["checks" "devShells"] self; + isCompatible = system: _: lib.elem system ciSystems; + in + lib.mapAttrs (_: lib.filterAttrs isCompatible) outputs) + + ( + let + configurations = + lib.getAttrs [ + "nixosConfigurations" + "darwinConfigurations" + "homeConfigurations" + ] + self; + + isCompatible = _: configuration: lib.elem configuration.pkgs.system ciSystems; + toDeriv = _: configuration: configuration.config.system.build.toplevel or configuration.activationPackage; + in + lib.mapAttrs (_: v: lib.mapAttrs toDeriv (lib.filterAttrs isCompatible v)) configurations + ) + ]; +} diff --git a/dev/default.nix b/dev/default.nix new file mode 100644 index 0000000..d8da3fe --- /dev/null +++ b/dev/default.nix @@ -0,0 +1,11 @@ +{ + imports = [ + ./checks.nix + ./ci.nix + ./shell.nix + ]; + + perSystem = {pkgs, ...}: { + formatter = pkgs.alejandra; + }; +} diff --git a/dev/shell.nix b/dev/shell.nix new file mode 100644 index 0000000..c0c9d20 --- /dev/null +++ b/dev/shell.nix @@ -0,0 +1,32 @@ +{ + perSystem = { + pkgs, + config, + inputs', + ... + }: { + devShells = { + default = pkgs.mkShell { + shellHook = config.pre-commit.installationScript; + packages = with pkgs; + [ + actionlint + + # nix + config.formatter + deadnix + nil + statix + + # utils + deploy-rs + fzf + just + jq + opentofu + ] + ++ lib.optional stdenv.isLinux inputs'.agenix.packages.agenix; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index c580600..aaac59d 100644 --- a/flake.nix +++ b/flake.nix @@ -142,13 +142,12 @@ inputs.pre-commit.flakeModule inputs.nix2workflow.flakeModule + ./dev ./modules ./overlay ./systems ./tf ./users - ./ci.nix - ./dev.nix ]; systems = [ -- cgit v1.2.3