-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
110 lines (101 loc) · 3.28 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
description = "Garuda Linux PKGBUILD flake ❄️";
inputs = {
# Devshell to set up a development environment
devshell.url = "github:numtide/devshell";
devshell.flake = false;
# Common used input of our flake inputs
flake-utils.url = "github:numtide/flake-utils";
# The single source of truth
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Easy linting of the flake and all kind of other stuff
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ devshell
, flake-parts
, nixpkgs
, pre-commit-hooks
, self
, ...
} @ inp:
let
inputs = inp;
perSystem =
{ pkgs
, system
, ...
}: {
checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
hooks = {
commitizen.enable = true;
nixpkgs-fmt.enable = true;
markdownlint.enable = true;
pkgbuilds-shellcheck = {
enable = true;
name = "PKGBUILD shellcheck";
entry = "${pkgs.shellcheck}/bin/shellcheck";
files = "(PKGBUILD|install$)";
types = [ "text" ];
language = "system";
};
pkgbuilds-style = {
enable = true;
name = "PKGBUILD shfmt";
entry = "${pkgs.shfmt}/bin/shfmt -d -w";
files = "(PKGBUILD|install$)";
types = [ "text" ];
language = "system";
};
prettier.enable = true;
yamllint.enable = true;
};
src = ./.;
};
devShells =
let
makeDevshell = import "${inp.devshell}/modules" pkgs;
mkShell = config:
(makeDevshell {
configuration = {
inherit config;
imports = [ ];
};
}).shell;
in
rec {
default = garuda-shell;
garuda-shell = mkShell {
devshell.name = "garuda-shell";
commands = [
{ package = "commitizen"; }
{ package = "markdownlint-cli"; }
{ package = "pre-commit"; }
{ package = "nodePackages.prettier"; }
{ package = "shellcheck"; }
{ package = "shfmt"; }
{ package = "yamllint"; }
];
devshell.startup = {
preCommitHooks.text = self.checks.${system}.pre-commit-check.shellHook;
garudaEnv.text = ''
export LC_ALL="C.UTF-8"
export NIX_PATH=nixpkgs=${nixpkgs}
'';
};
};
};
formatter = pkgs.nixpkgs-fmt;
};
in
flake-parts.lib.mkFlake { inherit inputs; } {
# Flake modules
imports = [ inputs.pre-commit-hooks.flakeModule ];
# The available systems
systems = [ "x86_64-linux" "aarch64-linux" ];
# This applies to all systems
inherit perSystem;
};
}