-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
100 lines (87 loc) · 2.92 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
{
description = "modern-hugo-resume";
inputs = {
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
biome = pkgs.biome;
commitlint = pkgs.commitlint;
git = pkgs.git;
go = pkgs.go;
hugo = pkgs.hugo;
nativeBuildInputs = [ go hugo ];
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
biome.enable = true;
commitizen.enable = true;
nixpkgs-fmt.enable = true;
};
};
};
packages.default = pkgs.stdenv.mkDerivation (finalAttrs: {
inherit nativeBuildInputs;
pname = "modern-hugo-resume-exampleSite";
# TODO: remove `name` once I get around to versioning this
name = finalAttrs.pname;
src = with pkgs.lib.fileset; (toSource {
root = ./.;
fileset = difference
(gitTracked ./.)
(unions [
./.github
./.vscode
./.envrc
./.gitignore
./biome.json
./LICENSE
./README.md
])
;
});
sourceRoot = "${finalAttrs.src.name}/exampleSite";
buildPhase =
let
hugoVendor = pkgs.stdenv.mkDerivation {
name = "${finalAttrs.pname}-hugoVendor";
inherit (finalAttrs) src sourceRoot;
nativeBuildInputs = [ go hugo git ];
buildPhase = ''
hugo mod vendor
'';
installPhase = ''
cp -r _vendor $out
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
# To get a new hash:
# 1. Replace the existing hash with `pkgs.lib.fakeHash`
# 2. Run `nix build` or push to GitHub (it will fail and provide the new hash)
# 3. Substitute the new hash (`nix build` should now work)
outputHash = "sha256-mFnxMxPDojDfxKDZE8xGopHYFnUi1/L7rjGsealysao=";
};
in
''
ln -s ${hugoVendor} _vendor
hugo --minify -d $out
'';
dontInstall = true;
dontFixup = true;
});
devShell = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
nativeBuildInputs = nativeBuildInputs ++ [
biome
self.checks.${system}.pre-commit-check.enabledPackages
];
};
});
}