Skip to content

Commit 3688d11

Browse files
committed
add nix/nixos development enviroment and automation for easy maintenance
make flake check action check all systems added assignment to assign myself to flake update prs. fix actions to use determinsys switch nix formatting check to flake check fix formatting for nix
1 parent fe728a9 commit 3688d11

File tree

7 files changed

+240
-0
lines changed

7 files changed

+240
-0
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/nix-check.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run nix checks on prs
2+
3+
on:
4+
pull_request:
5+
branches: [ "master", "rewrite/v3" ]
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
jobs:
12+
check:
13+
name: Check Nix
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install Nix
21+
uses: DeterminateSystems/nix-installer-action@main
22+
- uses: DeterminateSystems/magic-nix-cache-action@main
23+
- name: Check flake.lock
24+
uses: DeterminateSystems/flake-checker-action@main
25+
with:
26+
fail-mode: true
27+
- name: Check Nix formatting
28+
run: nix flake check

.github/workflows/update-nix.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: update-flake-lock
2+
on:
3+
workflow_dispatch: # allows manual triggering
4+
schedule:
5+
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
lockfile:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: DeterminateSystems/nix-installer-action@main
17+
- uses: DeterminateSystems/magic-nix-cache-action@main
18+
- uses: DeterminateSystems/update-flake-lock@main
19+
with:
20+
pr-title: "Update flake.lock"
21+
pr-assignees: eveeifyeve

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ config.toml
1212
.etc/blocks.json
1313

1414
flame.svg
15+
16+
.direnv
17+
result
18+
result-*

flake.lock

+96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
flake-compat = {
6+
url = "github:edolstra/flake-compat";
7+
flake = false;
8+
};
9+
rust-overlay = {
10+
url = "github:oxalica/rust-overlay";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
};
13+
};
14+
15+
outputs =
16+
inputs@{
17+
flake-parts,
18+
nixpkgs,
19+
rust-overlay,
20+
...
21+
}:
22+
flake-parts.lib.mkFlake { inherit inputs; } {
23+
systems = nixpkgs.lib.systems.flakeExposed;
24+
25+
perSystem =
26+
{
27+
pkgs,
28+
system,
29+
...
30+
}:
31+
{
32+
formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
33+
_module.args.pkgs = import inputs.nixpkgs {
34+
inherit system;
35+
overlays = [
36+
rust-overlay.overlays.default
37+
(self: super: {
38+
rustToolchain =
39+
let
40+
rust = super.rust-bin;
41+
in
42+
if builtins.pathExists ./rust-toolchain.toml then
43+
rust.fromRustupToolchainFile ./rust-toolchain.toml
44+
else if builtins.pathExists ./rust-toolchain then
45+
rust.fromRustupToolchainFile ./rust-toolchain
46+
else
47+
rust.nightly.latest.default;
48+
})
49+
];
50+
config = { };
51+
};
52+
53+
# Used to check formatting for nix specificly
54+
checks.fmt-check =
55+
pkgs.runCommand "format-check"
56+
{
57+
src = ./.;
58+
doCheck = true;
59+
nativeBuildInputs = [
60+
pkgs.nixfmt-rfc-style
61+
];
62+
}
63+
''
64+
nixfmt --check .
65+
touch $out
66+
'';
67+
68+
devShells.default = pkgs.mkShell {
69+
packages = with pkgs; [
70+
rustToolchain
71+
pkg-config
72+
openssl
73+
];
74+
};
75+
76+
};
77+
};
78+
}

shell.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(import (
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
nodeName = lock.nodes.root.inputs.flake-compat;
5+
in
6+
fetchTarball {
7+
url =
8+
lock.nodes.${nodeName}.locked.url
9+
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
10+
sha256 = lock.nodes.${nodeName}.locked.narHash;
11+
}
12+
) { src = ./.; }).shellNix

0 commit comments

Comments
 (0)