1
Fork 0

migrate to nix flake

main
Motiejus Jakštys 2023-03-25 12:43:23 +02:00
parent 8a77c3e232
commit 9f30e924c1
8 changed files with 101 additions and 9 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/.direnv
/.hugo_build.lock
/resources/_gen
/public

60
flake.lock Normal file
View File

@ -0,0 +1,60 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1679710833,
"narHash": "sha256-9yKVvGX1oAnlc8vTVvN2lRH35q6ETudQbM1w9ragMRU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "83607dae4e05e1de755bbc7d7949b33fc1cfbbb9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

21
flake.nix Normal file
View File

@ -0,0 +1,21 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShells.default = with pkgs; mkShell {
name = "rules_nixpkgs_shell";
packages = [ bash hugo zopfli brotli parallel ];
};
});
}

6
nixpkgs.nix Normal file
View File

@ -0,0 +1,6 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
spec = lock.nodes.nixpkgs.locked;
nixpkgs = fetchTarball "https://github.com/${spec.owner}/${spec.repo}/archive/${spec.rev}.tar.gz";
in
import nixpkgs

View File

@ -1,6 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)/jakstys.lt"
cd "$(git rev-parse --show-toplevel)"
hugo --cleanDestinationDir --printPathWarnings --panicOnWarning --log
# https://github.com/gohugoio/hugo/issues/8734
@ -8,12 +8,10 @@ hugo --cleanDestinationDir --printPathWarnings --panicOnWarning --log
# --buildDrafts --config config.yaml,debugconfig.yaml -d public/zz
cd public
zopfli=$(bazel run --ui_event_filters=-info,-stdout,-stderr --noshow_progress --run_under=echo @zopfli//:zopfli)
brotli=$(bazel run --ui_event_filters=-info,-stdout,-stderr --noshow_progress --run_under=echo @brotli//:brotli)
find . \
-name '*.html' -or \
-name '*.xml' -or \
-name '*.txt' -or \
-name '*.css' -or \
-name '*.map' | parallel --eta "$zopfli {} && $brotli {}"
-name '*.map' | parallel --eta "zopfli {} && brotli {}"

View File

@ -1,6 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)/jakstys.lt"
cd "$(git rev-parse --show-toplevel)"
scripts/build
scripts/upload

View File

@ -1,5 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)/jakstys.lt"
cd "$(git rev-parse --show-toplevel)"
rsync --info=progress2 -a --partial --delete public/ jakstys.lt:/data/public_html/
rsync --info=progress2 -a --partial --delete public/ beta.jakstys.lt:/var/www/jakstys.lt/