refactor(nix): add basic formatting check via nix flake check
This commit is contained in:
parent
f72378f850
commit
14b7243546
@ -10,8 +10,10 @@ jobs:
|
|||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install `Fmt` package
|
|
||||||
run: nix --experimental-features "flakes nix-command" build 'path:./pkgs/Fmt' --out-link fmt-result
|
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: PATH="${PATH}:${PWD}/fmt-result/bin" ./scripts/check-fmt-git-files.bash
|
run: |
|
||||||
|
for f in **/flake.nix; do
|
||||||
|
nix flake lock --update-input "$(basename "$(dirname "$f")")" || true
|
||||||
|
done
|
||||||
|
nix flake lock --update-input Fmt
|
||||||
|
nix --experimental-features "flakes nix-command" flake check
|
||||||
|
@ -236,7 +236,6 @@ in {
|
|||||||
};
|
};
|
||||||
git = {
|
git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hooks = { pre-commit = ../scripts/check-fmt-git-pre-commit.bash; };
|
|
||||||
userName = "Price Hiller";
|
userName = "Price Hiller";
|
||||||
userEmail = "price@orion-technologies.io";
|
userEmail = "price@orion-technologies.io";
|
||||||
aliases = { unstage = "reset HEAD --"; };
|
aliases = { unstage = "reset HEAD --"; };
|
||||||
|
48
flake.lock
48
flake.lock
@ -9,12 +9,12 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1,
|
"lastModified": 1,
|
||||||
"narHash": "sha256-8lIyAZd5WpfmwLW/peBk3eRX3SGUmIeczv+y73pTFwY=",
|
"narHash": "sha256-w//f0CiJqZtYO1MYA7DzwPnNFZh/dxPx6+ZP9tNoUEs=",
|
||||||
"path": "./pkgs/Fmt",
|
"path": "pkgs/Fmt",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"path": "./pkgs/Fmt",
|
"path": "pkgs/Fmt",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -152,11 +152,11 @@
|
|||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710867991,
|
"lastModified": 1710954378,
|
||||||
"narHash": "sha256-DXDC0u2Nrde3687uRiuwLy3lCCRRiymYluOCgj3tAvQ=",
|
"narHash": "sha256-IbidJZykfjyGZ9totyhUIPHcDSqW1B3Pepgo3c9tDHI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "emacs-overlay",
|
"repo": "emacs-overlay",
|
||||||
"rev": "78da5146ec2bbffc5a31fe08be4bcaf2fd6eeea3",
|
"rev": "a9216f7a1ec216e36e31c7d2ed42de4df89d918a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -558,11 +558,11 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "contrib",
|
"dir": "contrib",
|
||||||
"lastModified": 1710802530,
|
"lastModified": 1710889471,
|
||||||
"narHash": "sha256-lwTJam2SxB+NP1gqy9QtCvqCDauPUzZ+nvOB0jwqg4Q=",
|
"narHash": "sha256-9t/LXGvVH+ZiiVWLoroTkGe57Nu0Xe5AxiHqz9AHTiM=",
|
||||||
"owner": "neovim",
|
"owner": "neovim",
|
||||||
"repo": "neovim",
|
"repo": "neovim",
|
||||||
"rev": "79af4e7e734ed460eddbd57b7bf70d3e1624d772",
|
"rev": "37db3d97ea49fd1e22d50dd21e8924ed047cba95",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -581,11 +581,11 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710806634,
|
"lastModified": 1710893056,
|
||||||
"narHash": "sha256-sx1JfP47+5E9j4dLVdY422SiD99oeepUtbT8ZQW8GTc=",
|
"narHash": "sha256-FHJEmoVPHPNUe3zBBjcQipnwX5yEtaQzmmAOP5tLvAc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "neovim-nightly-overlay",
|
"repo": "neovim-nightly-overlay",
|
||||||
"rev": "f7b28f01c5f7e5e35fbc4e9a64faf95b8211744b",
|
"rev": "35e8046342b1c6ce0aab7fe5f791dd3d6b5ae1df",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -631,11 +631,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-stable": {
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710695816,
|
"lastModified": 1710838473,
|
||||||
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
|
"narHash": "sha256-RLvwdQSENKOaLdKhNie8XqHmTXzNm00/M/THj6zplQo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
|
"rev": "fa9f817df522ac294016af3d40ccff82f5fd3a63",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -647,11 +647,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710765496,
|
"lastModified": 1710827359,
|
||||||
"narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=",
|
"narHash": "sha256-/KY8hffTh9SN/tTcDn/FrEiYwTXnU8NKnr4D7/stmmA=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7",
|
"rev": "5710127d9693421e78cca4f74fac2db6d67162b1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -678,11 +678,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710871319,
|
"lastModified": 1710960368,
|
||||||
"narHash": "sha256-y30iYkmVpi6o2yCLH8Iz7Bi7XXuNOmCPmxFIdNMW9Og=",
|
"narHash": "sha256-CHnNU2yzeOY2tyOWtLVLerdNCrCgwqgZsGjpHKKWGWc=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f4fb648799ae71ac118a2a1c8b92698f2a01e246",
|
"rev": "2fe0900189c7e9561b9fffac0ad8b007244c13bc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -900,11 +900,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710854720,
|
"lastModified": 1710944791,
|
||||||
"narHash": "sha256-PxRujEfImJGjZCmcf0zbZFc1PCphTwPZqcdoXI4hb00=",
|
"narHash": "sha256-0EuGII59W01nLlU22buxJa5TJc/omZiIlchOWkwGI3M=",
|
||||||
"owner": "Alexays",
|
"owner": "Alexays",
|
||||||
"repo": "Waybar",
|
"repo": "Waybar",
|
||||||
"rev": "73e24af71c302c285573ca63099945efcfc4a685",
|
"rev": "1ecca055f780cb9fb7908cc0f1ef1c902cc0f662",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
21
flake.nix
21
flake.nix
@ -13,7 +13,7 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
Fmt = {
|
Fmt = {
|
||||||
url = "path:./pkgs/Fmt";
|
url = "path:pkgs/Fmt";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
home-manager = {
|
home-manager = {
|
||||||
@ -41,12 +41,25 @@
|
|||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
username = "sam";
|
username = "sam";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in {
|
in {
|
||||||
defaultPackage.x86_64-linux = home-manager.defaultPackage.x86_64-linux;
|
packages.x86_64-linux.default = home-manager.defaultPackage.x86_64-linux;
|
||||||
targets.genericLinux = { enable = true; };
|
checks.${system} = {
|
||||||
|
formatting = pkgs.runCommand "check-dot-file-formatting" {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
findutils
|
||||||
|
inputs.Fmt.packages.x86_64-linux.default
|
||||||
|
];
|
||||||
|
} ''
|
||||||
|
set -euo pipefail
|
||||||
|
cd ${self}
|
||||||
|
Fmt -- $(find . -type f)
|
||||||
|
printf "TEST COMPLETED!\n" > $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
homeConfigurations.${username} =
|
homeConfigurations.${username} =
|
||||||
home-manager.lib.homeManagerConfiguration {
|
home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
inherit pkgs;
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
inherit self;
|
inherit self;
|
||||||
|
@ -10,13 +10,19 @@
|
|||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let pkgs = nixpkgs.legacyPackages.${system};
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in {
|
in {
|
||||||
# This builds the blog binary then runs it and collects the output. Once done it throws away the binary and
|
packages.default = pkgs.writeShellApplication {
|
||||||
# shoves the newly created static site into the result.
|
name = "Fmt";
|
||||||
packages.default =
|
runtimeInputs = with pkgs; [
|
||||||
pkgs.writeScriptBin "Fmt" (builtins.readFile ./fmt.bash);
|
stylua
|
||||||
|
gnugrep
|
||||||
# Rust dev environment
|
nixfmt
|
||||||
devShells.default = pkgs.mkShell;
|
nodePackages.prettier
|
||||||
|
shfmt
|
||||||
|
];
|
||||||
|
text = (''
|
||||||
|
#!${pkgs.bash}/bin/bash
|
||||||
|
'' + builtins.readFile ./fmt.bash);
|
||||||
|
};
|
||||||
}) // {
|
}) // {
|
||||||
overlays.default = final: prev: {
|
overlays.default = final: prev: {
|
||||||
Fmt = self.packages.${final.system}.default;
|
Fmt = self.packages.${final.system}.default;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env -S nix --extra-experimental-features "flakes nix-command" shell nixpkgs#bash nixpkgs#stylua nixpkgs#gnugrep nixpkgs#nixfmt nixpkgs#nodePackages.prettier nixpkgs#shfmt --command bash
|
|
||||||
# vim: ft=sh
|
# vim: ft=sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
Loading…
Reference in New Issue
Block a user