Skip to content

Commit 16466dc

Browse files
build: add nix support
I use nix for everything so it felt kinda weird not having it in this project. Nix will ensure that all colaborators use the exact same version of node, as well as the docker.
1 parent bc0cadc commit 16466dc

File tree

17 files changed

+632
-0
lines changed

17 files changed

+632
-0
lines changed

.envrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# shellcheck shell=sh
2+
3+
# Load environment variables.
4+
if [ -f .env ]; then
5+
dotenv .env
6+
fi
7+
8+
# automatically loads a Nix Development environment if nix is installed.
9+
if has nix; then
10+
use flake .
11+
else
12+
echo 'Error: `nix` is not installed.'
13+
echo 'Please consider installing nix.'
14+
fi

default.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(import
2+
(
3+
let
4+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
5+
node = lock.nodes.flake-compat.locked;
6+
7+
sha256 = node.narHash;
8+
inherit (node) owner;
9+
inherit (node) repo;
10+
inherit (node) rev;
11+
inherit (node) type;
12+
13+
url =
14+
if type == "github" then
15+
"https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"
16+
else
17+
throw "Unknown URL type: ${type}";
18+
in
19+
fetchTarball {
20+
inherit url;
21+
inherit sha256;
22+
}
23+
)
24+
{
25+
src = ./.;
26+
}
27+
).defaultNix

flake.lock

Lines changed: 166 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
description = "Make beautifully animated Slydes and presentations from XML with ease!";
3+
4+
# A collection of packages for the Nix package manager
5+
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
6+
7+
# Generate Github Actions matrices from Nix Flakes
8+
inputs.nix-github-actions = {
9+
url = "github:nix-community/nix-github-actions";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
12+
13+
# Flake basics described using the module system
14+
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
15+
16+
# Allow flakes to be used with Nix < 2.4
17+
inputs.flake-compat = {
18+
url = "github:edolstra/flake-compat";
19+
flake = false;
20+
};
21+
22+
# treefmt nix configuration modules
23+
inputs.treefmt-nix = {
24+
url = "github:numtide/treefmt-nix";
25+
inputs.nixpkgs.follows = "nixpkgs";
26+
};
27+
28+
# Seamless integration of https://pre-commit.com git hooks with Nix.
29+
inputs.git-hooks-nix = {
30+
url = "github:cachix/git-hooks.nix";
31+
inputs.flake-compat.follows = "flake-compat";
32+
inputs.nixpkgs.follows = "nixpkgs";
33+
};
34+
35+
outputs =
36+
inputs:
37+
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
38+
imports = [ ./nix ];
39+
systems = [
40+
"aarch64-darwin"
41+
"aarch64-linux"
42+
"x86_64-darwin"
43+
"x86_64-linux"
44+
];
45+
};
46+
}

nix/apps/default.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
_:
2+
{
3+
perSystem = _: {
4+
# do not set a default, let that be the default package instead.
5+
};
6+
}

nix/ci/default.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{ inputs, config, ... }:
2+
let
3+
inherit (inputs) nix-github-actions;
4+
in
5+
{
6+
# Used by GitHub Actions to create a matrix out of this:
7+
flake.githubActions = nix-github-actions.lib.mkGithubMatrix {
8+
checks = inputs.nixpkgs.lib.getAttrs config.systems (
9+
# check whether the packages can be build for every platform,
10+
# but for Linux x86_64 also do the other checks. Prevents
11+
# duplicated checks for non-package builds as formatting for
12+
# example should be platform independent.
13+
inputs.self.packages // { inherit (inputs.self.checks) x86_64-linux; }
14+
);
15+
};
16+
}

nix/default.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
_: {
2+
imports = [
3+
./apps
4+
./ci
5+
./formatting
6+
./hooks
7+
./overlays
8+
./packages
9+
./shells
10+
];
11+
}

nix/formatting/default.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ inputs, ... }:
2+
{
3+
imports = [
4+
inputs.treefmt-nix.flakeModule
5+
];
6+
7+
perSystem = _: {
8+
treefmt = {
9+
enableDefaultExcludes = true;
10+
flakeCheck = true;
11+
flakeFormatter = true;
12+
#// on-unmatched = "warn";
13+
14+
# nix formatting
15+
programs.nixfmt = {
16+
enable = true;
17+
};
18+
19+
# nix static analysis
20+
programs.statix = {
21+
enable = true;
22+
};
23+
24+
# find dead nix code
25+
programs.deadnix = {
26+
enable = true;
27+
};
28+
};
29+
};
30+
}

nix/hooks/default.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{ ... }:
2+
{
3+
imports = [
4+
./git.nix
5+
];
6+
}

0 commit comments

Comments
 (0)