use treemft and also enable stylua

works well with CI
This commit is contained in:
cy 2024-12-28 10:59:57 -05:00
parent ae72391e42
commit 330feb587f
3 changed files with 57 additions and 20 deletions

View file

@ -1,4 +1,4 @@
name: "nix build and flake check" name: "nix flake and fmt check"
on: on:
pull_request: pull_request:
push: push:
@ -6,20 +6,8 @@ jobs:
flake-check: flake-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30 - uses: cachix/install-nix-action@v30
with: with:
github_access_token: ${{ secrets.github_token }} github_access_token: ${{ secrets.github_token }}
- run: nix flake check - run: nix flake check
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.github_token }}
- name: install nixfmt
run: nix-env -f <nixpkgs> -iAP nixfmt-rfc-style
- name: check that nix files are formatted correctly
run : nixfmt --check

37
flake.lock generated
View file

@ -84,6 +84,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1733097829,
"narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager", "home-manager": "home-manager",
@ -91,7 +107,8 @@
"nixpkgs-borg": "nixpkgs-borg", "nixpkgs-borg": "nixpkgs-borg",
"nixpkgs-evolution": "nixpkgs-evolution", "nixpkgs-evolution": "nixpkgs-evolution",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"sops-nix": "sops-nix" "sops-nix": "sops-nix",
"treefmt": "treefmt"
} }
}, },
"sops-nix": { "sops-nix": {
@ -113,6 +130,24 @@
"repo": "sops-nix", "repo": "sops-nix",
"type": "github" "type": "github"
} }
},
"treefmt": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1735135567,
"narHash": "sha256-8T3K5amndEavxnludPyfj3Z1IkcFdRpR23q+T0BVeZE=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "9e09d30a644c57257715902efbb3adc56c79cf28",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -11,6 +11,7 @@
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
treefmt.url = "github:numtide/treefmt-nix";
nixpkgs-borg.url = "github:cything/nixpkgs/borg"; nixpkgs-borg.url = "github:cything/nixpkgs/borg";
nixpkgs-master.url = "github:nixos/nixpkgs/master"; nixpkgs-master.url = "github:nixos/nixpkgs/master";
nixpkgs-evolution.url = "github:nixos/nixpkgs/a49023bcb550bcd84e1fa8afcbe7aa8bc0850bf4"; nixpkgs-evolution.url = "github:nixos/nixpkgs/a49023bcb550bcd84e1fa8afcbe7aa8bc0850bf4";
@ -21,6 +22,7 @@
self, self,
nixpkgs, nixpkgs,
home-manager, home-manager,
treefmt,
... ...
}@inputs: }@inputs:
let let
@ -65,10 +67,22 @@
}; };
} }
); );
treefmtEval = forEachSystem (
pkgs:
treefmt.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
programs.stylua.enable = true;
}
);
in in
{ {
packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; });
formatter = forEachSystem (pkgs: pkgs.nixfmt-rfc-style); formatter = forEachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
checks = forEachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
nixosConfigurations = nixosConfigurations =
let let