Skip to content

Commit fb7c730

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
1 parent fe728a9 commit fb7c730

File tree

7 files changed

+237
-0
lines changed

7 files changed

+237
-0
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/nix-check.yml

Lines changed: 28 additions & 0 deletions
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 develop -c fmt-check

.github/workflows/update-nix.yml

Lines changed: 21 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 96 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: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 = let rust = super.rust-bin;
39+
in if builtins.pathExists ./rust-toolchain.toml then
40+
rust.fromRustupToolchainFile ./rust-toolchain.toml
41+
else if builtins.pathExists ./rust-toolchain then
42+
rust.fromRustupToolchainFile ./rust-toolchain
43+
else
44+
rust.nightly.latest.default;
45+
})
46+
];
47+
config = { };
48+
};
49+
50+
# Used to check formatting for nix specificly
51+
checks.fmt-check =
52+
pkgs.runCommand "format-check"
53+
{
54+
src = ./.;
55+
doCheck = true;
56+
nativeBuildInputs = [
57+
pkgs.nixfmt-rfc-style
58+
];
59+
}
60+
''
61+
nixfmt --check .
62+
touch $out
63+
'';
64+
65+
devShells.default = pkgs.mkShell {
66+
packages = with pkgs; [
67+
rustToolchain
68+
pkg-config
69+
openssl
70+
];
71+
};
72+
73+
};
74+
};
75+
}

shell.nix

Lines changed: 12 additions & 0 deletions
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)