diff --git a/flake.nix b/flake.nix index fc2981b..2b54866 100644 --- a/flake.nix +++ b/flake.nix @@ -76,10 +76,10 @@ outputs = { self, nixpkgs, ... }@inputs: - import ./src/dotfiles { + import ./src/flake { inherit inputs self; inherit (nixpkgs) lib; - root = ./configs/nixos; + root = ./.; system = "x86_64-linux"; }; } diff --git a/src/dotfiles/apps.nix b/src/dotfiles/apps.nix deleted file mode 100644 index a8c7e71..0000000 --- a/src/dotfiles/apps.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - inputs, - lib, - formatter, - system, -}: -let - pkgs = inputs.nixpkgs.legacyPackages.${system}; -in -{ - fix = { - type = "app"; - program = lib.getExe ( - pkgs.writeShellApplication { - name = "fix"; - runtimeInputs = [ - formatter - pkgs.statix - pkgs.deadnix - ]; - text = '' - treefmt - statix fix . - deadnix --edit --exclude configs/nixos/hosts/*/hardware-configuration.nix -- . - treefmt - ''; - } - ); - }; -} diff --git a/src/dotfiles/default.nix b/src/dotfiles/default.nix index d012438..5b765e4 100644 --- a/src/dotfiles/default.nix +++ b/src/dotfiles/default.nix @@ -3,7 +3,6 @@ inputs, self, root, - system, }: let util = import ./util.nix { inherit lib; }; @@ -41,20 +40,6 @@ let }; in { - formatter.${system} = - (import ./formatter.nix { - inherit inputs system; - }).config.build.wrapper; - - apps.${system} = import ./apps.nix { - inherit - inputs - lib - system - ; - formatter = self.formatter.${system}; - }; - nixosConfigurations = import ./hosts.nix { inherit inputs diff --git a/src/flake/apps.nix b/src/flake/apps.nix new file mode 100644 index 0000000..6f5212f --- /dev/null +++ b/src/flake/apps.nix @@ -0,0 +1,41 @@ +{ + inputs, + lib, + formatter, + system, +}: +let + pkgs = inputs.nixpkgs.legacyPackages.${system}; +in +{ + fix = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "fix"; + runtimeInputs = [ + formatter + pkgs.statix + pkgs.deadnix + ]; + text = '' + treefmt + statix fix \ + --ignore 'configs/nixos/hosts/*/hardware-configuration.nix' \ + --ignore 'src/xatu/testdata/**' \ + --ignore third_party \ + . + deadnix --edit \ + --exclude \ + configs/nixos/hosts/neogaia/hardware-configuration.nix \ + configs/nixos/hosts/pikachu/hardware-configuration.nix \ + configs/nixos/hosts/zeus/hardware-configuration.nix \ + src/xatu/testdata \ + third_party \ + -- . + treefmt + ''; + } + ); + }; +} diff --git a/src/flake/default.nix b/src/flake/default.nix new file mode 100644 index 0000000..a5938d9 --- /dev/null +++ b/src/flake/default.nix @@ -0,0 +1,34 @@ +{ + lib, + inputs, + self, + root, + system, +}: +let + dotfiles = import ../dotfiles { + inherit + inputs + lib + self + ; + root = root + "/configs/nixos"; + }; +in +{ + formatter.${system} = + (import ./formatter.nix { + inherit inputs system; + }).config.build.wrapper; + + apps.${system} = import ./apps.nix { + inherit + inputs + lib + system + ; + formatter = self.formatter.${system}; + }; + + inherit (dotfiles) nixosConfigurations; +} diff --git a/src/dotfiles/formatter.nix b/src/flake/formatter.nix similarity index 83% rename from src/dotfiles/formatter.nix rename to src/flake/formatter.nix index f4cf85d..632ecf2 100644 --- a/src/dotfiles/formatter.nix +++ b/src/flake/formatter.nix @@ -6,5 +6,7 @@ inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} { settings.formatter.nixfmt.excludes = [ "configs/nixos/hosts/*/hardware-configuration.nix" + "src/xatu/testdata/*.nix" + "third_party/**" ]; } diff --git a/src/skills/style/nix/rules/flake.md b/src/skills/style/nix/rules/flake.md index 038541d..3e75efc 100644 --- a/src/skills/style/nix/rules/flake.md +++ b/src/skills/style/nix/rules/flake.md @@ -5,7 +5,7 @@ ### Rule Add flake inputs in `flake.nix`. -Put new flake output implementation in `src/dotfiles/default.nix`. +Put new flake output implementation in `src/flake/default.nix`. Use `flake.nix` to pass inputs into that implementation. ### Rationale