diff --git a/hosts/common/configs/system/btrfs/default.nix b/hosts/common/configs/system/btrfs/default.nix index b0447e1..d561c6e 100644 --- a/hosts/common/configs/system/btrfs/default.nix +++ b/hosts/common/configs/system/btrfs/default.nix @@ -5,7 +5,5 @@ interval = "weekly"; }; - environment.systemPackages = with pkgs; [ - compsize - ]; + environment.systemPackages = with pkgs; [ compsize ]; } diff --git a/hosts/common/configs/user/console/nix-develop/default.nix b/hosts/common/configs/user/console/nix-develop/default.nix index 3b0d485..384d0bc 100644 --- a/hosts/common/configs/user/console/nix-develop/default.nix +++ b/hosts/common/configs/user/console/nix-develop/default.nix @@ -35,7 +35,16 @@ done if [[ -z "$devshell" ]]; then - if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi + if [ ! -f flake.nix ]; then + cp "${./template.nix}" flake.nix + chmod 755 flake.nix + fi + + if [ ! treefmt.nix ]; then + cp "${./treefmt.nix}" treefmt.nix + chmod 755 treefmt.nix + fi + nix develop -c "$SHELL" else nix develop self#"$devshell" -c "$SHELL" diff --git a/hosts/common/configs/user/console/nix-develop/template.nix b/hosts/common/configs/user/console/nix-develop/template.nix index a5519d0..31c4790 100644 --- a/hosts/common/configs/user/console/nix-develop/template.nix +++ b/hosts/common/configs/user/console/nix-develop/template.nix @@ -8,21 +8,35 @@ }; flake-utils = { - url = "github:numtide/flake-utils"; + type = "github"; + owner = "numtide"; + repo = "flake-utils"; + ref = "main"; + }; + + treefmt-nix = { + type = "github"; + owner = "numtide"; + repo = "treefmt-nix"; + ref = "main"; + + inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = - { nixpkgs, ... }@inputs: + { self, nixpkgs, ... }@inputs: inputs.flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; + treefmt = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix; in { - devShells.default = pkgs.mkShell { packages = [ ]; }; + devShells.default = pkgs.mkShell { packages = with pkgs; [ ]; }; - formatter = pkgs.nixfmt-rfc-style; + formatter = treefmt.config.build.wrapper; + checks.formatting = treefmt.config.build.check self; } ); } diff --git a/hosts/common/configs/user/console/nix-develop/treefmt.nix b/hosts/common/configs/user/console/nix-develop/treefmt.nix new file mode 100644 index 0000000..2819e9f --- /dev/null +++ b/hosts/common/configs/user/console/nix-develop/treefmt.nix @@ -0,0 +1,19 @@ +{ ... }: +{ + projectRootFile = "flake.nix"; + + programs = { + nixfmt = { + enable = true; + strict = true; + }; + }; + + settings = { + global = { + excludes = [ + ".envrc" + ]; + }; + }; +} diff --git a/hosts/common/configs/user/console/nix-direnv/default.nix b/hosts/common/configs/user/console/nix-direnv/default.nix index e5f808d..c3c0795 100644 --- a/hosts/common/configs/user/console/nix-direnv/default.nix +++ b/hosts/common/configs/user/console/nix-direnv/default.nix @@ -49,8 +49,21 @@ done if [[ -z "$devshell" ]]; then - echo "use flake" > .envrc - if [ ! -f flake.nix ]; then cp "${../nix-develop/template.nix}" flake.nix; fi + if "$hide"; then + echo "use flake path:." > .envrc; + else + echo "use flake" > .envrc; + fi + + if [ ! -f flake.nix ]; then + cp "${../nix-develop/template.nix}" flake.nix + chmod 755 flake.nix + fi + + if [ ! -f treefmt.nix ]; then + cp "${../nix-develop/treefmt.nix}" treefmt.nix + chmod 755 treefmt.nix + fi else echo "use flake self#$devshell" > .envrc fi @@ -62,6 +75,7 @@ if [ -z "$devshell" ]; then if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi + if ! grep -q "^treefmt.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "treefmt.nix" >> "$top/.git/info/exclude"; fi fi fi