-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
106 lines (102 loc) · 3.01 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
npmlock2nix = {
url = "github:nix-community/npmlock2nix";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, devshell, npmlock2nix, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlays.default
(final: prev: {
npmlock2nix = import inputs.npmlock2nix { pkgs = prev; };
})
];
};
in
rec {
packages.node_modules = pkgs.npmlock2nix.v2.node_modules {
src = ./.; # This should point to your source folder
packageJson = ./package.json;
packageLockJson = ./package-lock.json;
nodejs = pkgs.nodejs_20; # Explicitly use Node.js 20
};
packages.website = pkgs.stdenvNoCC.mkDerivation {
name = "rosenpass-website";
src = ./.;
nativeBuildInputs = with pkgs; [ hugo groff packages.node_modules go git which ];
buildPhase = ''
runHook preBuild
ln --symbolic -- ${packages.node_modules}/node_modules ./
hugo
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp --recursive -- public $out/
runHook postInstall
'';
};
packages.default = packages.website;
devShells.default = (pkgs.devshell.mkShell {
imports = [ "${devshell}/extra/git/hooks.nix" ];
name = "rosenpass-website-dev-shell";
packages = with pkgs; [
groff
hugo
nodejs_20
nodePackages.prettier
];
git.hooks = {
enable = true;
pre-commit.text = ''
nix flake check
'';
};
commands = [
{
name = "build";
command = ''
./scripts/changelog-check.sh
git submodule update --init --recursive
npm ci
hugo $@
'';
help = "build the website";
}
{
name = "serve";
command = ''
./scripts/changelog-check.sh
npm ci
hugo server $@
'';
help = "run hugo in server mode";
}
{
name = "redirects";
command = ''
./scripts/redirects.sh
'';
help = "update the alias list for the website";
}
{
name = "clean";
command = ''
cd "$PRJ_ROOT"
rm --force --recursive -- node_modules public
'';
help = "remove public/ and node_modules/";
}
];
});
}
);
}