From 9ebd79f107e731d70694e4783884eeadecf02e1a Mon Sep 17 00:00:00 2001 From: alexion Date: Tue, 15 Sep 2026 23:21:37 -0400 Subject: [PATCH] refactor(nix): move style app wiring into dotfiles --- docs/TODO.md | 1 + flake.nix | 42 +++++----------------------------------- src/dotfiles/apps.nix | 40 ++++++++++++++++++++++++++++++++++++++ src/dotfiles/default.nix | 8 ++++++++ treefmt.nix | 9 --------- 5 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 src/dotfiles/apps.nix delete mode 100644 treefmt.nix diff --git a/docs/TODO.md b/docs/TODO.md index 3a01d21..bab0211 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -99,6 +99,7 @@ # tech debt - better remote deployment +- expose remote deployment as a flake app, replacing the Fish-only `deploy-to` workflow - centralize shared system group names, starting with the `storage` group ## nix refactor diff --git a/flake.nix b/flake.nix index 2a0461b..07078c2 100644 --- a/flake.nix +++ b/flake.nix @@ -75,42 +75,10 @@ }; outputs = - { - self, - nixpkgs, - treefmt-nix, - ... - }@inputs: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; - nixStyleCheck = pkgs.writeShellApplication { - name = "nix-style-check"; - runtimeInputs = [ - treefmtEval.config.build.wrapper - pkgs.statix - pkgs.deadnix - ]; - text = '' - treefmt --fail-on-change - statix check . - deadnix --fail --no-lambda-pattern-names --no-underscore . - ''; - }; - in - { - formatter.${system} = treefmtEval.config.build.wrapper; - - apps.${system}.nix-style-check = { - type = "app"; - program = "${nixStyleCheck}/bin/nix-style-check"; - }; - - nixosConfigurations = (import ./src/dotfiles { - inherit inputs self; - lib = nixpkgs.lib; - root = ./configs/nixos; - }).nixosConfigurations; + { self, nixpkgs, ... }@inputs: + import ./src/dotfiles { + inherit inputs self; + lib = nixpkgs.lib; + root = ./configs/nixos; }; } diff --git a/src/dotfiles/apps.nix b/src/dotfiles/apps.nix new file mode 100644 index 0000000..4787bd5 --- /dev/null +++ b/src/dotfiles/apps.nix @@ -0,0 +1,40 @@ +{ + inputs, + lib, +}: +let + system = "x86_64-linux"; + pkgs = inputs.nixpkgs.legacyPackages.${system}; + + treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + + programs.nixfmt.enable = true; + + settings.formatter.nixfmt.excludes = [ + "configs/nixos/hosts/*/hardware-configuration.nix" + ]; + }; + + styleCheck = pkgs.writeShellApplication { + name = "style-check"; + runtimeInputs = [ + treefmtEval.config.build.wrapper + pkgs.statix + pkgs.deadnix + ]; + text = '' + treefmt --fail-on-change + statix check . + deadnix --fail --no-lambda-pattern-names --no-underscore . + ''; + }; +in +{ + formatter.${system} = treefmtEval.config.build.wrapper; + + apps.${system}.style-check = { + type = "app"; + program = lib.getExe styleCheck; + }; +} diff --git a/src/dotfiles/default.nix b/src/dotfiles/default.nix index b7426d5..2a346e6 100644 --- a/src/dotfiles/default.nix +++ b/src/dotfiles/default.nix @@ -38,6 +38,13 @@ let ; registry = registry.collected; }; + + flakeApps = import ./apps.nix { + inherit + inputs + lib + ; + }; in { nixosConfigurations = import ./hosts.nix { @@ -52,3 +59,4 @@ in root = root + "/hosts"; }; } +// flakeApps diff --git a/treefmt.nix b/treefmt.nix deleted file mode 100644 index 376fded..0000000 --- a/treefmt.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - projectRootFile = "flake.nix"; - - programs.nixfmt.enable = true; - - settings.formatter.nixfmt.excludes = [ - "configs/nixos/hosts/*/hardware-configuration.nix" - ]; -}