Skip to content

Commit 53a7304

Browse files
committed
Update Nix packaging files
1 parent 9bfc45f commit 53a7304

File tree

3 files changed

+106
-54
lines changed

3 files changed

+106
-54
lines changed

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $RECYCLE.BIN/
2727
# Ignore all the scraped data
2828
scraped-data
2929

30-
#pytest
30+
# pytest
3131
/test/.jbsite
3232
/test/screenshots/
3333
/test/.pytest_cache
@@ -43,4 +43,7 @@ node_modules/
4343
env
4444
core
4545
core
46-
result
46+
result
47+
48+
# Nix
49+
result

flake.nix

+69-27
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,90 @@
11
{
2-
description = "Development environment and build process for a Hugo app with Python requirements";
2+
description = "QGIS Planet Website";
3+
4+
# nixConfig = {
5+
# extra-substituters = [ "https://example.cachix.org" ];
6+
# extra-trusted-public-keys = [ "example.cachix.org-1:xxxx=" ];
7+
# };
38

49
inputs = {
510
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
611
};
712

8-
outputs = { self, nixpkgs }:
13+
outputs = { self, nixpkgs }:
914
let
15+
# Flake system
1016
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
1117
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
12-
13-
nixpkgsFor = forAllSystems (system: import nixpkgs {
14-
inherit system;
18+
nixpkgsFor = forAllSystems (system: import nixpkgs {
19+
inherit system;
1520
config.allowUnfree = true;
1621
});
1722

18-
mkDevShell = system:
23+
in
24+
{
25+
#
26+
### PACKAGES
27+
#
28+
29+
packages = forAllSystems (system:
30+
let
31+
pkgs = nixpkgsFor.${system};
32+
33+
in
34+
{
35+
website = pkgs.callPackage ./package.nix { };
36+
});
37+
38+
39+
#
40+
### APPS
41+
#
42+
43+
apps = forAllSystems (system:
44+
let
45+
pkgs = nixpkgsFor.${system};
46+
inherit (nixpkgs) lib;
47+
48+
wwwLauncher = pkgs.writeShellApplication {
49+
name = "website";
50+
runtimeInputs = [ pkgs.python3 ];
51+
text = ''
52+
exec ${lib.getExe pkgs.python3} \
53+
-m http.server 8000 \
54+
-d ${self.packages.${system}.website}/
55+
'';
56+
};
57+
58+
in
59+
{
60+
default = {
61+
type = "app";
62+
program = "${wwwLauncher}/bin/website";
63+
};
64+
});
65+
66+
67+
#
68+
### SHELLS
69+
#
70+
71+
devShells = forAllSystems (system:
1972
let
2073
pkgs = nixpkgsFor.${system};
74+
2175
in
2276
{
77+
# Development environment
2378
default = pkgs.mkShell {
79+
2480
packages = with pkgs; [
25-
hugo # Hugo for building the website
26-
vscode # VSCode for development
27-
python312Packages.feedparser # Python package: feedparser
28-
python312Packages.requests # Python package: requests
29-
python312Packages.pillow # Python package: Pillow
81+
hugo # Hugo for building the website
82+
vscode # VSCode for development
83+
python312Packages.feedparser # Python package: feedparser
84+
python312Packages.requests # Python package: requests
85+
python312Packages.pillow # Python package: Pillow
3086
python312Packages.python-dateutil # Python package: dateutil
31-
gnumake # GNU Make for build automation
87+
gnumake # GNU Make for build automation
3288
];
3389

3490
shellHook = ''
@@ -51,20 +107,6 @@
51107
echo "-----------------------"
52108
'';
53109
};
54-
};
55-
56-
in
57-
{
58-
devShells = builtins.listToAttrs (map (system: {
59-
name = system;
60-
value = mkDevShell system;
61-
}) supportedSystems);
62-
63-
packages = builtins.listToAttrs (map (system: {
64-
name = system;
65-
value = {
66-
qgis-planet-website = nixpkgsFor.${system}.callPackage ./package.nix {};
67-
};
68-
}) supportedSystems);
110+
});
69111
};
70112
}

package.nix

+32-25
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
1-
{ lib, stdenv, hugo, gnumake }:
1+
{ lib
2+
, stdenv
3+
, hugo
4+
}:
25

36
stdenv.mkDerivation {
4-
name = "qgis-planet-website";
5-
src = lib.cleanSourceWith {
6-
src = ./.;
7-
filter = (
8-
path: type: (builtins.all (x: x != baseNameOf path) [
9-
".git"
10-
".github"
11-
"flake.nix"
12-
"package.nix"
13-
])
14-
);
15-
};
16-
buildInputs = [ hugo gnumake ];
7+
name = "qgis-planet-website";
178

18-
buildPhase = ''
19-
make deploy
20-
'';
9+
src = lib.cleanSourceWith {
10+
src = ./.;
11+
filter = (
12+
path: type: (builtins.all (x: x != baseNameOf path) [
13+
".git"
14+
".github"
15+
"flake.nix"
16+
"flake.lock"
17+
"package.nix"
18+
"result"
19+
])
20+
);
21+
};
2122

22-
installPhase = ''
23-
mkdir -p $out
24-
cp -r public/* $out/
25-
'';
23+
buildInputs = [ hugo ];
2624

27-
meta = with lib; {
28-
description = "A built QGIS Planet website";
29-
license = licenses.mit;
30-
};
25+
buildPhase = ''
26+
hugo --config config.toml,config/config.prod.toml
27+
'';
28+
29+
installPhase = ''
30+
mkdir -p $out
31+
cp -r public_prod/* $out/
32+
'';
33+
34+
meta = with lib; {
35+
description = "A built QGIS Planet website";
36+
license = licenses.mit;
37+
};
3138
}
3239

0 commit comments

Comments
 (0)